Loading...

Developer API

API Documentation

Integrate Our Data

Power your applications, research, and services with our reliable, real-time agricultural price data. Our REST API is simple, powerful, and easy to integrate.

Getting Started

To get started, you will need an API key. Public read-only access is available for free for low-volume use. Please contact us for high-volume or commercial keys.

Your public API Key for testing: SECRET_API_KEY_HERE_12345 (Note: This key is for read-only access).

All requests should be made to the base URL: http://localhost/agri_price_api/api/ (Update this to your live domain).


Endpoint: Get Single Commodity Details

Retrieve the details for a single commodity by its ID.

URL: /commodity-detail.php

Method: GET

Required Parameters: id

Example Request:

curl "http://localhost/agri_price_api/api/commodity-detail.php?id=1"

Endpoint: Get Prices

This is the primary endpoint for fetching the latest commodity prices.

URL: /prices.php

Method: GET

Example Request:

curl http://localhost/agri_price_api/api/prices.php
Query Parameters (Optional)
  • country_id: Filter prices by a specific country ID.
  • market_id: Filter prices by a specific market ID.
  • commodity_id: Filter prices for a specific commodity ID.

Example with filter:

curl "http://localhost/agri_price_api/api/prices.php?commodity_id=1&market_id=3"

Endpoint: Get Historical Prices

Retrieve historical price data for a specific commodity in a specific market (defaults to last 30 days).

URL: /historical-prices.php

Method: GET

Required Parameters: commodity_id, market_id

Optional Parameters: start_date (YYYY-MM-DD), end_date (YYYY-MM-DD)

Example Request:

curl "http://localhost/agri_price_api/api/historical-prices.php?commodity_id=1&market_id=3"

Endpoint: Get Markets

Retrieve a list of all available markets.

URL: /markets.php

Method: GET

Example Request:

curl http://localhost/agri_price_api/api/markets.php

Endpoint: Get Commodities

Retrieve a list of all available commodities and their categories.

URL: /commodities.php

Method: GET

Example Request:

curl http://localhost/agri_price_api/api/commodities.php