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 | |
Nuget Publish |
For Detailed documentation of Experian APIs, visit Experian Developers Portal
- .Net Standard 2.0 (.Net Framework 4.6.1, .Net Core 2.0)
- Nuget 3.x+
- Download the package: Experian.Api.Client via your favourite packet manager
- Alternatively you can download directly from: https://www.nuget.org/packages/Experian.Api.Client/
- .Net Core SDK 2.1.4
- Git Client
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.
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.
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.
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).
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();
}
}
}
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
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.
For Integration Tests on a build server, the variables can be injected via Environment variables can be used instead.
var request = new BankruptcyRequest()
{
Bin = "404197602",
Subcode = "0517614",
BankruptcySummary = true,
BankruptcyDetail = true,
};
var response = serviceClient.PostBankruptcyAsync(Environ.Sandbox, authResponse, request);
var request = new BusinessContactsRequest()
{
Bin = "725862571",
Subcode = "0517614",
Comments = "test",
};
var response = serviceClient.PostBusinessContactsAsync(Environ.Sandbox, authResponse, request);
var request = new BusinessFactsRequest()
{
Bin = "807205801",
Subcode = "0517614",
};
var response = serviceClient.PostBusinessFactsAsync(Environ.Sandbox, authResponse, request);
var request = new BusinessRequest()
{
Bin = "700880075",
Subcode = "0517614",
CollectionsSummary = true,
CollectionsDetail = true,
};
var response = serviceClient.PostCollectionsAsync(Environment.Sandbox, authResponse, request);
var request = new CorporateLinkageRequest()
{
Bin = "700513485",
Subcode = "0517614",
ModelCode = "000224",
CorporateLinkagePartial = true,
CorporateLinkageFull = true,
};
var response = serviceClient.PostCorporateLinkageAsync(Environ.Sandbox, authResponse, request);
var request = new CorporateRegistrationsRequest()
{
Bin = "700000001",
Subcode = "0517614",
StatusDescriptionDetail = true,
};
var response = serviceClient.PostCorporateRegistrationsAsync(Environ.Sandbox, authResponse, request);
var request = new CreditStatusRequest()
{
Bin = "807205801",
Subcode = "0517614",
};
var response = serviceClient.PostCreditStatusAsync(Environ.Sandbox, authResponse, request);
var request = new FraudShieldsRequest()
{
Bin = "807205801",
Subcode = "0517614",
};
var response = serviceClient.PostFraudShieldsAsync(Environ.Sandbox, authResponse, request);
var request = new HeadersRequest()
{
Bin = "807205801",
Subcode = "0517614",
};
var response = serviceClient.PostHeadersAsync(Environ.Sandbox, authResponse, request);
var request = new JudgmentsRequest()
{
Bin = "700969989",
Subcode = "0517614",
JudgmentSummary = true,
JudgmentDetail = true,
};
var response = serviceClient.PostJudgmentsAsync(Environ.Sandbox, authResponse, request);
var request = new LegalFilingsCollectionsSummariesRequest()
{
Bin = "800914632",
Subcode = "0517614",
LegalFilingsCollectionsSummary = true,
LegalFilingsSummary = true
};
var response = serviceClient.PostLegalCollectionSummariesAsync(Environ.Sandbox, authResponse, request);
var request = new LiensRequest()
{
Bin = "701000078",
Subcode = "0517614",
LienSummary = true,
LienDetail = true
};
var response = serviceClient.PostLiensAsync(Environ.Sandbox, authResponse, request);
var request = new RiskDashboardsRequest()
{
Bin = "807205801",
Subcode = "0517614",
ModelCode = "000224",
};
var response = serviceClient.PostRiskDashboardsAsync(Environ.Sandbox, authResponse, request);
var request = new ScoresRequest()
{
Bin = "700000001",
Subcode = "0517614",
ModelCode = "000224",
FsrScore = true,
CommercialScore = true,
};
var response = serviceClient.PostScoresAsync(Environment.Sandbox, authResponse, request);
var request = new TradesRequest()
{
Bin = "700000001",
Subcode = "0517614",
TradePaymentSummary = true,
TradePaymentTotals = true,
TradePaymentExperiences = true,
TradePaymentTrends = true,
};
var response = serviceClient.PostTradesAsync(Environ.Sandbox, authResponse, request);
var request = new UccFilingsRequest()
{
Bin = "700969989",
Subcode = "0517614",
UccFilingsSummary = true,
UccFilingsDetail = true,
};
var response = serviceClient.PostUccFilingsAsync(Environ.Sandbox, authResponse, request);
var request = new ReverseAddressesRequest()
{
Subcode = "0517614",
Street = "1 Infinite Loop",
City = "Cupertino",
State = "CA",
Zip = "10118",
};
var response = serviceClient.PostReverseAddressAsync(Environ.Sandbox, authResponse, request);
var request = new ReversePhonesRequest()
{
Subcode = "0517614",
Phone = "8006927753",
};
var response = serviceClient.PostReversePhonesAsync(Environ.Sandbox, authResponse, request);
var request = new ReverseTaxIdsRequest()
{
Subcode = "0517614",
TaxId = "156706138",
};
var response = serviceClient.PostReverseTaxidsAsync(Environ.Sandbox, authResponse, request);
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);
{
"requestId": "XXXX-XXXX-XXXX-XXXX",
"success": true,
"results": [...]
}
{
"success": false,
"requestId": "XXXX-XXXX-XXXX-XXXX",
"errors": [
{
"errorCode": XXXX,
"errorType": "Error Type",
"message": "Error Message"
}
]
}