← Back to API Ninjas
Get historical commodity prices
Returns a historical price series for a commodity over an optional Unix start/end range and interval. Requires a `name`. For the latest price use /commodityprice.
API Ninjas·$0.001 per call
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/commoditypricehistorical",
query: {
"name": "example"
}
});
console.log(output);Query parameters
namerequired
string
Name of commodity.
period
string
Time interval between data points. (Allowed: 1m, 5m, 15m, 30m, 1h, 4h, 1d) (Default: 1h)
start
number
Start timestamp in Unix format.
end
number
End timestamp in Unix format.