Get current commodity price (single or batch)
Returns the current price for a single commodity (`name`). Optional `currency` and `unit` parameters convert the response from the native USD/USX quote into any supported currency and unit.
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/commodityprice"
});
console.log(output);Query parameters
Name of a single commodity. (Allowed: gold, soybean_oil, wheat, platinum, micro_silver, lean_hogs, corn, oat, aluminum, soybean_meal, silver, soybean, lumber, live_cattle, sugar, natural_gas, crude_oil, orange_juice, coffee, cotton, copper, micro_gold, feeder_cattle, rough_rice, palladium, cocoa, brent_crude_oil, gasoline_rbob, heating_oil, class_3_milk)
ISO 4217 currency code to convert the price into (e.g., EUR, GBP, INR). When provided, USX prices are first normalized to USD before conversion. Defaults to the native USD/USX quote.
Target mass/volume/energy unit to convert the price into (e.g., kg, g, lb, metric_ton, liter). Bushel and board_feet are commodity-specific and cannot be cross-converted.