Get Exchange Rates

Get exchange Rates

Rates are exchange rates, representing the number of fiat currency units equivalent to one BTC. You can retrieve BitPay's BBB exchange rates.

GET /rates/:basecurrency

Facades PUBLIC

HTTP Request

An example code to get rates

const result = await client.GetRates();

let rate = await client.GetRate(Currency::USD); //Always use the included Currency model to avoid typos

let Rates = new BitPaySDK.Models.Rates(await client.GetRates(), client);
await Rates.Update();

let newRates = await Rates.GetRates();

HTTP Response

Body

NameDescriptionType
dataarray of currency rates for the requested baseCurrency.array
codeISO 4217 3-character currency code.string
namedetailed currency name.string
raterate for the requested baseCurrency /currency pair.number
{
    "data":[
        {
        "code":"BTC",
        "name":"Bitcoin",
        "rate":1
        },
        {
        "code":"BCH",
        "name":"Bitcoin Cash",
        "rate":50.77
        },
        {
        "code":"USD",
        "name":"US Dollar",
        "rate":41248.11
        },
        {
        "code":"EUR",
        "name":"Eurozone Euro",
        "rate":33823.04
        },
        {
        "code":"GBP",
        "name":"Pound Sterling",
        "rate":29011.49
        },
        {
        "code":"JPY",
        "name":"Japanese Yen",
        "rate":4482741
        },
        {
        "code":"CAD",
        "name":"Canadian Dollar",
        "rate":49670.85
        },
        {
        "code":"AUD",
        "name":"Australian Dollar",
        "rate":53031.99
        },
        {
        "code":"CNY",
        "name":"Chinese Yuan",
        "rate":265266.57
        },
        ...
    ]
}

You can retrieve all the rates for a given cryptocurrency

URL Parameters

ParameterDescriptionTypePresence
baseCurrencythe cryptocurrency for which you want to fetch the rates. Current supported values are BTC and BCH.stringMandatory
currencythe fiat currency for which you want to fetch the baseCurrency rates.stringMandatory

Headers

FieldsDescriptionPresence
X-Accept-VersionMust be set to 2.0.0 for requests to the BitPay API.Mandatory
Content-Typemust be set to application/json for requests to the BitPay API.Mandatory
let rate = await client.GetRate(Currency::USD); //Always use the included Currency model to avoid typos

HTTP Response

Body

NameDescriptionType
datarate data object.object
codeISO 4217 3-character currency code.string
namedetailed currency name.string
raterate for the requested baseCurrency /currency pair.number
{
    "data":
        {
            "code":"USD",
            "name":"US Dollar",
            "rate":41154.05
        }
}

See also the test package for more examples of API calls.