Skip to content

Try This API To Get Palm Oil Rates In PHP

If you’re looking for a way to acquire palm oil prices employing PHP, you should read this article. 

Palm oil is a vegetable oil made from the fruit of the oil palm tree. It is used in the production of food, cosmetics, and biofuel. Furthermore, palm oil accounted for almost 33% of all global oils produced from oil crops in 2014.

Crude palm oil and palm kernel oil are the two types of oil that can be generated. Squeezing the fleshy fruit yields crude palm oil, whilst crushing the kernel, or the stone in the middle of the fruit, yields palm kernel oil. Despite the fact that Indonesia and Malaysia produce more than 85% of the world’s palm oil, there are 42 other countries that produce it.

Palm oil is found in practically everything, accounting for more than half of all packaged products in supermarkets, including food, personal care, and cleaning supplies. It’s also used in animal feed and as a biofuel in various parts of the world.

Try This API To Get Palm Oil Rates In PHP

If you’re thinking of investing in something like this, you should be aware of how important it is to keep up with market prices. This could be the event that causes your investments to go in a different direction. If you don’t keep an eye on the commodity and observe how it performs in the market, you can wind up with poor outcomes and lose money.

So, if you’re curious about the palm oil industry and its daily price, consider Commodities-API, a programmatic interface that gets data from a location and returns it to the person who made the API request. This is a common feature on many websites, and it makes things a lot easier when you need updated information right away.

The majority of these responses use JSON and Python, but we’ll focus on PHP in this article.

Why is PHP (cURL) used?

The PHP (Hypertext Preprocessor) programming language is a well-known computer language for creating dynamic and interactive web pages. It was one of the first server-side languages to be integrated into HTML, making it easy to add functionality to web pages without having to access data from separate files.

It may be used in any project because it is an open-source language that allows developers to alter its structure.

How does Commodities-API work?

The best opening is always commodities-api.com. This is a platform where you can keep track of the pricing of a range of products, including palm oil. You’ll be able to forecast prices and convert them into your selected currency in this manner.

This is a very safe software tool because it gathers data from banks and the stock market and verifies its accuracy. The data is returned to you with a precision of 2 decimal points and in a number of programming languages once you submit an API call. Furthermore, this application uses bank-grade 256-bit SSL encryption to secure your connection.

Currency and commodity price conversions use the same API endpoints, and they can convert any amount from one currency to another, from one commodity to another, or from any currency to any currency.

To use it, you need to:

1. Go to www.commodities-api.com and sign in to get your API key

2. Look for the symbols of Palm Oil (CPO) and the currency of choice

3. Once you have them, insert them both and make the API call

4. The software will give you different answers, look for the PHP one between them. 

The answer in PHP will be something like this:

// set API Endpoint and API key 

$endpoint = ‘latest’;

$access_key = ‘API_KEY’;

// Initialize CURL:

$ch = curl_init(‘https://commodities-api.com/api/’.$endpoint.’?access_key=’.$access_key.”);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// Store the data:

$json = curl_exec($ch);

curl_close($ch);

// Decode JSON response:

$exchangeRates = json_decode($json, true);

// Access the exchange rate values, e.g. GBP:

echo $exchangeRates[‘rates’][‘GBP’];


Also published on Medium.

Published inAppsTechnology
%d bloggers like this: