Quick Start Guide

For developers eager to hit the ground running with the CPAY Rates API here are a few quick steps to make your first call with the API.

  1. Sign up. You can sign up at coinprice.cpay.world - This is our live production environment with the latest market data. Select the free Basic plan if it meets your needs or upgrade to a paid tier.

  2. Copy your API key. After registration, you will be taken to the main page of your account. Copy your API key from the API Key field from the API Key section.

  3. Make a test call using your key. You may use the code examples provided below to make a test call with your programming language of choice.This example retrieves the AAVEBTC exchange rate history for one day within an hour. Be sure to replace the API key in the sample code with your own and use the api.rates.cpay.world/ex API domain. Please note that our sandbox API contains mock data and should not be used in your application.

  4. Implement your application. Now that you've confirmed your API Key is working, get familiar with the API by reading the rest of this API Reference and commence building your application!

cURL command line

curl --location --request GET 'https://api.rates.cpay.world/ex/api/exchanges/history?symbol=AAVEBTC&from=2022-02-02 14:12:10&to=2022-02-03 14:12:10&interval=hourly&exchangeId=1' --header 'x-exchange-api-key: Z300BHR-WT6MPRZ-PEHNBZ8-9SGXK91'

Node.js
/* Example in Node.js */
const axios = require('axios');

let response = null;
new Promise(async (resolve, reject) => {
  try {
    response = await axios.get('https://api.rates.cpay.world/ex/api/exchanges/history?symbol=AAVEBTC&from=2022-02-02 14:12:10&to=2022-02-03 14:12:10&interval=hourly&exchangeId=1', {
      headers: {
        'x-exchange-api-key': 'Z300BHR-WT6MPRZ-PEHNBZ8-9SGXK91',
      },
    });
  } catch(ex) {
    response = null;
    // error
    console.log(ex);
    reject(ex);
  }
  if (response) {
    // success
    const json = response.data;
    console.log(json);
    resolve(json);
  }
});
Python
#This example uses Python 2.7 and the python-request library.

from requests import Request, Session
from requests.exceptions import ConnectionError, Timeout, TooManyRedirects
import json

url = 'https://api.rates.cpay.world/ex/api/exchanges/history'
parameters = {
  'symbol':'AAVEBTC',
  'from':'2022-02-02 14:12:10',
  'to':'2022-02-03 14:12:10',
  'interval':'hourly',
  'exchangeId':'1',
}
headers = {
  'Accepts': 'application/json',
  'x-exchange-api-key': 'Z300BHR-WT6MPRZ-PEHNBZ8-9SGXK91',
}

session = Session()
session.headers.update(headers)

try:
  response = session.get(url, params=parameters)
  data = json.loads(response.text)
  print(data)
except (ConnectionError, Timeout, TooManyRedirects) as e:
  print(e)
  
PHP
/**
 * Requires curl enabled in php.ini
 **/

<?php
$url = 'https://api.rates.cpay.world/ex/api/exchanges/history';
$parameters = [
  'symbol' => 'AAVEBTC',
  'from' => '2022-02-02 14:12:10',
  'to' => '2022-02-03 14:12:10',
  'interval' => 'hourly',
  'exchangeId' => '1'
];

$headers = [
  'Accepts: application/json',
  'x-exchange-api-key: Z300BHR-WT6MPRZ-PEHNBZ8-9SGXK91'
];
$qs = http_build_query($parameters); // query string encode the parameters
$request = "{$url}?{$qs}"; // create the request URL


$curl = curl_init(); // Get cURL resource
// Set cURL options
curl_setopt_array($curl, array(
  CURLOPT_URL => $request,            // set the request URL
  CURLOPT_HTTPHEADER => $headers,     // set the headers 
  CURLOPT_RETURNTRANSFER => 1         // ask for raw response instead of bool
));

$response = curl_exec($curl); // Send the request, save the response
print_r(json_decode($response)); // print json decoded response
curl_close($curl); // Close request
?>

Java
C#
Go

Last updated