Skip to content

Latest commit

 

History

History
417 lines (321 loc) · 13.3 KB

README.md

File metadata and controls

417 lines (321 loc) · 13.3 KB

Experian API .Net Library

The Experian .Net library provides convenient access to the RESTful Experian APIs from Applications written in .Net. This package is for use with .Net Applications (.Net Standard 2.0+) that uses Experian client_id, client_secret, username, password obtainable from the developer portal and subcode (if applicable).

Stage Status
C# CI Build Status
Nuget Publish Deployment Status

API Documentation

For Detailed documentation of Experian APIs, visit Experian Developers Portal

.Net Setup & Development

Getting started

Prerequisites to use

  1. .Net Standard 2.0 (.Net Framework 4.6.1, .Net Core 2.0)
  2. Nuget 3.x+
  3. Download the package: Experian.Api.Client via your favourite packet manager
  4. Alternatively you can download directly from: https://www.nuget.org/packages/Experian.Api.Client/

Prerequisites to Build

  1. .Net Core SDK 2.1.4
  2. Git Client

Package Usage

ServiceClient is the main component. It is a thin wrapper to HttpClient that adds methods to call our Authentication API and the Service Endpoint. By including a Service collection namespace (e.g. using Experian.Api.Client.Bis) you will also bring in that service collections request/response models and helper extension methods for ServiceClient.

ServiceClient configuration

The service client uses an underlying HttpClient that it can create itself or can be passed in. If you need to configure special headers or a proxy, simply configure a HttpClient as desired then pass it to the ServiceClient Constructor.

TLS 1.2 and older versions of .Net

Experian API's require a TLS 1.2 connection. For the latest versions of .Net Framework and .Net Core this (or higher) is the default. However older versions of .Net will require an additional line of configuration in order to negotiate a connection to the server correctly:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;

This line needs to execute anywhere before you POST the request to the server. Note that versions of .Net released earlier than 2012 did not contain TLS 1.2 support.

Authentication before Calling the API

Api.Experian.Com

Services on api.Experian.com such as Business Information Services require a Bearer token (in this case a OAuth Access token). This token can be obtained with the code below.

    var serviceClient = new ServiceClient();
    var authResult    = serviceClient.SendAuthenticationRequestAsync(new AuthRequest(Username, Password), ClientId, ClientSecret, ServiceClient.OAuthSandboxUrl).Result;

The ClientId, ClientSecret can be obtained from an App created in the developer.experian.com portal. The username and password are your credentials for the portal. The authenticated response returns the the access token, the token type (bearer), the time the token was created (in milliseconds from the Unix Time/Epoch UTC). It also gives you the time the token will expire and you need to get another one (you should write your re-authenticate logic based on this field rather than a fixed time period).

Example

namespace Experian.Api.Example
{
    using System;
    using Experian.Api.Client;
    using Experian.Api.Client.Bis;

    internal sealed class Program
    {
        private static void Main(string[] args)
        {
            var request = new ReverseAddressesRequest()
                            {
                                Subcode = "0517614",
                                Street  = "1 Infinite Loop",
                                City    = "Cupertino",
                                State   = "CA",
                                Zip     = "10118",
                            };

            ClientId         = "YOURCLIENTID";
            ClientSecret     = "YOURCLIENTSECRET";
            Username         = "YOURUSERNAME";
            Password         = "YOURPASSWORD";

            var client       = new ServiceClient();
            var authResponse = client.SendAuthenticationRequestAsync(new AuthRequest(Username, Password), ClientId, ClientSecret, ServiceClient.OAuthSandboxUrl).Result;
            var response     = client.PostReverseAddressAsync(Environ.Sandbox, authResponse, request).Result;
            Console.WriteLine(response.Success);
            Console.ReadKey();
        }
    }
}

Developer Secrets

Our integration tests require confidential information to operation. To prevent this information being publically disclosed in the Git repo we inject these values at runtime. We use two different techniques based on the use case

Local development

Locally we use the .Net User Secrets tool. The tool will be available after a package restore. Then from within the source folder simply type:

dotnet user-secrets set ClientId YOURCLIENTID
dotnet user-secrets set ClientSecret YOURCLIENTSECRET
dotnet user-secrets set Username YOURUSERNAME
dotnet user-secrets set Password YOURPASSWORD

This will set up your local system to hold these secrets without checking them into source control.

Running tests on a Build server

For Integration Tests on a build server, the variables can be injected via Environment variables can be used instead.

BIS Service usage

Bankruptcies
            var request = new BankruptcyRequest()
            {
                Bin               = "404197602",
                Subcode           = "0517614",
                BankruptcySummary = true,
                BankruptcyDetail  = true,
            };

            var response = serviceClient.PostBankruptcyAsync(Environ.Sandbox, authResponse, request);
Business Contacts
            var request = new BusinessContactsRequest()
            {
                Bin      = "725862571",
                Subcode  = "0517614",
                Comments = "test",
            };

            var response = serviceClient.PostBusinessContactsAsync(Environ.Sandbox, authResponse, request);
Business Facts
            var request = new BusinessFactsRequest()
            {
                Bin     = "807205801",
                Subcode = "0517614",
            };

            var response = serviceClient.PostBusinessFactsAsync(Environ.Sandbox, authResponse, request);
