Skip to content

Latest commit

 

History

History
145 lines (102 loc) · 6.95 KB

ExchangeRatesApi.md

File metadata and controls

145 lines (102 loc) · 6.95 KB

CryptoAPIs\ExchangeRatesApi

All URIs are relative to https://rest.cryptoapis.io.

Method HTTP request Description
getExchangeRateByAssetSymbols() GET /market-data/exchange-rates/by-symbols/{fromAssetSymbol}/{toAssetSymbol} Get Exchange Rate By Asset Symbols
getExchangeRateByAssetsIDs() GET /market-data/exchange-rates/by-asset-ids/{fromAssetId}/{toAssetId} Get Exchange Rate By Assets IDs

getExchangeRateByAssetSymbols()

getExchangeRateByAssetSymbols($from_asset_symbol, $to_asset_symbol, $context, $calculation_timestamp): \CryptoAPIs\Model\GetExchangeRateByAssetSymbolsR

Get Exchange Rate By Asset Symbols

Through this endpoint customers can obtain exchange rates by asset symbols. The process represents the exchange rate value of a single unit of one asset versus another one. Data is provided per unique asset symbol.

Example

<?php
require_once(__DIR__ . '/vendor/autoload.php');


// Configure API key authorization: ApiKey
$config = CryptoAPIs\Configuration::getDefaultConfiguration()->setApiKey('x-api-key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = CryptoAPIs\Configuration::getDefaultConfiguration()->setApiKeyPrefix('x-api-key', 'Bearer');


$apiInstance = new CryptoAPIs\Api\ExchangeRatesApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$from_asset_symbol = btc; // string | Defines the base asset symbol to get a rate for.
$to_asset_symbol = usd; // string | Defines the relation asset symbol in which the base asset rate will be displayed.
$context = yourExampleString; // string | In batch situations the user can use the context to correlate responses with requests. This property is present regardless of whether the response was successful or returned as an error. `context` is specified by the user.
$calculation_timestamp = 1635514425; // int | Defines the time of the market data used to calculate the exchange rate in UNIX Timestamp. Oldest possible timestamp is 30 days.

try {
    $result = $apiInstance->getExchangeRateByAssetSymbols($from_asset_symbol, $to_asset_symbol, $context, $calculation_timestamp);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling ExchangeRatesApi->getExchangeRateByAssetSymbols: ', $e->getMessage(), PHP_EOL;
}

Parameters

Name Type Description Notes
from_asset_symbol string Defines the base asset symbol to get a rate for.
to_asset_symbol string Defines the relation asset symbol in which the base asset rate will be displayed.
context string In batch situations the user can use the context to correlate responses with requests. This property is present regardless of whether the response was successful or returned as an error. `context` is specified by the user. [optional]
calculation_timestamp int Defines the time of the market data used to calculate the exchange rate in UNIX Timestamp. Oldest possible timestamp is 30 days. [optional]

Return type

\CryptoAPIs\Model\GetExchangeRateByAssetSymbolsR

Authorization

ApiKey

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

getExchangeRateByAssetsIDs()

getExchangeRateByAssetsIDs($from_asset_id, $to_asset_id, $context, $calculation_timestamp): \CryptoAPIs\Model\GetExchangeRateByAssetsIDsR

Get Exchange Rate By Assets IDs

Through this endpoint customers can obtain exchange rates by asset IDs. The process represents the exchange rate value of a single unit of one asset versus another one. Data is provided per unique asset Reference ID.

Example

<?php
require_once(__DIR__ . '/vendor/autoload.php');


// Configure API key authorization: ApiKey
$config = CryptoAPIs\Configuration::getDefaultConfiguration()->setApiKey('x-api-key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = CryptoAPIs\Configuration::getDefaultConfiguration()->setApiKeyPrefix('x-api-key', 'Bearer');


$apiInstance = new CryptoAPIs\Api\ExchangeRatesApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$from_asset_id = 5b1ea92e584bf50020130612; // string | Defines the base asset Reference ID to get a rate for.
$to_asset_id = 5b1ea92e584bf50020130615; // string | Defines the relation asset Reference ID in which the base asset rate will be displayed.
$context = yourExampleString; // string | In batch situations the user can use the context to correlate responses with requests. This property is present regardless of whether the response was successful or returned as an error. `context` is specified by the user.
$calculation_timestamp = 1618577849; // int | Defines the time of the market data used to calculate the exchange rate in UNIX Timestamp. Oldest possible timestamp is 30 days.

try {
    $result = $apiInstance->getExchangeRateByAssetsIDs($from_asset_id, $to_asset_id, $context, $calculation_timestamp);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling ExchangeRatesApi->getExchangeRateByAssetsIDs: ', $e->getMessage(), PHP_EOL;
}

Parameters

Name Type Description Notes
from_asset_id string Defines the base asset Reference ID to get a rate for.
to_asset_id string Defines the relation asset Reference ID in which the base asset rate will be displayed.
context string In batch situations the user can use the context to correlate responses with requests. This property is present regardless of whether the response was successful or returned as an error. `context` is specified by the user. [optional]
calculation_timestamp int Defines the time of the market data used to calculate the exchange rate in UNIX Timestamp. Oldest possible timestamp is 30 days. [optional]

Return type

\CryptoAPIs\Model\GetExchangeRateByAssetsIDsR

Authorization

ApiKey

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]