Introduction

OilpriceAPI.com is a simple API for fetching live and historical oil price data.

Endpoints

All end points can be called using the following base url:

https://api.oilpriceapi.com/v1/prices

So as an example, to access the latest oil price the full request URL would be:

https://api.oilpriceapi.com/v1/prices/latest

The endpoint being - /latest

Below is a list of all available endpoints:

/latest

This endpoint returns the latest available oil price.

Example cURL request:

curl https://api.oilpriceapi.com/v1/prices/latest \
-H 'Authorization: Token YOUR_API_TOKEN' \
-H 'Content-Type: application/json'

Note YOUR_API_TOKEN needs to be replaced with your own API token.

Example response:

{
    "status": "success",
    "data": {
        "price": 80.29,
        "formatted": "$80.29",
        "currency": "USD",
        "code": "OIL_BRENT_USD",
        "created_at": "2018-10-17T20:14:05.698Z"
    }
}

/past_day

This endpoint returns all oil price data available within the last 24 hours.

Example cURL request:

curl https://api.oilpriceapi.com/v1/prices/past_day \
-H 'Authorization: Token YOUR_API_TOKEN' \
-H 'Content-Type: application/json'

Note YOUR_API_TOKEN needs to be replaced with your own API token.

Example response:

{
    "status": "success",
    "data": {
        "prices": [
            {
                "price": 82.73,
                "formatted": "$82.73",
                "currency": "USD",
                "code": "OIL_BRENT_USD",
                "created_at": "2018-10-10T20:39:05.283Z"
            },
            {
                "price": 82.71,
                "formatted": "$82.71",
                "currency": "USD",
                "code": "OIL_BRENT_USD",
                "created_at": "2018-10-10T20:40:09.823Z"
            },
            {
                "price": 82.46,
                "formatted": "$82.46",
                "currency": "USD",
                "code": "OIL_BRENT_USD",
                "created_at": "2018-10-10T20:41:05.961Z"
            },
            ...
        ]
    }
}

/past_week

This endpoint returns all oil price data available within the last 7 days.

Example cURL request:

curl https://api.oilpriceapi.com/v1/prices/past_week \
-H 'Authorization: Token YOUR_API_TOKEN' \
-H 'Content-Type: application/json'

Note YOUR_API_TOKEN needs to be replaced with your own API token.

Example response:

{
    "status": "success",
    "data": {
        "prices": [
            {
                "price": 82.73,
                "formatted": "$82.73",
                "currency": "USD",
                "code": "OIL_BRENT_USD",
                "created_at": "2018-10-10T20:39:05.283Z"
            },
            {
                "price": 82.71,
                "formatted": "$82.71",
                "currency": "USD",
                "code": "OIL_BRENT_USD",
                "created_at": "2018-10-10T20:40:09.823Z"
            },
            {
                "price": 82.46,
                "formatted": "$82.46",
                "currency": "USD",
                "code": "OIL_BRENT_USD",
                "created_at": "2018-10-10T20:41:05.961Z"
            },
            ...
        ]
    }
}

/past_month

This endpoint returns all oil price data available within the last 30 days.

Example cURL request:

curl https://api.oilpriceapi.com/v1/prices/past_month \
-H 'Authorization: Token YOUR_API_TOKEN' \
-H 'Content-Type: application/json'

Note YOUR_API_TOKEN needs to be replaced with your own API token.

Example response:

{
    "status": "success",
    "data": {
        "prices": [
            {
                "price": 82.73,
                "formatted": "$82.73",
                "currency": "USD",
                "code": "OIL_BRENT_USD",
                "created_at": "2018-10-10T20:39:05.283Z"
            },
            {
                "price": 82.71,
                "formatted": "$82.71",
                "currency": "USD",
                "code": "OIL_BRENT_USD",
                "created_at": "2018-10-10T20:40:09.823Z"
            },
            {
                "price": 82.46,
                "formatted": "$82.46",
                "currency": "USD",
                "code": "OIL_BRENT_USD",
                "created_at": "2018-10-10T20:41:05.961Z"
            },
            ...
        ]
    }
}

/past_year

This endpoint returns all oil price data available within the last 365 days.

Example cURL request:

curl https://api.oilpriceapi.com/v1/prices/past_year \
-H 'Authorization: Token YOUR_API_TOKEN' \
-H 'Content-Type: application/json'

Note YOUR_API_TOKEN needs to be replaced with your own API token.

Example response:

{
    "status": "success",
    "data": {
        "prices": [
            {
                "price": 82.73,
                "formatted": "$82.73",
                "currency": "USD",
                "code": "OIL_BRENT_USD",
                "created_at": "2018-10-10T20:39:05.283Z"
            },
            {
                "price": 82.71,
                "formatted": "$82.71",
                "currency": "USD",
                "code": "OIL_BRENT_USD",
                "created_at": "2018-10-10T20:40:09.823Z"
            },
            {
                "price": 82.46,
                "formatted": "$82.46",
                "currency": "USD",
                "code": "OIL_BRENT_USD",
                "created_at": "2018-10-10T20:41:05.961Z"
            },
            ...
        ]
    }
}