Collections
    var request = new BusinessRequest()
    {
        Bin                = "700880075",
        Subcode            = "0517614",
        CollectionsSummary = true,
        CollectionsDetail  = true,
    };

    var response = serviceClient.PostCollectionsAsync(Environment.Sandbox, authResponse, request);
Corporate Linkage
            var request = new CorporateLinkageRequest()
            {
                Bin                     = "700513485",
                Subcode                 = "0517614",
                ModelCode               = "000224",
                CorporateLinkagePartial = true,
                CorporateLinkageFull    = true,
            };

            var response = serviceClient.PostCorporateLinkageAsync(Environ.Sandbox, authResponse, request);
Corporate Registrations
            var request = new CorporateRegistrationsRequest()
            {
                Bin                     = "700000001",
                Subcode                 = "0517614",
                StatusDescriptionDetail = true,
            };

            var response = serviceClient.PostCorporateRegistrationsAsync(Environ.Sandbox, authResponse, request);
Credit Status
            var request = new CreditStatusRequest()
            {
                Bin     = "807205801",
                Subcode = "0517614",
            };

            var response = serviceClient.PostCreditStatusAsync(Environ.Sandbox, authResponse, request);
Fraud Shields
            var request = new FraudShieldsRequest()
            {
                Bin     = "807205801",
                Subcode = "0517614",
            };

            var response = serviceClient.PostFraudShieldsAsync(Environ.Sandbox, authResponse, request);

Headers

            var request = new HeadersRequest()
            {
                Bin     = "807205801",
                Subcode = "0517614",
            };

            var response = serviceClient.PostHeadersAsync(Environ.Sandbox, authResponse, request);
Judgements
            var request = new JudgmentsRequest()
            {
                Bin             = "700969989",
                Subcode         = "0517614",
                JudgmentSummary = true,
                JudgmentDetail  = true,
             };

            var response = serviceClient.PostJudgmentsAsync(Environ.Sandbox, authResponse, request);
Legal Collection Summaries
            var request = new LegalFilingsCollectionsSummariesRequest()
            {
                Bin                            = "800914632",
                Subcode                        = "0517614",
                LegalFilingsCollectionsSummary = true,
                LegalFilingsSummary            = true
            };

            var response = serviceClient.PostLegalCollectionSummariesAsync(Environ.Sandbox, authResponse, request);
Liens
            var request = new LiensRequest()
            {
                    Bin         = "701000078",
                    Subcode     = "0517614",
                    LienSummary = true,
                    LienDetail  = true
            };

            var response = serviceClient.PostLiensAsync(Environ.Sandbox, authResponse, request);
Risk Dashboards
            var request = new RiskDashboardsRequest()
            {
                Bin       = "807205801",
                Subcode   = "0517614",
                ModelCode = "000224",
            };

            var response = serviceClient.PostRiskDashboardsAsync(Environ.Sandbox, authResponse, request);
Scores
        var request = new ScoresRequest()
        {
            Bin = "700000001",
            Subcode         = "0517614",
            ModelCode       = "000224",
            FsrScore        = true,
            CommercialScore = true,
        };

        var response = serviceClient.PostScoresAsync(Environment.Sandbox, authResponse, request);
Trades
            var request = new TradesRequest()
            {
                Bin                     = "700000001",
                Subcode                 = "0517614",
                TradePaymentSummary     = true,
                TradePaymentTotals      = true,
                TradePaymentExperiences = true,
                TradePaymentTrends      = true,
            };

            var response = serviceClient.PostTradesAsync(Environ.Sandbox, authResponse, request);
UCC Filings
            var request = new UccFilingsRequest()
            {
                Bin               = "700969989",
                Subcode           = "0517614",
                UccFilingsSummary = true,
                UccFilingsDetail  = true,
            };

            var response = serviceClient.PostUccFilingsAsync(Environ.Sandbox, authResponse, request);
Reverse Addresses
            var request = new ReverseAddressesRequest()
            {
                Subcode = "0517614",
                Street  = "1 Infinite Loop",
                City    = "Cupertino",
                State   = "CA",
                Zip     = "10118",
            };

            var response = serviceClient.PostReverseAddressAsync(Environ.Sandbox, authResponse, request);
Reverse Phones
            var request = new ReversePhonesRequest()
            {
                Subcode = "0517614",
                Phone   = "8006927753",
            };

            var response = serviceClient.PostReversePhonesAsync(Environ.Sandbox, authResponse, request);
Reverse TaxIDs
            var request = new ReverseTaxIdsRequest()
            {
                Subcode = "0517614",
                TaxId   = "156706138",
            };

            var response = serviceClient.PostReverseTaxidsAsync(Environ.Sandbox, authResponse, request);
Search
            var request = new SearchRequest()
            {
                Name     = "Experian",
                City     = "Costa Mesa",
                State    = "CA",
                Subcode  = "0517614",
                Street   = "475 ANTON BLVD",
                Zip      = "92626",
                Phone    = "9495673800",
                TaxId    = "176970333",
                Geo      = true,
                Comments = "testing",
            };

            var response = serviceClient.PostSearchAsync(Environ.Sandbox, authResponse, request);

An example response object

{
    "requestId": "XXXX-XXXX-XXXX-XXXX",
    "success": true,
    "results": [...]
}

error object

{
    "success": false,
    "requestId": "XXXX-XXXX-XXXX-XXXX",
    "errors": [
        {
            "errorCode": XXXX,
            "errorType": "Error Type",
            "message": "Error Message"
        }
    ]
}