Authorization
In order to access your account through our HTTP or WebSocket API, you need to specify your OAuth Access Token with the request.
Here's a rough guide for obtaining Access Tokens. Please refer to the OAuth 2.0 standard for the full details.
-
Create an OAuth Client ID for your application: Login to ProBit Global website with your ID, and click the "
API Settings" button in My Page. Click the "Create new key" button and copy the "Client ID" and "Client Secret Key". Keep it secret. Anyone who have this key have the full access to your account. -
Get an OAuth Access Token using POST /token API with the Client ID/Secret from Step 1(Example 1). Put this Access Token to the "Authorization" HTTP header to access your accounts(Example 2). Access Tokens expire after a few minutes, so you need to fetch a new Access Token before it expires. Expiration time can be found in the "expires_in" field of the POST /token API.
To access Probit Global accounts: Create your OAuth Client ID from https://www.probit.com/.
API endpoints are same for both Probit Global : https://api.probit.com/ and https://accounts.probit.com/token.
Authorization APIs have different addresses than other HTTP APIs.
Default endpoint: https://accounts.probit.com/token
Example 1. Retrieving an Access Token from Client ID and Client Secret.
const getToken = async () => {
const authHeader = 'Basic ' + new Buffer.from(apiClientId + ':' + apiClientSecret, 'utf-8').toString('base64');
const resp = await fetch('https://accounts.probit.com/token', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': authHeader
},
body: JSON.stringify({
grant_type: 'client_credentials'
})
});
if (!resp.ok) {
throw new Error(resp.statusText);
}
return resp.json();
};
import base64
import requests
apiClientId = "apiClientId"
apiClientSecret = "apiClientSecret"
payload = { "grant_type": "client_credentials" }
url = "https://accounts.probit.com/token"
# Concatenate the API client ID and secret with a colon
concatenated_credentials = f"{apiClientId}:{apiClientSecret}"
# Encode the concatenated string to base64
encoded_base64 = base64.b64encode(concatenated_credentials.encode()).decode()
headers = {
"accept": "application/json",
"Authorization": f"Basic {encoded_base64}",
"content-type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)
Example 2. Using the "balance" API with Access Token to fetch your account balances.
const getBalance = async () => {
const {access_token: accessToken} = await getToken();
const resp = await fetch('https://api.probit.com/api/exchange/v1/balance', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + accessToken
}
});
if (!resp.ok) {
throw new Error(resp.statusText);
}
return resp.json();
};
getBalance().then((balances) => console.log(balances));
Updated 8 months ago