Error API Documentation

Sample Code PHP (GET Request)

Note: Get request is deprecated, Please use Post request.
Forex Latest Prices: Find below a simple PHP example for getting exchange rate data via the API's latest endpoint.

$access_key = "AUTH_KEY"; // Your API access key, Signup to get API KEY
$symbol = "EUR/USD"; // FX Pairs

// Enter your API URL below
$api_url = "https://elklayer.com/api/v1/latest?symbol=".$symbol."&access_key=".$access_key;

// Initialize CURL:
$ch = curl_init($api_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$json = curl_exec($ch); // Store the data
curl_close($ch);

$response = json_decode($json, true); // convert JSON into Array
foreach ($response['response'] as $key => $value) {
  echo "<br>Open Price Of ".$value['symbol']." is ".$value['price']; // Open Price Of EUR/USD is 1.1266
}

Sample Code PHP (POST Request)

$access_key = "AUTH_KEY"; // Your API access key, Signup to get API KEY
$symbol = "EUR/USD"; // FX Pairs

// Enter your API URL below
$api_url = "https://elklayer.com/api/v1/latest";
$post = "symbol=".$symbol."&access_key=".$access_key;

// Initialize CURL:
$ch = curl_init($api_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$json = curl_exec($ch); // Store the data
curl_close($ch);

$response = json_decode($json, true); // convert JSON into Array
foreach ($response['response'] as $key => $value) {
  echo "<br>Open Price Of ".$value['symbol']." is ".$value['price']; // Open Price Of EUR/USD is 1.1266
}

Sample Code jQuery.ajax

Find below a simple jQuery.ajax example of getting exchange rate data via the API's latest endpoint.

<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<script>
access_key = "AUTH_KEY"; // Your API access key, Signup to get API KEY
id = '1,2,3,4'; // Forex ids

$.ajax({
    url:
"https://elklayer.com/api/v1/latest?id=" + id + "&access_key=" + access_key,
    type:
"GET", // GET or POST
    dataType:
"json",
    success: function(data) {
        console.log("Price of "+data.response[0].symbol + " is "+data.response[0].price); // Price of EUR/USD is 1.1064;
    }
});

</script>

Errors

There are multiple errors that help you to understand issue with your API response.

CodeDetails
200Successfully
501You have not supplied a valid API Access Key.
502Your account is not active, Please check your email to activate it.
503Your account is suspend for some resons, Please contact us, to activate it.
504Sorry, auth_key parameter missing. Or add your IP in your dashboard->profile
505Sorry, You are not allow to access this API endpoint. Please upgrade your plan
111Sorry you are using demo API key, that has limited id access, To get unlimited access please signup.
112No data or an invalid value has been specified. Data not found.
113Sorry, Something wrong, or an invalid value. Please try again or check your required parameters.
211Your monthly API request limit exceed, Please upgrade your account, If you think this message is error, please contact our support.
212Your account is expire, Please update your payments, If you think this message is error, please contact our support.
213Free user has per mintue limit also per month, you can exceed your per minute limit. Please try again after 1 minute.