Get the current spot price of a commodity (single or batch)
Returns the spot price (the price for immediate delivery) for one commodity that has a spot market: gold, silver, platinum, and palladium (composite: blended live market quotes with bid/ask, refreshed about once a minute on this listing) and WTI, Brent, natural gas, gasoline, and heating oil (assessed: the U.S. EIA official daily spot price). Other commodities have no public spot market and return an error pointing to /commodityprice.
Example code
// Using @orth/sdk - The simplest way to call APIs
// Install: npm install @orth/sdk
import Orthogonal from "@orth/sdk";
const orthogonal = new Orthogonal({
apiKey: process.env.ORTHOGONAL_API_KEY,
});
const output = await orthogonal.run({
api: "api-ninjas",
path: "/v1/commodityspot"
});
console.log(output);Query parameters
The commodity. crude_oil, brent_crude_oil, gasoline_rbob, and heating_oil also accept wti, brent, gasoline, and diesel. (Allowed: gold, silver, platinum, palladium, crude_oil, brent_crude_oil, natural_gas, gasoline_rbob, heating_oil)
ISO 4217 currency code to convert prices into (e.g., EUR, GBP). Defaults to USD.
Target unit, in the same dimension as the commodity's native unit (mass for metals, volume for oil, gasoline and heating oil, energy for natural gas).