API reference
Authentication
Last updated
The Tradesync API uses API keys to authenticate requests. Each request uses a key and secret pair with Basic authorization. Your key:secret pair must be Base64 encoded and added to the header of each request.
Key and secret pairs can be generated and managed via the web application's API keys page.
Your username and password for the web application are not used for API requests.
Required header
Authorization: Basic <base64-encoded credentials>
Sample http request with encoded auth
GET /accounts HTTP/1.1
Host: api.tradesync.com
Content-Type: application/json
Authorization: Basic <base64-encoded key:secret>
Response body
{
"result": "success",
"status": 200,
"meta": {
"count": 0,
"limit": 1000,
"order": "desc",
"last_id": null
},
"data": []
}
JavaScript fetch example
fetch("https://api.tradesync.com/accounts/",{
headers: {
'Authorization':'Basic ' + btoa('H7VNs9JbKJQCZUtf7Wt:UQ8K6WibfeVml0QzZLis')
}
}).then((response) => {
if(response.ok){
return response.json();
}
throw response;
}).then((data) => {
console.log(data);
}).catch((error) => {
console.log(error);
});
PHP Curl example
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.tradesync.com/accounts/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, "H7VNs9JbKJQCZUtf7Wt:UQ8K6WibfeVml0QzZLis");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
$response = curl_exec($ch);
$http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($http_status === 200) {
$data = json_decode($response, true);
print_r($data);
} else {
echo "Error: HTTP Status $http_status\n";
echo "Response: $response";
}
curl_close($ch);
?>
Python example
import requests
from requests.auth import HTTPBasicAuth
response = requests.get("https://api.tradesync.com/accounts/", auth=HTTPBasicAuth("H7VNs9JbKJQCZUtf7Wt", "UQ8K6WibfeVml0QzZLis"))
if response.status_code == 200:
data = response.json()
print(data)
else:
print(f"Error: HTTP {response.status_code}")
print(response.text)