A Quick Overview to the LoanPro API, Part 2

Connecting to the API

Introduction

To connect to LoanPro, you’ll need an HTTP client—an application on your computer that will send HTTP requests. If you want to send requests to the API without writing code, a REST client will work, since REST clients are HTTP clients with a graphical user interface and helpful tools. Some popular REST clients are Postman and Insomnia. Alternately, you could use command-line utilities, such as cURL, or an HTTP library for your chosen programming language, if available. This tutorial will include code samples for a handful of languages, but we’ll also show the raw HTTP requests so that you can translate them to the language of your choice.

If you aren’t using one of our supported languages, we recommend taking some time to understand the structure of an HTTP request so you can understand what is going on in our HTTP samples. Some good resources for this include TutorialsPoint, Udacity, MDN Web Docs and Codecademy. We recommend referring to your HTTP client’s documentation on how to set it up, as many of them have tutorials on how to send a sample request. Once you have your client setup, it’s time to get your API credentials.

Note: LoanPro uses TLS 1.2 to encrypt communications. When selecting an HTTP client make sure it’s compatible with TLS 1.2.

API credentials consist of two pieces: a tenant ID and an API token. To get the tenant ID and API token, you’ll need to log in to the LoanPro user interface. Upon login, you’ll need to select the tenant you want to get access to.

Next, go to Main Menu > Settings > Company > API > Overview. Once there, will see a page like the example shown below if your API credentials have not yet been set up. If so, complete the next two steps. If your API token is already setup, skip ahead to step 3.

1. First, click 'Do it now.'

2. You’ll then be presented with a popup similar to the example shown below. Use the drop-down menu to select a user to associate with API Access and actions. Click 'Save'.

3. Once your API Access has been configured, your credentials will be shown as in the following example:

To the right, you’ll see the API URL. This is the base URL of the LoanPro API, and all endpoints throughout the tutorial will be relative to this URL. You’ll also see the tenant ID and the API Token that you’ll use to access the API. Keep track of these as you will use them to access the API.

Caution: Keep your tenant ID and API token safe! Anyone who has them can access your tenant and either steal or corrupt your data.

Using Credentials

To use your credentials, you’ll need to set some HTTP headers. Most libraries will have a function to do this, and REST clients will usually have a dedicated headers tab where headers can be set. You’ll need to set the following headers:

Authorization: Bearer <API Token>

Autopal-Instance-ID: <Tenant ID>

Content-Type: application/json

const apiToken = '';
const instanceId = '';

const loanproApi = axios.create({
headers: {
'Authorization': `Bearer ${apiToken}`,
'Autopal-Instance-ID': instanceId
}
});

For example, if your API Token is “ABCDEFG1234567” and the Tenant ID 12345, your headers would be:

const apiToken = 'ABCDEFG1234567';
const instanceId = '12345';

const loanproApi = axios.create({
headers: {
'Authorization': `Bearer ${apiToken}`,
'Autopal-Instance-ID': instanceId
}
});

Testing the Connection

To test the connection, send a GET request to the LoanPro server; your REST client will have a way to select which type of request you want to send. Send the request to the following endpoint:

https://loanpro.simnang.com/api/public/api/1/tenant.settings(company.date)

This should return a 200 response, the body of which looks like the following:

{
"d": {
"results": [
{
"id": "company.date.format",
"label": "Date Formatting",
"type": "STRING",
"value": "MM/dd/yyyy",
"group": "company.date",
"modified": "0",
"modified_by": "0",
"sequence": 0
}
]
}
}

Congratulations! You’ve just connected to the LoanPro API!

Go back to Part 1.


How did we do?


Powered by HelpDocs (opens in a new tab)