Authentication

It is highly recommended that you follow the Create An App guide.

 

Register your app and get API keys


Your keys can be found in the Developer Tools app; You can find it in the app list in the left sidebar of Settle, or use this link to bring it up. Select the ‘Apps’ tab, make sure your app is selected from the list on the left and scroll down to the bottom of the App Details page.

You dont need to request a repo to key API keys. They are automatically generated when you create an app, and are available at the bottom of the first page (App Details).

JS Apps:

Use our NPM module

// npm install settlesdk
const Settle = require('settlesdk')
Settle.PriceFeed.Ticker({token: 'Bitcoin'})

console.log(Settle)

 

API Keys

Set your keys as environment variables. If you project doesn’t use env variables yet you will need to install dotenv.

// .env
SETTLE_API_KEY    = "API KEY HERE"
SETTLE_API_SECRET = "API SECRET HERE"

You can now make requests to the Settle API

 

Non JS Apps:

 

2 – Get an Access Token


Access tokens are one time use (1 per request) and expire after a short time, so they should be generated immediately before they are needed to make a request.

Access Tokens are handled separately by each Settle api service, currently there are 2:

// Main Settle API

https://jsapi.settle.finance

// Settle Price Feed API
https://dbapi.settle.finance

Make sure to get an access token from whichever api your call will be made to

// All endpoints other then price feed
GET https://jsapi.settle.finance/api/app/AccessToken

// Price feed
GET https://dbapi.settle.finance/api/app/AccessToken

headers: {
	'X-Api-Key': YOUR APP'S API KEY
}

The above request should return output like this:

{ accessToken: 'eyJhbGciOiJIUzI1NiIsI...' }

 

3 – Generate a Request Signature


Once you have an access token, you can use it and your app’s secret key to generate a signature for the request that will use the access token.

var signature = crypto.createHmac('sha256', YOUR APP'S API SECRET)
	.update(ACCESS TOKEN)
	.digest('base64')

 

4 – Make a Signed Request


We’ll use the app/users endpoint in this example, which requires authentication and returns a list of users that have installed your app.

// All endpoints other then price feed
GET https://jsapi.settle.finance/api/app/AccessToken

// Price feed
GET https://dbapi.settle.finance/api/app/AccessToken

headers: {
	'X-Api-Key': YOUR APP'S API KEY
	'X-Access-Token': ACCESS TOKEN
	'X-Api-Signature': GENERATED SIGNATURE
}

You can now make requests to the Settle API

 

Troubleshooting

If your app requested private data such as the portfolio, you need to install the app or else requests will be unauthorized. You can install your app privately in the developer tools: