@flexbase/ecredit-node-client
v0.15.0
Published
Node.js Client for CRS Credit eCredit API
Downloads
1,112
Readme
ecredit-node-client
ecredit-node-client
is a Node/JS and TypeScript Client for
CRS Credit that allows you to use normal Node
syntax to Experian, Equifax, and other data from the CRS Credit
eCredit API.
Install
# with npm
$ npm install @flexbase/ecredit-node-client
Usage
This README isn't going to cover all the specifics of what CRS Credit is, and how to use it - it's targeted as a companion to the CRS Credit developer docs that explain each of the endpoints and how the general CRS Credit API works.
However, we'll put in plenty of examples so that it's clear how to use this library to interact with CRS Credit.
Getting your Credentials
This client uses the standard username
and password
, and you obtain those
from the CRS Credit support team.
Creating the Client
At the current time, a targeted subset of functions are available from the client. These are currently about the Experian domain. As we add more features, this client will exapnd, but for now, this works as we need it to.
The basic construction of the client is:
import { Ecredit } from '@flexbase/ecredit-node-client'
const client = new Ecredit(username, password)
If you'd like to provide the Host to use, say, for sandbox access, this can also be provided in the constructor:
const client = new Eclient(username, password, {
host: 'mware-dev.crscreditapi.com/api',
})
where the options can include:
host
- the hostname where all eCredit calls should be sent
Experian Calls
The CRS Credit API documentation is broken up into different sections, and for the Experian section, we have implemented the calls most important to our work.
Basic Credit Report
You can get a Basic Experian Credit Report with a single call:
const resp = await client.experian.basic({
firstName: 'ANDERSON',
lastName: 'LAURIE',
ssn: '666-45-5730',
street1: '9817 LOOP BLVD',
street2: 'APT G',
city: 'CALIFORNIA CITY',
state: 'CA',
zip: '93505-1352',
})
where the user is a test user for Experian's sandbox instance. And the response will be something like:
{
success: true,
report: {
headerRecord: [ [Object] ],
addressInformation: [ [Object], [Object], [Object] ],
consumerIdentity: { dob: [Object], name: [Array] },
employmentInformation: [ [Object], [Object] ],
informationalMessage: [ [Object], [Object] ],
inquiry: [ [Object], [Object], [Object] ],
publicRecord: [ [Object] ],
riskModel: [ [Object] ],
tradeline: [
[Object], [Object],
[Object], [Object],
[Object], [Object],
[Object], [Object],
[Object], [Object],
[Object], [Object],
[Object], [Object],
[Object], [Object],
[Object]
],
endTotals: [ [Object] ]
}
}
where the complete, detailed structure is in the Typescript interface
definitions.
There is an optional config, as detailed in the CRS Credit docs, and that can be specified as:
const resp = await client.experian.basic(person, {
config: 'exp-prequal-vantage4',
})
and that will be the version of the report that's pulled from Experian and returned to CRS Credit, and ultimately, the client.
Development
For those interested in working on the library, there are a few things that
will make that job a little simpler. The organization of the code is all in
src/
, with one module per section of the Client: authentication
,
experian
, etc. This makes location of the function very easy.
Additionally, the main communication with the CRS Credit service is in the
src/index.ts
module in the fire()
function. In the constructor for the
Client, each of the sections are created, and then they link back to the
main class for their communication work.
Setup
In order to work with the code, the development dependencies include dotenv
so that each user can create a .env
file with a single value for working
with CRS Credit:
ECREDIT_USERNAME
- this is the CRS Credit generated "username".ECREDIT_PASSWORD
- this is the CRS Credit "password".
Testing
There are several test scripts that test, and validate, information on the CRS Credit service exercising different parts of the API. Each is self-contained, and can be run with:
$ npm run ts tests/basic.ts
> @flexbase/[email protected] ts
> ts-node -r dotenv/config "tests/basic.ts"
doing a soft pull from Experian...
Success! Pulled the prequal report for test person
doing a hard pull from Experian...
Success! Pulled the hard report for test person
Each of the tests will run a series of calls through the Client, and check the
results to see that the operation succeeded. As shown, if the steps all
report back with Success!
then things are working.
If there is an issue with one of the calls, then an Error!
will be printed
out, and the data returned from the client will be dumped to the console.