Skip to content

Use An API To Obtain Platinum Rates In PHP

Are you looking for an API that provides you platinum rates in PHP? This article will be very useful to you.

Due to COVID-19 restrictions, the global platinum market is expected to drop 18% by 2020. In 20’21, global platinum demand for all automotive, jewelry, and industrial applications was a favorable year over year, as it had been for the previous three quarters. While a surplus is expected in 2022.

Use An API To Obtain Platinum Rates In PHP

Because of all of these considerations, you should be aware that platinum rates may be critical to the success of your business. To access this information in PHP, you may utilize an API, which is a user interface that exposes data acquired from another device. This gives you data in a short amount of time. But, not every one of them provides this information in PHP.

Why PHP

PHP (Hypertext Preprocessor) is a general-purpose programming language that may be used to create 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 websites without relying on data from other files. It has advanced as a consequence of regular upgrades that add new features and expand its capabilities.

As a result, we recommend that you use Metals-API, which is one of the most well-known and comprehensive APIs for precious metals pricing, to help you make investment decisions. This API allows you to track platinum rates in real-time as well as their fluctuations over time.

Use An API To Obtain Platinum Rates In PHP

Follow these procedures to get your API key:

  1. You may get an API key at www.metals-API.com.
  2. On the website’s list, look for the platinum symbol (XPT).
  3. Before utilizing the API, insert these metal and currency symbols into the list. You may also choose between a variety of programming languages and rate types, such as historical and spot pricing.
  4. Then, hit the “Run” button.

The API will display the following information:

// set API Endpoint and API key 
$endpoint = 'latest';
$access_key = 'API_KEY';

// Initialize CURL:
$ch = curl_init('https://metals-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'];

Which Are The Benefits Of Metals-API

Thousands of developers, small businesses, and large corporations frequent Metals-API. This API is used by firms like Barrick Gold, Chainlink, and Glencore, to name a few. They may use this tool to quickly and simply determine the current global market value of any metal.

Metals-API is the most reliable source for real-time precious metals rates since it receives data every minute from roughly 15 reputable data sources, such as financial institutions. JSON, Python, and PHP are just a few of the programming languages that may be used to construct real-time systems and services. There are over 170 commodities and currencies to pick from.

Published inAppsApps, technologyTechnology
%d bloggers like this: