get https://openexchangerates.org/api/usage.json
Get basic plan information and usage statistics for an Open Exchange Rates App ID
Requests to
usage.info
do not count towards your usage volume.
If the App ID you provided is valid, you will receive a JSON response with a status
value (containing the HTTP code of the response) and a data
object, containing the following attributes:
app_id
: The app ID you provided.status
: The current status of this app ID (either 'active' or 'access_restricted')plan
: Plan information for this app IDname
: The name of the current planquota
: The monthly request allowance (formatted string for display)update_frequency
: The rate at which data refreshes on this planfeatures
: The supported features of this plan (base
,symbols
,experimental
,time-series
,convert
)usage
: Usage information for this app IDrequests
: Number of requests made since month startrequests_quota
: Number of requests allowed each month with this planrequests_remaining
: Number of requests remaining this monthdays_elapsed
: Number of days since start of monthdays_remaining
: Number of days remaining until next month's startdaily_average
: Average requests per day
NB: If the App ID belongs to an account with unlimited requests, the usage.requests_quota
and usage.requests_remaining
values will be -1
.
Public Endpoint
Because this API endpoint is accessible to anybody with any App ID, no personal or sensitive account data is ever returned.
Basic Code Samples
$.get('https://openexchangerates.org/api/usage.json', {app_id: 'YOUR_APP_ID'}, function(response) {
console.log("This Open Exchange Rates app ID has made " + response.data.usage.requests + "hits this month.");
});
<?php
$app_id = '[[app:app_id]]';
$oxr_url = "https://openexchangerates.org/api/latest.json?app_id=" . $app_id;
// Open CURL session:
$ch = curl_init($api_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// Get the data:
$json = curl_exec($ch);
curl_close($ch);
// Decode JSON response:
$oxr_latest = json_decode($json);
// You can now access the rates inside the parsed object, like so:
printf(
"1 %s equals %s GBP at %s",
$oxr_latest->base,
$oxr_latest->rates->GBP,
date('H:i jS F, Y', $oxr_latest->timestamp)
);
// -> eg. "1 USD equals: 0.656741 GBP at 11:11, 11th December 2015"
?>
More code samples are on their way! Please get in touch if you'd like to submit a new/improved code sample in your languague or framework.