# Fetch Third Party Service

These services can encompass a wide range of functionalities, including machine learning scoring models or data pertaining to each borrower within a loan request.

To utilize this API endpoint, developers need to provide two essential parameters: the "loan request ID" and the "Provider Name." With these inputs, the endpoint empowers developers to seamlessly access the specific service offered by the designated third-party provider. Whether it's extracting valuable insights from machine learning models or accessing borrower-specific data, the "Fetch Third Party Service" endpoint simplifies the process of integrating and utilizing external services within the Lenme ecosystem.

## HTTP Request

<mark style="color:green;">`POST`</mark> `https://api.lenmo.app/api/v3/data_marketplace/data_integration/`

This endpoint returns the requested service score for the requested loan ID.

#### Headers

| Name                                          | Type   | Description                                                                 |
| --------------------------------------------- | ------ | --------------------------------------------------------------------------- |
| Accept                                        | String | The content type of the response.                                           |
| X-API-KEY<mark style="color:red;">\*</mark>   | String | The API key that gives the user the authentication to perform this request. |
| Content-Type                                  | String | The type of the request body                                                |
| X-HMAC<mark style="color:red;">\*</mark>      | String | The HMAC generated for the request.                                         |
| X-Timestamp<mark style="color:red;">\*</mark> | String | The timestamp of the request.                                               |

#### Request Body

| Name                                                | Type   | Description                 |
| --------------------------------------------------- | ------ | --------------------------- |
| loan\_request\_id<mark style="color:red;">\*</mark> | Int    | Loan Request ID             |
| provider\_name<mark style="color:red;">\*</mark>    | String | The requested provider name |

