About the Developer
Hi! I'm a technical solutions professional with over 16 years of software engineering experience, specializing in developer platforms, APIs & SDKs, and cloud services. I love building relationships with partners and understanding their business needs in a sales engineering capacity. In advocacy of the developer, I partner with internal product engineering teams to drive new features and to release incredible new products to market. My ultimate goal is to bring delight to the end users, all while building an ever more efficient, secure, and profitable API product platform.
As a cryptocurrency investor and enthusiast since 2017, I'm passionate about Web3 and the future of democratized digital finance. I dream of a day when the unbanked worldwide have safe and easy access to digital currency — hence, this project. In my spare time, I enjoy running blockchain nodes and contributing to various projects, such as Trace Labs' recent Trusted COVID-19 Essential Supplies Repository.
About the Project
This API platform proof-of-concept (PoC) enables banking integration partners to offer their end-users the ability to obtain a USD loan against their Bitcoin position. Complete API documentation for the Service Platform is included, along with a dedicated integration guide that presents a mobile app reference implementation. All content is my own, authored in calendar Q2 of 2022.
High-Level Architecture
Partner Integration Guide
API Design
The API Design document, complete with market analysis and product research is available for download.
REST API DOCUMENTATION
Overview
We're pleased to offer a brand new Lending API to make it possible for our partners to develop solutions that enable their end-users to obtain a USD loan against their Bitcoin position. This section contains the API endpoints and the request and response schemas for all methods required to integrate to the platform.
Postman Collection
The quickest way to get started is to use our Postman request collection. The following steps will help you get up and running. If you prefer, our API can also easily be explored with other tools, like cURL.
1) Open the Postman Collection
2) Configure the Postman Environment
- Setup a new environment by clicking the Gear icon at top right
- Name the new environment Bitcoin Lending and click Add to create
- Expand the GET STARTED folder and select the Environment Setup method
- Select the Pre-req. tab and set
bearer-token
to the Access Token Value previously obtained - Click the Send button
3) Explore the API
- Execute any of the requests within the collection
- Refer to this documentation for the requirements of each method
Authorization
We use OAuth2 for authorization to our API. OAuth2 is a protocol designed to let third-party applications perform actions on behalf of an end user. There are several libraries available that implement the protocol, and a good list can be found at the OAuth2 home page. Through the use of OAuth2, you'll go through the process of obtaining a token and then you'll use that token in every request made to the API to verify your identity.
Obtaining a Token
Before you can make any request of the API, you must first make an authorization request. Once authorized, you will be given an access token that may be used for all subsequent requests. This will require an OAuth client ID and an OAuth client secret. Contact your partner success manager to obtain these application credentials. The OAuth client secret should never be shared.
Base URL
All URLs referenced in the documentation have the following base:
https://api.example.com/v1/lending
Throttling
Calls are limited to a maximum of 300 within any 5 minute time window (subject to change). Rate is calculated on a per-connection basis (per access token). If you exceed the current rate limit, you will receive a 429 'Too many requests'
response from our API. You will continue to receive a 429 response until you're out of the violation time window.
Lending Programs
These endpoints return lists of the lending programs offered to our partners. Use it to retrieve
the basic loan structure of each program, including the target customer type, collateral currencies & various fees. With this information you can introduce high-level discovery content within your product to entice customers to learn more.
Before offering any loan programs to your customers you will need to call our Get Eligibilities for an account endpoint to determine eligility, as well as the specific conditions of the loan as they apply to the specific customer. Since not all customers will qualify, you should use this endpoint in generic fashion, for example to drive content for a banner on your website homepage, e.g.: "NEW! We've further partnered with our provider to provide a brand new loan program, backed by Bitcoin. You may qualify - contact us today to learn more."
Get All Programs
Request
curl "https://api.example.com/v1/lending/programs" \
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.example.com/v1/lending/programs")
.get()
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://api.example.com/v1/lending/programs");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.example.com/v1/lending/programs",
"method": "GET",
"headers": {
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require("request");
var options = { method: 'GET',
url: 'https://api.example.com/v1/programs',
headers:
{
} };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
<?php
$request = new HttpRequest();
$request->setUrl('https://api.example.com/v1/programs');
$request->setMethod(HTTP_METH_GET);
$request->setHeaders(array(
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/lending/programs")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body
import requests
url = "https://api.example.com/v1/programs"
payload = ""
headers = {
}
response = requests.request("GET", url, data=payload, headers=headers)
print(response.text)
use REST::Client;
my $client = REST::Client->new();
$url="https://api.example.com/v1/lending/programs";
$client->GET($url);
print $client->responseContent();
print $client->responseHeader('ResponseHeader');
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.example.com/v1/lending/programs"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
import Foundation
let headers = [
]
let request = NSMutableURLRequest(
url: NSURL(string: "https://api.example.com/v1/lending/programs")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(
with: request as URLRequest, completionHandler: {
(data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
}
)
dataTask.resume()
Response
[
{
"id": 1,
"name": "BTC Secured Personal Loan",
"description": "Now you can borrow cash against your BTC!",
"type": "PERSONAL",
"collateralSymbol": "BTC",
"originationFee": 0,
"annualFee": 0,
"prepaymentPenalty": false,
"status": "LIVE",
"created": "2022-03-01T12:05:37"
},
{
"id": 2,
"name": "BTC Secured Business Loan",
"description": "Use your BTC to help your business grow!",
"type": "BUSINESS",
"collateralSymbol": "BTC",
"originationFee": 0,
"annualFee": 100,
"prepaymentPenalty": false,
"status": "PREVIEW",
"created": "2022-03-01T12:07:45"
}
]
Returns all lending programs, including those that are well established, upcoming, and no longer available.
HTTP Request
https://api.example.com/v1/lending/programs
Response Properties
This API method returns a list of program objects
Property | Description |
---|---|
id | Unique identifier of the program |
name | Friendly descriptive identifier of the program |
description | Short informative summary to provide context |
type | Either ‘PERSONAL’ or ‘BUSINESS’. Additional types may be added |
collateralSymbol | The short name (symbol) of the cryptocurrency |
originationFee | The startup cost passed on to the partners’ end customer |
annualFee | The fee passed on to the partners’ end customer, charged yearly |
status | The use readiness state, one of ‘LIVE’, ‘PREVIEW, or ‘CLOSED’ |
created | The UTC timestamp of the creation of the loan |
Response Codes
HTTP Code | Status |
---|---|
200 |
OK |
Get a Specific Program
Request
curl "https://api.example.com/v1/lending/programs/1" \
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.example.com/v1/lending/programs/1")
.get()
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://api.example.com/v1/lending/programs/1");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.example.com/v1/lending/programs/1",
"method": "GET",
"headers": {
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require("request");
var options = { method: 'GET',
url: 'https://api.example.com/v1/programs/1',
headers:
{
} };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
<?php
$request = new HttpRequest();
$request->setUrl('https://api.example.com/v1/programs/1');
$request->setMethod(HTTP_METH_GET);
$request->setHeaders(array(
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/lending/programs/1")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body
import requests
url = "https://api.example.com/v1/programs/1"
payload = ""
headers = {
}
response = requests.request("GET", url, data=payload, headers=headers)
print(response.text)
use REST::Client;
my $client = REST::Client->new();
$url="https://api.example.com/v1/lending/programs/1";
$client->GET($url);
print $client->responseContent();
print $client->responseHeader('ResponseHeader');
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.example.com/v1/lending/programs/1"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
import Foundation
let headers = [
]
let request = NSMutableURLRequest(
url: NSURL(string: "https://api.example.com/v1/lending/programs/1")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(
with: request as URLRequest, completionHandler: {
(data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
}
)
dataTask.resume()
Response
{
"id": 1,
"name": "BTC Secured Personal Loan",
"description": "Now you can borrow cash against your BTC!",
"type": "PERSONAL",
"collateralSymbol": "BTC",
"originationFee": 0,
"annualFee": 0,
"prepaymentPenalty": false,
"status": "LIVE",
"created": "2022-03-01T12:05:37"
}
Return a single lending program, given its unique id.
HTTP Request
https://api.example.com/v1/lending/programs/<ID>
URL Parameters
Parameter | Description |
---|---|
ID | The ID of the program to retrieve |
Response Properties
Property | Description |
---|---|
id | Unique identifier of the program |
name | Friendly descriptive identifier of the program |
description | Short informative summary to provide context |
type | Either ‘PERSONAL’ or ‘BUSINESS’. Additional types may be added |
collateralSymbol | The short name (symbol) of the cryptocurrency |
originationFee | The startup cost passed on to the partners’ end customer |
annualFee | The fee passed on to the partners’ end customer, charged yearly |
status | The use readiness state, one of ‘LIVE’, ‘PREVIEW, or ‘CLOSED’ |
created | The UTC timestamp of the creation of the loan |
Response Codes
HTTP Code | Status |
---|---|
200 |
OK |
404 |
Not Found |
Customer Eligibilities
We will provide a determination on the eligibility for each of your customers, as well as the conditions of the loan that must be met, including lending limits, and the maximum APR you can charge. Consider the following example:
Here are three customer accounts and the eligibility determinations and conditions for each. For demonstration only - actual business rules will vary. For this example, state of residence determines overall eligibility, whereas BTC balance (and other unlisted factors) determines whether each will qualify for a business loan (offered at more attractive interest rates, higher amounts, and longer terms).
Customer Account | 1 | 2 | 3 |
---|---|---|---|
State of Residence | South Carolina | Arizona | Nebraska |
BTC Balance | 0.037511243 | 1.43778521 | 0.20039265 |
Eligible? | No | Personal & Business | Personal Only |
Min Offer USD | - | $100 / $5,000 | $100 / - |
Max Offer USD | - | $10,000 / $250,000 | $7,500 / - |
Max APR | - | 12% / 8.5% | 15% / - |
Max Initial LTV | - | 50% / 45% | 40% |
Partner Fee | - | 4% / 3% | 4% |
Term in Months | - | 12 / 36 | 12 |
Get Eligibilities for an Account
Request
curl "https://api.example.com/v1/lending/eligibilities?accountId=1" \
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.example.com/v1/lending/eligibilities?accountId=1")
.get()
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://api.example.com/v1/lending/eligibilities?accountId=1");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.example.com/v1/lending/eligibilities?accountId=1",
"method": "GET",
"headers": {
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require("request");
var options = { method: 'GET',
url: 'https://api.example.com/v1/eligibilities',
qs: {
accountId: '1',
},
headers:
{
} };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
<?php
$request = new HttpRequest();
$request->setUrl('https://api.example.com/v1/eligibilities');
$request->setMethod(HTTP_METH_GET);
$request->setQueryData(array(
'accountId' => '1',
));
$request->setHeaders(array(
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/lending/eligibilities?accountId=1")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body
import requests
url = "https://api.example.com/v1/eligibilities"
querystring = {
"accountId":"1",
}
payload = ""
headers = {
}
response = requests.request("GET", url, data=payload, headers=headers, params=querystring)
print(response.text)
use REST::Client;
my $client = REST::Client->new();
$url="https://api.example.com/v1/lending/eligibilities?accountId=1";
$client->GET($url);
print $client->responseContent();
print $client->responseHeader('ResponseHeader');
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.example.com/v1/lending/eligibilities?accountId=1"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
import Foundation
let headers = [
]
let request = NSMutableURLRequest(
url: NSURL(string: "https://api.example.com/v1/lending/eligibilities?accountId=1")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(
with: request as URLRequest, completionHandler: {
(data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
}
)
dataTask.resume()
Response
[
{
"id": 1,
"accountId": 1,
"programId": 1,
"status": "ELIGIBLE",
"collateralSymbol": "BTC",
"minOfferUSD": 100,
"maxOfferUSD": 10000,
"maxAPR": 15,
"maxInitialLTV": 40,
"partnerFee": 2,
"termInMonths": 12,
"created": "2022-04-02T19:03:32",
"expires": "2022-04-03T19:03:32"
},
{
"id": 2,
"accountId": 1,
"programId": 2,
"status": "INELIGIBLE",
"collateralSymbol": "BTC",
"minOfferUSD": 0,
"maxOfferUSD": 0,
"maxAPR": 0,
"maxInitialLTV": 0,
"partnerFee": 0,
"termInMonths": 0,
"created": "2022-04-02T19:03:32",
"expires": "2022-04-03T19:03:32"
}
]
Gets lending program eligibility determinations and conditions for a given customer account.
HTTP Request
https://api.example.com/v1/lending/eligibilities?accountId=<value>
Query Parameters
Parameter | Use | Description |
---|---|---|
accountId | required | The id of the customer account for which to retrieve lending program eligibility |
Response Properties
This API method returns a list of eligibility objects
Property | Description |
---|---|
id | Unique identifier of the eligibility determination |
accountId | Unique id of the customer’s account associated with the eligibilities |
programId | Unique id of the lending program to which the eligibility applies |
status | The determination, one of ‘ELIGIBLE’, ‘INELIGIBLE’, or ‘CONTESTED’ |
collateralSymbol | The short name (symbol) of the cryptocurrency to be used as collateral |
minOfferUSD | The smallest possible loan allowed, denominated in US dollars |
maxOfferUSD | The largest possible loan allowed, denominated in US dollars |
maxAPR | The maximum APR the partner is allowed to charge the customer |
maxInitialLTV | The Loan-to-value at origination. Value of collateral must be greater than or equal to the borrowed amount divided by this number (expressed as a percentage) |
partnerFee | The US dollar amount, expressed as a percentage of the borrowed amount, Which must be paid to within 24 hours of loan origination |
created | The UTC timestamp of the creation of the loan |
expires | The UTC timestamp at which the eligibility determination is no longer valid |
Response Codes
HTTP Code | Status |
---|---|
200 |
OK |
404 |
Not Found |
Loan Quotes
We will make the sole determination of whether each partner’s customer is eligible to participate in our lending programs (as well as the specific conditions), based on regulatory and legal guidance. Before a loan quote can be provided, a valid eligibility determination must be made.
Create a Loan Quote
Request
curl -X POST \
https://api.example.com/v1/lending/quotes \
-H 'Content-Type: application/json' \
-d '<REQUEST BODY>'
var client = new RestClient("https://api.example.com/v1/lending/quotes");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "<REQUEST BODY>", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Dim client = New RestClient("https://api.example.com/v1/lending/quotes")
Dim request = New RestRequest(Method.POST)
request.AddHeader("Content-Type", "application/json")
request.AddParameter("application/json", "<REQUEST BODY>", ParameterType.RequestBody);
Dim response As IRestResponse = client.Execute(request)
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "<REQUEST BODY>");
Request request = new Request.Builder()
.url("https://api.example.com/v1/lending/quotes")
.post(body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.example.com/v1/lending/eligibilities?accountId=1",
"method": "POST",
"headers": {
"Content-Type", "application/json",
},
"processData": false,
"data": "<REQUEST BODY>"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require("request");
var options = { method: 'POST',
url: 'https://api.example.com/v1/lending/quotes',
headers:
{
'Content-Type': 'application/json',
},
body: '<REQUEST BODY>',
json: true };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
<?php
$request = new HttpRequest();
$request->setUrl('https://api.example.com/v1/lending/quotes');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'Content-Type' => 'application/json',
));
$request->setBody('<REQUEST BODY>');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/lending/quotes")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json',
request.body = "<REQUEST BODY>"
response = http.request(request)
puts response.read_body
import requests
url = "https://api.example.com/v1/lending/quotes"
payload = "<REQUEST BODY>"
headers = {
'Content-Type': 'application/json',
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.example.com/v1/lending/quotes"
payload := strings.NewReader("<REQUEST BODY>")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
import Foundation
let headers = [
"Content-Type": "application/json",
]
let parameters = <REQUEST BODY> as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(
url: NSURL(string: "https://api.example.com/v1/lending/quotes")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(
with: request as URLRequest,
completionHandler: {
(data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
}
)
dataTask.resume()
use REST::Client;
my $client = REST::Client->new();
$client->addHeader('Content-Type', 'application/json');
$req = '<REQUEST BODY>';
$url="https://api.example.com/v1/lending/quotes";
$client->POST($url, $req);
print $client->responseContent();
print $client->responseHeader('ResponseHeader');
Request Body
{
"accountId": 1,
"eligibilityId": 1,
"borrowUSD": 800
}
Response
{
"id": 1,
"accountId": 1,
"eligibilityId": 1,
"borrowUSD": 800,
"minCollateral": 0.04313599,
"collateralBalance": 0.075,
"collateralSymbol": "BTC",
"created": "2022-04-03T13:57:45",
"expires": "2022-04-03T13:58:45"
}
Returns a quote for a loan, given the amount requested, and the market price of the cryptocurrency. This operation will use the properties of the referenced eligibility determination to verify the requested loan amount is within limits, and to calculate the required collateral amount.
For example:
Requested loan amount is $800
, offered by the partner at 8.5%
interest:
Eligibility Property | Value | Within Limits? |
---|---|---|
Min Offer USD | 100 | Yes |
Max Offer USD | 1000 | Yes |
Max APR | 15% | Yes |
MaxInitialLTV | 40% | - |
Required collateral: (Loan Amount / MaxInitialLTV) / BTC Market Price
(800 / 0.4) / 46195 = 0.04329473 BTC
HTTP Request
https://api.example.com/v1/lending/quotes
Request Properties
Property | Use | Description |
---|---|---|
accountId | required | Id of the customer account for which to create a loan quote. |
eligibilityId | required | Id of the lending program eligibility determination. |
borrowUSD | required | The cash amount requested, in USD. |
Response Properties
Property | Description |
---|---|
id | Unique identifier of the loan quote |
accountId | Unique id of the customer’s account associated with the loan quote |
eligibilityId | Unique id of the eligibility determination used to generate the quote |
borrowUSD | The requested loan amount, in US dollars |
minCollateral | The minimum amount of cryptocurrency than must be locked as collateral to secure the loan. (Note: this value is derived from the eligibility determination’s MaxInitialLTV property, as well as the price of the currency at time of quote request). |
collateralBalance | The amount of cryptocurrency currently held in the account’s wallet. |
created | The UTC timestamp of the creation of the loan quote |
expires | The UTC timestamp at which the loan quote is no longer valid |
Response Codes
HTTP Code | Status |
---|---|
201 |
OK. Loan quote created successfully. |
400 |
Bad Request. |
409 |
Conflict. |
422 |
Unprocessable Entity. |
Get a Specific Loan Quote
Request
curl "https://api.example.com/v1/lending/quotes/1" \
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.example.com/v1/lending/quotes/1")
.get()
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://api.example.com/v1/lending/quotes/1");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.example.com/v1/lending/quotes/1",
"method": "GET",
"headers": {
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require("request");
var options = { method: 'GET',
url: 'https://api.example.com/v1/quotes/1',
headers:
{
} };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
<?php
$request = new HttpRequest();
$request->setUrl('https://api.example.com/v1/quotes/1');
$request->setMethod(HTTP_METH_GET);
$request->setHeaders(array(
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/lending/quotes/1")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body
import requests
url = "https://api.example.com/v1/quotes/1"
payload = ""
headers = {
}
response = requests.request("GET", url, data=payload, headers=headers)
print(response.text)
use REST::Client;
my $client = REST::Client->new();
$url="https://api.example.com/v1/lending/quotes/1";
$client->GET($url);
print $client->responseContent();
print $client->responseHeader('ResponseHeader');
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.example.com/v1/lending/quotes/1"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
import Foundation
let headers = [
]
let request = NSMutableURLRequest(
url: NSURL(string: "https://api.example.com/v1/lending/quotes/1")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(
with: request as URLRequest, completionHandler: {
(data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
}
)
dataTask.resume()
Response
{
"id": 1,
"accountId": 1,
"eligibilityId": 1,
"borrowUSD": 800,
"minCollateral": 0.04342634,
"collateralBalance": 0.075,
"collateralSymbol": "BTC",
"created": "2022-04-02T19:07:06",
"expires": "2022-04-02T19:08:06"
}
Returns a previously generated loan quote, given its unique id.
HTTP Request
https://api.example.com/v1/lending/quotes/<ID>
URL Parameters
Parameter | Description |
---|---|
ID | The id of the loan quote to retrieve |
Response Properties
Property | Description |
---|---|
id | Unique identifier of the loan quote |
accountId | Unique id of the customer’s account associated with the loan quote |
eligibilityId | Unique id of the eligibility determination used to generate the quote |
borrowUSD | The requested loan amount, in US dollars |
minCollateral | The minimum amount of cryptocurrency than must be locked as collateral to secure the loan. (Note: this value is derived from the eligibility determination’s MaxInitialLTV property, as well as the price of the currency at time of quote request). |
collateralBalance | The amount of cryptocurrency currently held in the account’s wallet. |
created | The UTC timestamp of the creation of the loan quote |
expires | The UTC timestamp at which the loan quote is no longer valid |
Response Codes
HTTP Code | Status |
---|---|
200 |
OK |
404 |
Not Found |
Get Loan Quotes for an Account
Request
curl "https://api.example.com/v1/lending/quotes?accountId=1" \
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.example.com/v1/lending/quotes?accountId=1")
.get()
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://api.example.com/v1/lending/quotes?accountId=1");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.example.com/v1/lending/quotes?accountId=1",
"method": "GET",
"headers": {
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require("request");
var options = { method: 'GET',
url: 'https://api.example.com/v1/quotes',
qs: {
accountId: '1',
},
headers:
{
} };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
<?php
$request = new HttpRequest();
$request->setUrl('https://api.example.com/v1/quotes');
$request->setMethod(HTTP_METH_GET);
$request->setQueryData(array(
'accountId' => '1',
));
$request->setHeaders(array(
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/lending/quotes?accountId=1")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body
import requests
url = "https://api.example.com/v1/quotes"
querystring = {
"accountId":"1",
}
payload = ""
headers = {
}
response = requests.request("GET", url, data=payload, headers=headers, params=querystring)
print(response.text)
use REST::Client;
my $client = REST::Client->new();
$url="https://api.example.com/v1/lending/quotes?accountId=1";
$client->GET($url);
print $client->responseContent();
print $client->responseHeader('ResponseHeader');
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.example.com/v1/lending/quotes?accountId=1"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
import Foundation
let headers = [
]
let request = NSMutableURLRequest(
url: NSURL(string: "https://api.example.com/v1/lending/quotes?accountId=1")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(
with: request as URLRequest, completionHandler: {
(data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
}
)
dataTask.resume()
Response
[
{
"id": 1,
"accountId": 1,
"eligibilityId": 1,
"borrowUSD": 800,
"minCollateral": 0.04342634,
"collateralBalance": 0.075,
"collateralSymbol": "BTC",
"created": "2022-04-02T19:07:06",
"expires": "2022-04-02T19:08:06"
}
]
Retrieves all loan quotes for a given customer account.
HTTP Request
https://api.example.com/v1/lending/quotes?accountId=<value>
Query Parameters
Parameter | Use | Description |
---|---|---|
accountId | required | The id of the customer account for which to retrieve loan quotes |
Response Properties
This API method returns a list of loan quote objects
Property | Description |
---|---|
id | Unique identifier of the loan quote |
accountId | Unique id of the customer’s account associated with the loan quote |
eligibilityId | Unique id of the eligibility determination used to generate the quote |
borrowUSD | The requested loan amount, in US dollars |
minCollateral | The minimum amount of cryptocurrency than must be locked as collateral to secure the loan. (Note: this value is derived from the eligibility determination’s MaxInitialLTV property, as well as the price of the currency at time of quote request). |
collateralBalance | The amount of cryptocurrency currently held in the account’s wallet. |
created | The UTC timestamp of the creation of the loan quote |
expires | The UTC timestamp at which the loan quote is no longer valid |
Response Codes
HTTP Code | Status |
---|---|
200 |
OK |
404 |
Not Found |
Loans
Create Loan
Request
curl -X POST \
https://api.example.com/v1/lending/loans \
-H 'Content-Type: application/json' \
-d '<REQUEST BODY>'
var client = new RestClient("https://api.example.com/v1/lending/loans");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "<REQUEST BODY>", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Dim client = New RestClient("https://api.example.com/v1/lending/loans")
Dim request = New RestRequest(Method.POST)
request.AddHeader("Content-Type", "application/json")
request.AddParameter("application/json", "<REQUEST BODY>", ParameterType.RequestBody);
Dim response As IRestResponse = client.Execute(request)
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "<REQUEST BODY>");
Request request = new Request.Builder()
.url("https://api.example.com/v1/lending/loans")
.post(body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.example.com/v1/lending/quotes?accountId=1",
"method": "POST",
"headers": {
"Content-Type", "application/json",
},
"processData": false,
"data": "<REQUEST BODY>"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require("request");
var options = { method: 'POST',
url: 'https://api.example.com/v1/lending/loans',
headers:
{
'Content-Type': 'application/json',
},
body: '<REQUEST BODY>',
json: true };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
<?php
$request = new HttpRequest();
$request->setUrl('https://api.example.com/v1/lending/loans');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'Content-Type' => 'application/json',
));
$request->setBody('<REQUEST BODY>');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/lending/loans")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json',
request.body = "<REQUEST BODY>"
response = http.request(request)
puts response.read_body
import requests
url = "https://api.example.com/v1/lending/loans"
payload = "<REQUEST BODY>"
headers = {
'Content-Type': 'application/json',
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.example.com/v1/lending/loans"
payload := strings.NewReader("<REQUEST BODY>")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
import Foundation
let headers = [
"Content-Type": "application/json",
]
let parameters = <REQUEST BODY> as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(
url: NSURL(string: "https://api.example.com/v1/lending/loans")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(
with: request as URLRequest,
completionHandler: {
(data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
}
)
dataTask.resume()
use REST::Client;
my $client = REST::Client->new();
$client->addHeader('Content-Type', 'application/json');
$req = '<REQUEST BODY>';
$url="https://api.example.com/v1/lending/loans";
$client->POST($url, $req);
print $client->responseContent();
print $client->responseHeader('ResponseHeader');
Request Body
{
"accountId": 1,
"quoteId": 1,
"borrowUSD": 800,
"collateralToHold": 0.04297471,
"collateral": "BTC",
"APR": 7.5
}
Response
{
"id": 1,
"accountId": 1,
"quoteId": 1,
"balanceUSD": 800,
"collateralHeld": 0.04297471,
"collateralSymbol": "BTC",
"apr": 7.5,
"currentLTV": 40,
"currentCollateralPrice": 46538.99,
"status": "OPEN",
"created": "2022-04-03T17:20:18"
}
Creates a loan from the referenced quote, for a given account.
HTTP Request
https://api.example.com/v1/lending/loans
Request Properties
Property | Use | Description |
---|---|---|
accountId | required | Id of the customer account for which to create the loan. |
quoteId | required | Id of the loan quote. |
borrowUSD | required | The cash amount to be borrowed, in USD. |
collateralToHold | required | The amount of collateral to be secured against the loan. |
collateralCurrency | required | The currency of the collateral. |
Response Properties
Property | Description |
---|---|
id | Unique identifier of the loan |
accountId | Unique id of the customer’s account associated with the loan |
quoteId | Unique id of the quote which determined the collateral amount for the loan |
balanceUSD | The outstanding (unpaid) balance of the loan |
collateralHeld | The amount of cryptocurrency being held in the collateral vault wallet |
collateralSymbol | The short name (symbol) of the cryptocurrency |
apr | The annual percentage rate charged by the partner to the customer |
currentLTV | The loan-to-value at time of origination of the loan |
currentCollateralPrice | The market price of the collateral currency at origination |
status | The state of the loan, one of ‘PENDING’, ‘OPEN’, ‘CLOSING’, ‘CLOSED’, or ‘FAILED’ |
created | The UTC timestamp at which the loan was created |
Response Codes
HTTP Code | Status |
---|---|
201 |
Created. |
400 |
Bad Request. |
403 |
Forbidden. |
409 |
Conflict. |
422 |
Unprocessable Entity. |
Get a Specific Loan
Request
curl "https://api.example.com/v1/lending/loans/1" \
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.example.com/v1/lending/loans/1")
.get()
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://api.example.com/v1/lending/loans/1");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.example.com/v1/lending/loans/1",
"method": "GET",
"headers": {
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require("request");
var options = { method: 'GET',
url: 'https://api.example.com/v1/loans/1',
headers:
{
} };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
<?php
$request = new HttpRequest();
$request->setUrl('https://api.example.com/v1/loans/1');
$request->setMethod(HTTP_METH_GET);
$request->setHeaders(array(
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/lending/loans/1")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body
import requests
url = "https://api.example.com/v1/loans/1"
payload = ""
headers = {
}
response = requests.request("GET", url, data=payload, headers=headers)
print(response.text)
use REST::Client;
my $client = REST::Client->new();
$url="https://api.example.com/v1/lending/loans/1";
$client->GET($url);
print $client->responseContent();
print $client->responseHeader('ResponseHeader');
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.example.com/v1/lending/loans/1"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
import Foundation
let headers = [
]
let request = NSMutableURLRequest(
url: NSURL(string: "https://api.example.com/v1/lending/loans/1")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(
with: request as URLRequest, completionHandler: {
(data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
}
)
dataTask.resume()
Response
{
"id": 1,
"accountId": 1,
"quoteId": 1,
"balanceUSD": 800,
"collateralHeld": 0.045,
"collateralSymbol": "BTC",
"apr": 7.5,
"currentLTV": 38.5,
"currentCollateralPrice": 46177,
"status": "OPEN",
"created": "2022-04-02T19:23:24"
}
Returns a loan, given its unique id.
HTTP Request
https://api.example.com/v1/lending/loans/<ID>
URL Parameters
Parameter | Description |
---|---|
ID | The id of the loan to retrieve |
Response Properties
Property | Description |
---|---|
id | Unique identifier of the loan |
accountId | Unique id of the customer’s account associated with the loan |
quoteId | Unique id of the quote which determined the collateral amount for the loan |
balanceUSD | The outstanding (unpaid) balance of the loan |
collateralHeld | The amount of cryptocurrency being held in the collateral vault wallet |
collateralSymbol | The short name (symbol) of the cryptocurrency |
apr | The annual percentage rate charged by the partner to the customer |
currentLTV | The loan-to-value at time of origination of the loan |
currentCollateralPrice | The market price of the collateral currency at origination |
status | The state of the loan, one of ‘PENDING’, ‘OPEN’, ‘CLOSING’, ‘CLOSED’, or ‘FAILED’ |
created | The UTC timestamp at which the loan was created |
Response Codes
HTTP Code | Status |
---|---|
200 |
OK |
404 |
Not Found |
Get Loans for an Account
Request
curl "https://api.example.com/v1/lending/quotes?accountId=1" \
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.example.com/v1/lending/quotes?accountId=1")
.get()
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://api.example.com/v1/lending/quotes?accountId=1");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.example.com/v1/lending/quotes?accountId=1",
"method": "GET",
"headers": {
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require("request");
var options = { method: 'GET',
url: 'https://api.example.com/v1/quotes',
qs: {
accountId: '1',
},
headers:
{
} };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
<?php
$request = new HttpRequest();
$request->setUrl('https://api.example.com/v1/quotes');
$request->setMethod(HTTP_METH_GET);
$request->setQueryData(array(
'accountId' => '1',
));
$request->setHeaders(array(
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/lending/quotes?accountId=1")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body
import requests
url = "https://api.example.com/v1/quotes"
querystring = {
"accountId":"1",
}
payload = ""
headers = {
}
response = requests.request("GET", url, data=payload, headers=headers, params=querystring)
print(response.text)
use REST::Client;
my $client = REST::Client->new();
$url="https://api.example.com/v1/lending/quotes?accountId=1";
$client->GET($url);
print $client->responseContent();
print $client->responseHeader('ResponseHeader');
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.example.com/v1/lending/quotes?accountId=1"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
import Foundation
let headers = [
]
let request = NSMutableURLRequest(
url: NSURL(string: "https://api.example.com/v1/lending/quotes?accountId=1")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(
with: request as URLRequest, completionHandler: {
(data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
}
)
dataTask.resume()
Response
[
{
"id": 1,
"accountId": 1,
"quoteId": 1,
"balanceUSD": 800,
"collateralHeld": 0.045,
"collateralSymbol": "BTC",
"apr": 7.5,
"currentLTV": 38.4,
"currentCollateralPrice": 46321,
"status": "OPEN",
"created": "2022-04-02T19:49:30"
}
]
Returns all loans, past and present, for a given account.
HTTP Request
https://api.example.com/v1/lending/loans?accountId=<value>
Query Parameters
Parameter | Use | Description |
---|---|---|
accountId | required | The id of the customer account for which to retrieve loans |
Response Properties
This API method returns a list of loan objects
Property | Description |
---|---|
id | Unique identifier of the loan |
accountId | Unique id of the customer’s account associated with the loan |
quoteId | Unique id of the quote which determined the collateral amount for the loan |
balanceUSD | The outstanding (unpaid) balance of the loan |
collateralHeld | The amount of cryptocurrency being held in the collateral vault wallet |
collateralSymbol | The short name (symbol) of the cryptocurrency |
apr | The annual percentage rate charged by the partner to the customer |
currentLTV | The loan-to-value at time of origination of the loan |
currentCollateralPrice | The market price of the collateral currency at origination |
status | The state of the loan, one of ‘PENDING’, ‘OPEN’, ‘CLOSING’, ‘CLOSED’, or ‘FAILED’ |
created | The UTC timestamp at which the loan was created |
Response Codes
HTTP Code | Status |
---|---|
200 |
OK |
404 |
Not Found |
Get Loan Transaction History
Request
curl "https://api.example.com/v1/lending/loans/1/transactions?from=1645844323" \
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.example.com/v1/lending/loans/1/transactions?from=1645844323")
.get()
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://api.example.com/v1/lending/loans/1/transactions?from=1645844323");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.example.com/v1/lending/loans/1/transactions?from=1645844323",
"method": "GET",
"headers": {
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require("request");
var options = { method: 'GET',
url: 'https://api.example.com/v1/loans/1/transactions',
qs: {
from: '1645844323',
},
headers:
{
} };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
<?php
$request = new HttpRequest();
$request->setUrl('https://api.example.com/v1/loans/1/transactions');
$request->setMethod(HTTP_METH_GET);
$request->setQueryData(array(
'from' => '1645844323',
));
$request->setHeaders(array(
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/lending/loans/1/transactions?from=1645844323")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body
import requests
url = "https://api.example.com/v1/loans/1/transactions"
querystring = {
"from":"1645844323",
}
payload = ""
headers = {
}
response = requests.request("GET", url, data=payload, headers=headers, params=querystring)
print(response.text)
use REST::Client;
my $client = REST::Client->new();
$url="https://api.example.com/v1/lending/loans/1/transactions?from=1645844323";
$client->GET($url);
print $client->responseContent();
print $client->responseHeader('ResponseHeader');
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.example.com/v1/lending/loans/1/transactions?from=1645844323"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
import Foundation
let headers = [
]
let request = NSMutableURLRequest(
url: NSURL(string: "https://api.example.com/v1/lending/loans/1/transactions?from=1645844323")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(
with: request as URLRequest, completionHandler: {
(data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
}
)
dataTask.resume()
Response
[
{
"id": 3,
"loanId": 1,
"action": "Add Collateral",
"amount": 0.025,
"currencySymbol": "BTC",
"balanceUSD": 700,
"collateralHeld": 0.07,
"status": "POSTED",
"created": "2022-04-02T19:44"
},
{
"id": 2,
"loanId": 1,
"action": "Payment",
"amount": 100,
"currencySymbol": "USD",
"balanceUSD": 700,
"collateralHeld": 0.045,
"status": "POSTED",
"created": "2022-04-02T19:43"
},
{
"id": 1,
"loanId": 1,
"action": "Loan Origination",
"amount": 0,
"currencySymbol": "BTC",
"balanceUSD": 800,
"collateralHeld": 0.045,
"status": "POSTED",
"created": "2022-04-02T19:43:25"
}
]
Returns a list of all transactions associated with the loan, within a given timeframe, in descending order by date.
HTTP Request
https | //api.example.com/v1/lending/loans/<ID>/transactions?from=<value>&to=<value>
URL Parameters
Parameter | Description |
---|---|
ID | The ID of the loan for which to retrieve transaction history |
Query Parameters
Parameter | Use | Description |
---|---|---|
from | required | The start of the timeframe, in <a href="https |
to | optional | The end of the timeframe, in <a href="https |
Response Properties
This API method returns a list of loan transaction objectss, sorted by date in descending order
Property | Description |
---|---|
id | Unique identifier of the loan transaction |
loanId | Unique identifier of the loan to which the transaction pertains |
action | The type of action carried out by the transaction, one of |
description | A short informative message giving context to the transaction’s reason |
amount | The amount transacted (Note |
currencySymbol | The short name of the currency to which amount applies (e.g. ‘BTC’ or ‘USD’) |
balanceUSD | The outstanding balance of the loan after the transaction, in US dollars |
collateralHeld | Yhe amount of cryptocurrency being held in the collateral vault wallet |
created | The UTC timestamp at which the transaction was created |
Response Codes
HTTP Code | Status |
---|---|
200 |
OK |
400 |
Bad Request |
404 |
Not Found |
Close Loan
Request
curl -X PATCH \
https://api.example.com/v1/lending/loans/1 \
-H 'Content-Type: application/json' \
-d '<REQUEST BODY>'
var client = new RestClient("https://api.example.com/v1/lending/loans/1");
var request = new RestRequest(Method.PATCH);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "<REQUEST BODY>", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Dim client = New RestClient("https://api.example.com/v1/lending/loans/1")
Dim request = New RestRequest(Method.PATCH)
request.AddHeader("Content-Type", "application/json")
request.AddParameter("application/json", "<REQUEST BODY>", ParameterType.RequestBody);
Dim response As IRestResponse = client.Execute(request)
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "<REQUEST BODY>");
Request request = new Request.Builder()
.url("https://api.example.com/v1/lending/loans/1")
.patch(body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.example.com/v1/lending/loans/1/transactions?from=1645844323",
"method": "PATCH",
"headers": {
"Content-Type", "application/json",
},
"processData": false,
"data": "<REQUEST BODY>"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require("request");
var options = { method: 'PATCH',
url: 'https://api.example.com/v1/lending/loans/1',
headers:
{
'Content-Type': 'application/json',
},
body: '<REQUEST BODY>',
json: true };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
<?php
$request = new HttpRequest();
$request->setUrl('https://api.example.com/v1/lending/loans/1');
$request->setMethod(HTTP_METH_PATCH);
$request->setHeaders(array(
'Content-Type' => 'application/json',
));
$request->setBody('<REQUEST BODY>');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/lending/loans/1")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Patch.new(url)
request["Content-Type"] = 'application/json',
request.body = "<REQUEST BODY>"
response = http.request(request)
puts response.read_body
import requests
url = "https://api.example.com/v1/lending/loans/1"
payload = "<REQUEST BODY>"
headers = {
'Content-Type': 'application/json',
}
response = requests.request("PATCH", url, data=payload, headers=headers)
print(response.text)
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.example.com/v1/lending/loans/1"
payload := strings.NewReader("<REQUEST BODY>")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
import Foundation
let headers = [
"Content-Type": "application/json",
]
let parameters = <REQUEST BODY> as [String : Any]
let patchData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(
url: NSURL(string: "https://api.example.com/v1/lending/loans/1")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "PATCH"
request.allHTTPHeaderFields = headers
request.httpBody = patchData as Data
let session = URLSession.shared
let dataTask = session.dataTask(
with: request as URLRequest,
completionHandler: {
(data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
}
)
dataTask.resume()
use REST::Client;
my $client = REST::Client->new();
$client->addHeader('Content-Type', 'application/json');
$req = '<REQUEST BODY>';
$url="https://api.example.com/v1/lending/loans/1";
$client->PATCH($url, $req);
print $client->responseContent();
print $client->responseHeader('ResponseHeader');
Request Body
{
"status": "CLOSE"
}
Response
Updates the status of the loan to ‘CLOSED’.
HTTP Request
https://api.example.com/v1/lending/loans/<ID>
URL Parameters
Parameter | Description |
---|---|
ID | The ID of the loan to close |
Request Properties
Property | Use | Description |
---|---|---|
status | required | The value of this property must be set to CLOSE. |
Response
No Content
Response Codes
HTTP Code | Status |
---|---|
204 |
No Content. |
400 |
Bad Request. |
403 |
Forbidden. The loan is not in a state to permit closure. |
422 |
Unprocessable Entity. |
Loan Transactions
Apply Interest
Request
curl -X POST \
https://api.example.com/v1/lending/loans/1/transactions \
-H 'Content-Type: application/json' \
-d '<REQUEST BODY>'
var client = new RestClient("https://api.example.com/v1/lending/loans/1/transactions");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "<REQUEST BODY>", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Dim client = New RestClient("https://api.example.com/v1/lending/loans/1/transactions")
Dim request = New RestRequest(Method.POST)
request.AddHeader("Content-Type", "application/json")
request.AddParameter("application/json", "<REQUEST BODY>", ParameterType.RequestBody);
Dim response As IRestResponse = client.Execute(request)
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "<REQUEST BODY>");
Request request = new Request.Builder()
.url("https://api.example.com/v1/lending/loans/1/transactions")
.post(body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.example.com/v1/lending/loans/1/transactions?from=1645844323",
"method": "POST",
"headers": {
"Content-Type", "application/json",
},
"processData": false,
"data": "<REQUEST BODY>"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require("request");
var options = { method: 'POST',
url: 'https://api.example.com/v1/lending/loans/1/transactions',
headers:
{
'Content-Type': 'application/json',
},
body: '<REQUEST BODY>',
json: true };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
<?php
$request = new HttpRequest();
$request->setUrl('https://api.example.com/v1/lending/loans/1/transactions');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'Content-Type' => 'application/json',
));
$request->setBody('<REQUEST BODY>');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/lending/loans/1/transactions")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json',
request.body = "<REQUEST BODY>"
response = http.request(request)
puts response.read_body
import requests
url = "https://api.example.com/v1/lending/loans/1/transactions"
payload = "<REQUEST BODY>"
headers = {
'Content-Type': 'application/json',
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.example.com/v1/lending/loans/1/transactions"
payload := strings.NewReader("<REQUEST BODY>")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
import Foundation
let headers = [
"Content-Type": "application/json",
]
let parameters = <REQUEST BODY> as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(
url: NSURL(string: "https://api.example.com/v1/lending/loans/1/transactions")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(
with: request as URLRequest,
completionHandler: {
(data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
}
)
dataTask.resume()
use REST::Client;
my $client = REST::Client->new();
$client->addHeader('Content-Type', 'application/json');
$req = '<REQUEST BODY>';
$url="https://api.example.com/v1/lending/loans/1/transactions";
$client->POST($url, $req);
print $client->responseContent();
print $client->responseHeader('ResponseHeader');
Request Body
{
"action": "APPLY_INTEREST",
"description": "Adding interest for May",
"amount": 5.33,
"currency": "USD"
}
Response
{
"id": 2,
"loanId": 1,
"action": "APPLY_INTEREST",
"description": "Adding interest for May",
"amount": 5.33,
"currencySymbol": "USD",
"balanceUSD": 805.33,
"collateralHeld": 0.04297471,
"created": "2022-04-03T17:32:17"
}
This endpoint is for adding the interest amount to the outstanding balance of the loan, monthly.
HTTP Request
https://api.example.com/v1/lending/loans/<ID>/transactions
URL Parameters
Parameter | Description |
---|---|
ID | The id of the loan for which to make payment |
Request Properties
Property | Use | Description |
---|---|---|
action | required | A descriptor, the value of which must be set to Apply Interest. |
description | required | A short summary message to provide reason for the transaction |
amount | required | The dollar amount of the interest to add to the balance. |
currency | required | The currency symbol. Must be USD. |
Response Properties
Property | Description |
---|---|
id | Unique identifier of the newly created apply interest transaction |
loanId | Unique identifier of the loan to which the transaction applies |
action | The action carried out |
description | A short informative message providing reason for the transaction |
amount | The amount added to the outstanding balance |
currencySymbol | The currency in which the amount is denominated. Must be ‘USD’. |
balanceUSD | The outstanding balance of the loan after the transaction, in US dollars |
collateralHeld | The amount of cryptocurrency being held in the collateral vault wallet |
created | The UTC timestamp at which the transaction was created |
Response Codes
HTTP Code | Status |
---|---|
201 |
Created |
400 |
Bad Request |
409 |
Conflict |
422 |
Unprocessable Entity |
Make Payment
Request
curl -X POST \
https://api.example.com/v1/lending/loans/1/transactions \
-H 'Content-Type: application/json' \
-d '<REQUEST BODY>'
var client = new RestClient("https://api.example.com/v1/lending/loans/1/transactions");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "<REQUEST BODY>", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Dim client = New RestClient("https://api.example.com/v1/lending/loans/1/transactions")
Dim request = New RestRequest(Method.POST)
request.AddHeader("Content-Type", "application/json")
request.AddParameter("application/json", "<REQUEST BODY>", ParameterType.RequestBody);
Dim response As IRestResponse = client.Execute(request)
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "<REQUEST BODY>");
Request request = new Request.Builder()
.url("https://api.example.com/v1/lending/loans/1/transactions")
.post(body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.example.com/v1/lending/loans/1/transactions?from=1645844323",
"method": "POST",
"headers": {
"Content-Type", "application/json",
},
"processData": false,
"data": "<REQUEST BODY>"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require("request");
var options = { method: 'POST',
url: 'https://api.example.com/v1/lending/loans/1/transactions',
headers:
{
'Content-Type': 'application/json',
},
body: '<REQUEST BODY>',
json: true };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
<?php
$request = new HttpRequest();
$request->setUrl('https://api.example.com/v1/lending/loans/1/transactions');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'Content-Type' => 'application/json',
));
$request->setBody('<REQUEST BODY>');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/lending/loans/1/transactions")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json',
request.body = "<REQUEST BODY>"
response = http.request(request)
puts response.read_body
import requests
url = "https://api.example.com/v1/lending/loans/1/transactions"
payload = "<REQUEST BODY>"
headers = {
'Content-Type': 'application/json',
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.example.com/v1/lending/loans/1/transactions"
payload := strings.NewReader("<REQUEST BODY>")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
import Foundation
let headers = [
"Content-Type": "application/json",
]
let parameters = <REQUEST BODY> as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(
url: NSURL(string: "https://api.example.com/v1/lending/loans/1/transactions")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(
with: request as URLRequest,
completionHandler: {
(data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
}
)
dataTask.resume()
use REST::Client;
my $client = REST::Client->new();
$client->addHeader('Content-Type', 'application/json');
$req = '<REQUEST BODY>';
$url="https://api.example.com/v1/lending/loans/1/transactions";
$client->POST($url, $req);
print $client->responseContent();
print $client->responseHeader('ResponseHeader');
Request Body
{
"action": "MAKE_PAYMENT",
"description": "Payment for May",
"amount": 100,
"currency": "USD"
}
Response
{
"id": 3,
"loanId": 1,
"action": "MAKE_PAYMENT",
"description": "Payment for May",
"amount": 100,
"currencySymbol": "USD",
"balanceUSD": 705.33,
"collateralHeld": 0.045,
"created": "2022-04-03T17:34"
}
This endpoint is for making payments to the customer’s outstanding balance.
HTTP Request
https://api.example.com/v1/lending/loans/<ID>/transactions
URL Parameters
Parameter | Description |
---|---|
ID | The id of the loan for which to make payment |
Request Properties
Property | Use | Description |
---|---|---|
action | required | A descriptor, the value of which must be set to Payment. |
description | required | A short summary message to provide reason for the transaction |
amount | required | The dollar amount of the loan payment. |
currency | required | The payment currency symbol. Must be USD. |
Response Properties
Property | Description |
---|---|
id | Unique identifier of the newly created make payment transaction |
loanId | Unique identifier of the loan to which the transaction applies |
action | The action carried out: ‘MAKE PAYMENT’ |
description | A short informative message providing reason for the transaction |
amount | The amount paid on the outstanding balance |
currencySymbol | The currency in which the amount is denominated. Must be ‘USD’. |
balanceUSD | The outstanding balance of the loan after the transaction, in US dollars |
collateralHeld | The amount of cryptocurrency being held in the collateral vault wallet |
created | The UTC timestamp at which the transaction was created |
Response Codes
HTTP Code | Status |
---|---|
201 |
Created. The loan transaction has been sucessfully created. |
400 |
Bad Request. |
409 |
Conflict. |
422 |
Unprocessable Entity. |
Add Collateral
Request
curl -X POST \
https://api.example.com/v1/lending/loans/1/transactions \
-H 'Content-Type: application/json' \
-d '<REQUEST BODY>'
var client = new RestClient("https://api.example.com/v1/lending/loans/1/transactions");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "<REQUEST BODY>", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Dim client = New RestClient("https://api.example.com/v1/lending/loans/1/transactions")
Dim request = New RestRequest(Method.POST)
request.AddHeader("Content-Type", "application/json")
request.AddParameter("application/json", "<REQUEST BODY>", ParameterType.RequestBody);
Dim response As IRestResponse = client.Execute(request)
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "<REQUEST BODY>");
Request request = new Request.Builder()
.url("https://api.example.com/v1/lending/loans/1/transactions")
.post(body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.example.com/v1/lending/loans/1/transactions?from=1645844323",
"method": "POST",
"headers": {
"Content-Type", "application/json",
},
"processData": false,
"data": "<REQUEST BODY>"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require("request");
var options = { method: 'POST',
url: 'https://api.example.com/v1/lending/loans/1/transactions',
headers:
{
'Content-Type': 'application/json',
},
body: '<REQUEST BODY>',
json: true };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
<?php
$request = new HttpRequest();
$request->setUrl('https://api.example.com/v1/lending/loans/1/transactions');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'Content-Type' => 'application/json',
));
$request->setBody('<REQUEST BODY>');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/lending/loans/1/transactions")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json',
request.body = "<REQUEST BODY>"
response = http.request(request)
puts response.read_body
import requests
url = "https://api.example.com/v1/lending/loans/1/transactions"
payload = "<REQUEST BODY>"
headers = {
'Content-Type': 'application/json',
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.example.com/v1/lending/loans/1/transactions"
payload := strings.NewReader("<REQUEST BODY>")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
import Foundation
let headers = [
"Content-Type": "application/json",
]
let parameters = <REQUEST BODY> as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(
url: NSURL(string: "https://api.example.com/v1/lending/loans/1/transactions")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(
with: request as URLRequest,
completionHandler: {
(data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
}
)
dataTask.resume()
use REST::Client;
my $client = REST::Client->new();
$client->addHeader('Content-Type', 'application/json');
$req = '<REQUEST BODY>';
$url="https://api.example.com/v1/lending/loans/1/transactions";
$client->POST($url, $req);
print $client->responseContent();
print $client->responseHeader('ResponseHeader');
Request Body
{
"action": "ADD_COLLATERAL",
"description": "Topping off collateral",
"amount": 0.005,
"currency": "BTC"
}
Response
{
"id": 4,
"loanId": 1,
"action": "ADD_COLLATERAL",
"description": "Topping off collateral",
"amount": 0.005,
"currencySymbol": "BTC",
"balanceUSD": 605.33,
"collateralHeld": 0.05,
"created": "2022-04-03T17:36:05"
}
This endpoint is for adding collateral to further secure the customer’s balance. The customer must have sufficient funds in their wallet, as this operation results in the transfer of cryptocurrency from the customer wallet into the secure vault wallet.
HTTP Request
https://api.example.com/v1/lending/loans/<ID>/transactions
URL Parameters
Parameter | Description |
---|---|
ID | The ID of the loan for which to add collateral |
Request Properties
Property | Use | Description |
---|---|---|
action | required | The value of this property must be set to Add Collateral. |
description | required | A short summary message to provide reason for the transaction |
amount | required | The amount of currency to add. |
currency | required | The currency of the collateral to add. |
Response Properties
Property | Description |
---|---|
id | Unique identifier of the newly created add collateral transaction |
loanId | Unique identifier of the loan to which the transaction applies |
action | The action carried out |
description | A short informative message providing reason for the transaction |
amount | The amount added to collateral |
currencySymbol | The currency in which the amount is denominated. Must be ‘USD’. |
balanceUSD | The outstanding balance of the loan after the transaction, in US dollars |
collateralHeld | The amount of cryptocurrency being held in the collateral vault wallet |
created | The UTC timestamp at which the transaction was created |
Response Codes
HTTP Code | Status |
---|---|
201 |
Created |
400 |
Bad Request |
409 |
Conflict |
422 |
Unprocessable Entity |
Liquidate Collateral
Request
curl -X POST \
https://api.example.com/v1/lending/loans/1/transactions \
-H 'Content-Type: application/json' \
-d '<REQUEST BODY>'
var client = new RestClient("https://api.example.com/v1/lending/loans/1/transactions");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "<REQUEST BODY>", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Dim client = New RestClient("https://api.example.com/v1/lending/loans/1/transactions")
Dim request = New RestRequest(Method.POST)
request.AddHeader("Content-Type", "application/json")
request.AddParameter("application/json", "<REQUEST BODY>", ParameterType.RequestBody);
Dim response As IRestResponse = client.Execute(request)
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "<REQUEST BODY>");
Request request = new Request.Builder()
.url("https://api.example.com/v1/lending/loans/1/transactions")
.post(body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.example.com/v1/lending/loans/1/transactions?from=1645844323",
"method": "POST",
"headers": {
"Content-Type", "application/json",
},
"processData": false,
"data": "<REQUEST BODY>"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require("request");
var options = { method: 'POST',
url: 'https://api.example.com/v1/lending/loans/1/transactions',
headers:
{
'Content-Type': 'application/json',
},
body: '<REQUEST BODY>',
json: true };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
<?php
$request = new HttpRequest();
$request->setUrl('https://api.example.com/v1/lending/loans/1/transactions');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'Content-Type' => 'application/json',
));
$request->setBody('<REQUEST BODY>');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/lending/loans/1/transactions")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json',
request.body = "<REQUEST BODY>"
response = http.request(request)
puts response.read_body
import requests
url = "https://api.example.com/v1/lending/loans/1/transactions"
payload = "<REQUEST BODY>"
headers = {
'Content-Type': 'application/json',
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.example.com/v1/lending/loans/1/transactions"
payload := strings.NewReader("<REQUEST BODY>")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
import Foundation
let headers = [
"Content-Type": "application/json",
]
let parameters = <REQUEST BODY> as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(
url: NSURL(string: "https://api.example.com/v1/lending/loans/1/transactions")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(
with: request as URLRequest,
completionHandler: {
(data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
}
)
dataTask.resume()
use REST::Client;
my $client = REST::Client->new();
$client->addHeader('Content-Type', 'application/json');
$req = '<REQUEST BODY>';
$url="https://api.example.com/v1/lending/loans/1/transactions";
$client->POST($url, $req);
print $client->responseContent();
print $client->responseHeader('ResponseHeader');
Request Body
{
"action": "LIQUIDATE_COLLATERAL",
"description": "Missed Payment",
"amount": 100,
"currency": "USD"
}
Response
{
"id": 5,
"loanId": 1,
"action": 4,
"description": "Missed Payment",
"amount": 100,
"currencySymbol": "USD",
"balanceUSD": 605.33,
"collateralHeld": 0.04782722,
"created": "2022-04-03T17:40:34"
}
This endpoint is to be used for liquidation of the customer's collateral.
HTTP Request
https://api.example.com/v1/lending/loans/<ID>/transactions
URL Parameters
Parameter | Description |
---|---|
ID | The ID of the loan for which to liquidate collateral |
Request Properties
Property | Use | Description |
---|---|---|
action | required | The value of this property must be set to Liquidate. |
description | required | A short summary message to provide reason for the transaction |
amount | required | The amount of currency to sell. |
currency | required | The currency of the collateral to sell. |
Response Properties
Property | Description |
---|---|
id | Unique identifier of the newly created liquidate collateral transaction |
loanId | Unique identifier of the loan to which the transaction applies |
action | The action carried out |
description | A short informative message providing reason for the transaction |
amount | The amount to liquidate |
currencySymbol | The currency in which the amount is denominated. Can be either ‘USD’ or ‘BTC’ |
balanceUSD | The outstanding balance of the loan after the transaction, in US dollars |
collateralHeld | The amount of cryptocurrency being held in the collateral vault wallet. |
created | The UTC timestamp at which the transaction was created |
Response Codes
HTTP Code | Status |
---|---|
201 |
Created |
400 |
Bad Request |
403 |
Forbidden |
409 |
Conflict |
422 |
Unprocessable Entity |
Webhooks
Our early-adopter partners have requested push notifications in the event of the following conditions:
- Extreme cryptocurrency price volatility (e.g. a drop of >20% within a 24-hour period)
- Customers' loan-to-value (LTV) exceeds a given threshold.
In both of these situations the partner may choose to sell a portion of their customers' collateral to manage risk. New webhook API's are coming soon to faciliate proactive notifications and alerts to meet these needs.
Errors
Following is a complete list of all error codes used by this API:
Error Code | Meaning |
---|---|
400 | Bad Request |
403 | Forbidden |
404 | Not Found |
409 | Conflict |
422 | Unprocessable Request |
429 | Too Many Requests |
500 | Internal Server Error |
503 | Service Unavailable |