Skip to content

Get Petroleum Rates For Your Javascript Project With An API

Crude oil prices move the world around. And you need to follow it up.

It’s already been more than 150 years since the beginning of the Second Industrial Revolution. And, as everyone knows, petroleum played a major role in the industrialization process.

That is to say, that we are surrounded by crude oil derivates. From consumption products to the energy we use every day. 

What Is It?

First, let’s define crude oil as a mixture of hydrocarbons found in natural subsurface reservoirs that remains liquid after passing through surface separating facilities.

Because it is a finite resource, it´s a nonrenewable resource that cannot be replaced naturally at the rate at which humans utilize it.

petroleum ship

Investing

However, if you’re looking to invest in this industry, you should be aware that staying up to speed on crude oil rates is critical to your success. 

Moreover, it’s important to pay attention to spot prices. Indeed, an API is the most convenient way to obtain such information. That way, when you make a request for spot pricing for a specified commodity, the interface will return the expected result.

Commodities-API

Emerging market investments change in value from one moment to the next. As a result, adopting an API like Commodities-API can be extremely beneficial.

Furthermore, this online API delivers precise rate data in a variety of currencies for a large range of commodities.

Commodities-API began as a simple, minimalist Open-Source API for recent and historical prices from financial institutions.

commodities website

Encrypted

The Commodities-API uses bank-grade 256-bit SSL security to protect your connection.

Similarly, thousands of developers, small enterprises, and large corporations use this on a daily basis. This API is the most popular site for commodity rates because of its reliable data sources and 6+ years of experience.

Refreshed

The API can offer real-time commodity data with a precision of two decimal points and a frequency of up to every 60 seconds.

Finally, Commodities-API is built on a robust back-end architecture that ensures high availability and response times of less than 50 milliseconds.

JavaScript

javascript

Because it publishes results in JavaScript Object Notation or JSON, Commodities-API is one of the best and most popular among programmers.

A text-based structured data encoding standard based on JavaScript object syntax. It’s frequently used to deliver data in web applications.

A simple jQuery.ajax example for collecting exchange rate data from the Commodities-API API’s newest endpoint:

JavaScript (jQuery.ajax)

Real-time rates: Find below a simple jQuery.ajax example for getting exchange rate data via the Commodities-API API’s latest endpoint.

// set endpoint and your access key
endpoint = 'latest'
access_key = 'API_KEY';

// get the most recent exchange rates via the "latest" endpoint:
$.ajax({
url: 'https://commodities-api.com/api/' + endpoint + '?access_key=' + access_key,   
dataType: 'jsonp',
success: function(json) {

// exchange rata data is stored in json.rates
alert(json.rates.GBP);

// base currency is stored in json.base
alert(json.base);

// timestamp can be accessed in json.timestamp
alert(json.timestamp);

}
});

Also published on Medium.

Published inAppsTechnology

Be First to Comment

Leave a Reply

%d bloggers like this: