Connecting to the LoanPro API

Complexity:    

Audience: Developers, Data

In this article, we explain how to connect to the LoanPro API. However, if you're new to the concept of APIs, we recommend starting with our APIs 101 article, where we cover the basics of the topic.

Introduction

To connect to LoanPro's API, 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, and we recommend using either of them.

Alternatively, 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 learn about the structure of an HTTP request so you can understand what is going on in our 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.

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

How To Get Your Credentials

Once you have your client of choice set up, it’s time to get your API credentials. These credentials consist of two pieces: a tenant ID and an API token. To get your 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 access.

Step 1

Next, navigate to Settings > Company > API > Overview. If your API credentials have not yet been set up, you will see a page like the example shown below. If this is the case for you, complete the next two steps. But if your API token is already setup, skip ahead to step 3.

Click 'Do it now.'

Step 2

You’ll then be presented with the pop-up shown below. Use the drop-down menu to select an agent user to associate with API access and actions. Agent users that have not signed the SaaS agreement will not be available on this list.

This agent user will be associated with every action completed through API calls. This will be shown in system notes, reports, time/date stamps, etc. We highly recommend that you create a new agent user specifically for API requests so you can differentiate between which actions occurred though the API and which didn't.

If you have multiple tenants (such as production, sandbox, and testing), it is required that you create an agent user for each tenant and assign that agent as your API user.

When creating API agent users, we recommend using a naming convention for assigned email addresses similar to the following examples:

  • Production tenant – ProductionAPI@companyname.com
  • Sandbox tenant – SandboxAPI@companyname.com
  • Test tenant – TestAPI@company@companyname.com

Once you have selected an agent user, click 'Save'.

Step 3

If your API Access has been configured, your credentials will be generated and displayed like the following:

To maintain security, you must enter the top-level domain for the server from which API requests will originate. This should be formatted as https://yourdomain.com.

Entering your server domain is required. Requests to the API will receive a 401 response if you have not entered it.

You also have the option to allow LoanPro to regularly cycle your keys. Key rotation comes with a bit of a trade-off: it will make your API connection more secure, but you will need to update the keys within your code each time they change. We recommend selecting the option that fits your company's needs and security policies best.

To the right of the registered user information, 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 the data within your tenant account.

You now have the credential information needed for API requests.

Using Your 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:

Content-Type: application/json
Authorization: Bearer f2baf317eb45527580d1da1d258a79c75076541d4
Autopal-Instance-Id: 5200243

Your headers will need to be formatted exactly as shown in the example above, but with your authentication information instead.

Here is an example of setting header information with JavaScript. Setting the headers for an account with an API Token of “ABCDEFG1234567” and a Tenant ID of "12345" would look like the following:

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 provide a way to select which type of request you want to send. Send the request to the following endpoint:

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

This should return a 200 response, and the body of which will look 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
}
]
}
}

It's important to mention that the LoanPro API is built on top of OData, a prominent REST framework, and only accepts JSON objects in bodies of POST and PUT requests.

With that, you're connected to the LoanPro API.

What's Next

Now that you are connected to the LoanPro API, you can begin testing some requests. For a complete list of all LoanPro endpoints, visit our Swagger UI page. For a more interactive experience with our requests where you can test values without a REST client, take a look at our ReadMe documentation page.

Lastly, all of our API documentation is also located here on our help site. View our LMS API category for Loan Management System (LMS) requests and our Secure Payments API category for Secure Payments requests.


How did we do?


Powered by HelpDocs (opens in a new tab)