{% tabs %}
{% tab title="200: Third Party Score was found" %}
See the [Available Service Options](#available-service-options) section for a sample response for each provider.
{% endtab %}

{% tab title="403: Authentication Failure" %}

```javascript
{
    "detail": "Authentication credentials were not provided."
}
```

{% endtab %}

{% tab title="404: Third Party Score not found" %}

```json
{"message": "Service provider score not found for the given loan request ID"}
```

{% endtab %}

{% tab title="404: Loan request not found" %}

```json
{"message": "No active loan request found for the given ID."}
```

{% endtab %}

{% tab title="400: Invalid provider name" %}

```json
{"message": "Please enter a valid provider name"}
```

{% endtab %}
{% endtabs %}

#### Sample Request

{% tabs %}
{% tab title="cURL" %}

```sh
curl -X POST "https://api.lenmo.app/api/v3/data_marketplace/data_integration/" \
    -H "accept: application/json" \
    -H "X-API-KEY: YOUR_API_KEY" \
    -H "X-Timestamp: REQUEST_TIMESTAMP" \
    -H "X-HMAC: REQUEST_HMAC" \
    -H "Content-Type: application/json" \
    -d '{"loan_request_id": 1, "provider_name": "salus"}'
```

{% endtab %}

{% tab title="Python" %}
{% code overflow="wrap" %}

```python
import requests
import json

api_key = 'YOUR_API_KEY'
api_secret = 'YOUR_API_SECRET'

url = 'https://api.lenmo.app/api/v3/data_marketplace/data_integration/'

headers = {
    'Accept': 'application/json',
    "Content-Type": "application/json",
    'X-API-KEY': api_key,
    'X-Timestamp': 'YOUR_TIME_STAMP',
    'X-HMAC': 'YOUR_HMAC_KEY'
}

loan_request_id = 1
provider_name = "salus"
data = {
    "loan_request_id": loan_request_id,
    "provider_name": provider_name
}

r = requests.post(url, headers=headers, json=data)

print(r.text)
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}

```java
import java.io.OutputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class Main {
    public static void main(String[] args) {
        try {
            String apiKey = "YOUR_API_KEY";
            String apiSecret = "YOUR_API_SECRET";
            String urlString = "https://api.lenmo.app/api/v3/data_marketplace/data_integration/";
            URL url = new URL(urlString);
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("POST");
            connection.setRequestProperty("Accept", "application/json");
            connection.setRequestProperty("Content-Type", "application/json");
            connection.setRequestProperty("X-API-KEY", apiKey);
            connection.setRequestProperty("X-Timestamp", "YOUR_TIME_STAMP");
            connection.setRequestProperty("X-HMAC", "YOUR_HMAC_KEY");
            connection.setDoOutput(true);

            int loanRequestId = 1;
            String providerName = "salus";
            String jsonInputString = String.format("{\"loan_request_id\": %d, \"provider_name\": \"%s\"}", loanRequestId, providerName);

            try (OutputStream os = connection.getOutputStream()) {
                byte[] input = jsonInputString.getBytes("utf-8");
                os.write(input, 0, input.length);
            }

            BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf-8"));
            String inputLine;
            StringBuilder response = new StringBuilder();
            while ((inputLine = in.readLine()) != null) {
                response.append(inputLine);
            }
            in.close();

            System.out.println(response.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'net/http'
require 'json'
require 'openssl'
require 'time'

api_key = 'YOUR_API_KEY'
api_secret = 'YOUR_API_SECRET'
url = URI('https://api.lenmo.app/api/v3/data_marketplace/data_integration/')

timestamp = Time.now.to_i.to_s
message = timestamp + url.to_s
signature = OpenSSL::HMAC.hexdigest('sha256', api_secret, message)

headers = {
  'Accept' => 'application/json',
  'Content-Type' => 'application/json',
  'X-API-KEY' => api_key,
  'X-Timestamp' => timestamp,
  'X-HMAC' => signature
}

data = {
  loan_request_id: 1,
  provider_name: "salus"
}.to_json

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url, headers)
request.body = data

response = http.request(request)
puts response.read_body

```

{% endtab %}

{% tab title="Node.Js" %}

```javascript
const fetch = require('node-fetch');

const apiKey = 'YOUR_API_KEY';
const apiSecret = 'YOUR_API_SECRET';
const url = 'https://api.lenmo.app/api/v3/data_marketplace/data_integration/';

const headers = {
    "Accept": "application/json",
    "Content-Type": "application/json",
    "X-API-KEY": apiKey,
    "X-Timestamp": "YOUR_TIME_STAMP",
    "X-HMAC": "YOUR_HMAC_KEY",
};

const data = {
    loan_request_id: 1,
    provider_name: "salus"
};

fetch(url, {
    method: 'POST',
    headers: headers,
    body: JSON.stringify(data)
})
.then(response => response.text())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$apiKey = 'YOUR_API_KEY';
$apiSecret = 'YOUR_API_SECRET';
$url = "https://api.lenmo.app/api/v3/data_marketplace/data_integration/";

$headers = [
    "Accept: application/json",
    "Content-Type: application/json",
    "X-API-KEY: $apiKey",
    "X-Timestamp: YOUR_TIME_STAMP",
    "X-HMAC: YOUR_HMAC_KEY"
];

$body = json_encode([
    "loan_request_id" => 1,
    "provider_name" => "salus"
]);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);

$response = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
} else {
    echo $response;
}

curl_close($ch);
?>

```

{% endtab %}
{% endtabs %}

#### Available Service Options

<table><thead><tr><th width="159">Provider Name</th><th width="110">Price</th><th width="117">Description</th><th>Sample Response</th></tr></thead><tbody><tr><td>salus</td><td>Unlimited access for $200 per month.</td><td><a href="#salus-score-description">Salus Score Description*</a></td><td><pre class="language-json"><code class="lang-json">{
  "loan_request_id": 123456,
  "model_version": "648bc628aeae01aeab885d35",
  "salus_score": 12,
  "salus_score_request_id": "d290f1ee-6c54-4b01-90e6-d701748f0851",
  "timestamp": "2022-08-29T09:12:33.001Z"
}
</code></pre></td></tr><tr><td>pave</td><td>$1.50 per API request, billed monthly.</td><td><a href="#pave-score-description">Pave Score Description*</a></td><td><p></p><pre class="language-json" data-full-width="true"><code class="lang-json">{
  "p2p_score": {
    "date": "2024-08-16",
    "score": 21,
    "score_band": "poor",
    "loan_request_id": "781991",
  },
  "attributes": {
    "date": "2024-08-16",
    "loan_request_id": "781991",
    "attributes": {
      // Calculated banking attributes here.
    }
  }
}
</code></pre></td></tr></tbody></table>

#### Salus Score Description \*

Salus Score uses credit data and transaction data to highlight the historically observed default rate of a given loan application based on similar historical applications, going beyond traditional measures like credit score. Users of the Salus Score acknowledge that the Salus Score is for informational purposes only and should not be solely relied on to make credit decisions; it is not guaranteed to generate default rates consistent with historical patterns used to generate the score. Salus Score is provided by Lenme’s data partner, Salus Financial Technology, Inc. Salus Financial Technology, Inc. is not a credit reporting agency. Information like age, sex, race, or marital status are not used in the creation of the Salus Score. Users of the Salus Score allow Lenme to share loan data with Salus Financial Technology, Inc.

***

#### Pave Score Description\*

The Pave Score identifies healthy borrowers, optimizes credit limits, and enhances collection outcomes. It is composed of two key components:

1. **P2P Score**: This score represents the user’s ability to repay the loan. The P2P Score is categorized as follows:
   * **Excellent**: 75 to 100
   * **Good**: 50 to 75
   * **Average**: 25 to 50
   * **Poor**: 0 to 25
2. **Bank Attributes**: This component includes over 4,000 attributes related to the user’s cash flow and financial profile. These attributes cover areas such as debt payment history, past and expected income, bank fees, cash advance defaults, account balances, and more.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.lenme.com/reference/fetch-third-party-service.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
