# Get Borrower Loan History

## HTTPS Request

<mark style="color:blue;">`GET`</mark> `https://api.lenmo.app/api/v3/loan_requests/{loan_request_id}/borrower_loan_history/`

This endpoint takes an active loan request ID and returns the associated borrower's loan history.

#### Path Parameters

| Name              | Type    | Description         |
| ----------------- | ------- | ------------------- |
| loan\_request\_id | Integer | The loan request ID |

#### Headers

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

#### Sample Request

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

```clike
curl -X GET "https://api.lenmo.app/api/v3/loan_requests/50/borrower_loan_history/" \
    -H "accept: application/json" \
    -H "X-API-KEY: YOUR_API_KEY" \
    -H "X-Timestamp: REQUEST_TIMESTAMP" \
    -H "X-HMAC: REQUEST_HMAC"

```

{% endtab %}

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

```python
import requests

loan_request_id = 50
url = f'https://api.lenmo.app/api/v3/loan_requests/{loan_request_id}/borrower_loan_history/'

headers = {
    "Accept": "application/json",
    "X-API-KEY": "YOUR_API_KEY",
    "X-Timestamp": "REUQUEST_TIMESTAMP",
    "X-HMAC": "REQUEST_HMAC",
}

r = requests.get(url, headers=headers)

print(r.json())
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}

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

public class Main {
    public static void main(String[] args) {
        try {
            int loanRequestId = 50;
            String urlString = "https://api.lenmo.app/api/v3/loan_requests/" + loanRequestId + "/borrower_loan_history/";
            URL url = new URL(urlString);
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("GET");
            connection.setRequestProperty("Accept", "application/json");
            connection.setRequestProperty("X-API-KEY", "YOUR_API_KEY");
            connection.setRequestProperty("X-Timestamp", "REQUEST_TIMESTAMP");
            connection.setRequestProperty("X-HMAC", "REQUEST_HMAC");

            BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            String inputLine;
            StringBuffer response = new StringBuffer();
            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 'uri'

loan_request_id = 50
url = URI("https://api.lenmo.app/api/v3/loan_requests/#{loan_request_id}/borrower_loan_history/")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Accept"] = "application/json"
request["X-API-KEY"] = "YOUR_API_KEY"
request["X-Timestamp"] = "REQUEST_TIMESTAMP"
request["X-HMAC"] = "REQUEST_HMAC"

response = http.request(request)
puts JSON.parse(response.body)

```

{% endtab %}

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

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

const loanRequestId = 50;
const url = `https://api.lenmo.app/api/v3/loan_requests/${loanRequestId}/borrower_loan_history/`;

const headers = {
    "Accept": "application/json",
    "X-API-KEY": "YOUR_API_KEY",
    "X-Timestamp": "REQUEST_TIMESTAMP",
    "X-HMAC": "REQUEST_HMAC",
};

fetch(url, {
    method: 'GET',
    headers: headers
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$loanRequestId = 50;
$url = "https://api.lenmo.app/api/v3/loan_requests/$loanRequestId/borrower_loan_history/";

$headers = [
    "Accept: application/json",
    "X-API-KEY: YOUR_API_KEY",
    "X-Timestamp: REQUEST_TIMESTAMP",
    "X-HMAC: REQUEST_HMAC"
];

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

$response = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
} else {
    $json = json_decode($response, true);
    print_r($json);
}

curl_close($ch);
?>

```

{% endtab %}
{% endtabs %}

## Sample Response

{% tabs %}
{% tab title="200: OK Returns a paginated list of the borrower's completed loans" %}

```json
{
  "count": 3,
  "next": null,
  "previous": null,
  "results": [
    {
      "lender": {
        "initial": "TT",
        "avatar": 3
      },
      "borrower": {
        "initial": "AE",
        "avatar": 1
      },
      "borrower_card_color": 2,
      "loan_amount": "508.11",
      "payment_terms": 3,
      "interest_rate": "1.85"
    },
    {
      "lender": {
        "initial": "JC",
        "avatar": 3
      },
      "borrower": {
        "initial": "FT",
        "avatar": 1
      },
      "borrower_card_color": 1,
      "loan_amount": "203.11",
      "payment_terms": 1,
      "interest_rate": "1.65"
    },
    {
      "lender": {
        "initial": "JC",
        "avatar": 3
      },
      "borrower": {
        "initial": "FT",
        "avatar": 1
      },
      "borrower_card_color": 1,
      "loan_amount": "53.11",
      "payment_terms": 1,
      "interest_rate": "1.34"
    }
  ]
}
```

{% endtab %}

{% tab title="403: Forbidden Permission denied" %}

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

{% endtab %}
{% endtabs %}

## Response Parameters

<table data-full-width="false"><thead><tr><th width="247">Parameter</th><th width="116">Type</th><th width="351">Description</th></tr></thead><tbody><tr><td>count</td><td>Number</td><td>Number of objects in page.</td></tr><tr><td>next</td><td>String</td><td>Next page URL.</td></tr><tr><td>previous</td><td>String</td><td>Previous page URL.</td></tr><tr><td>results</td><td>JSON</td><td>The borrower loan history data.</td></tr><tr><td>lender</td><td>JSON</td><td>Contains the lender initail and avatar.</td></tr><tr><td>borrower</td><td>JSON</td><td>Contains the borrower initail and avatar.</td></tr><tr><td>borrower_card_color</td><td>Integer</td><td>An integer value that reflect the risk level of the borrower.</td></tr><tr><td>loan_amount</td><td>Float</td><td>The amount of loan in USD</td></tr><tr><td>payment_termns</td><td>Number</td><td>The loan payment terms.</td></tr><tr><td>interest_rate</td><td>Float</td><td>The loan interest rate.</td></tr></tbody></table>
