Reference Tables API
The FPMA API provides several reference tables that can be used to retrieve, create, update, and delete information related to price types, exchange rates, markets, commodities, sources, and measurement units. These reference tables are essential for understanding the context and details of the price data available through the FPMA API.
General Notes
- GET methods are publicly accessible.
- POST, PUT, PATCH, and DELETE methods require an access token obtained from the authentication API.
Authentication
To perform POST, PUT, PATCH, or DELETE operations on the reference table endpoints, you need to authenticate using the following API:
Login API
URL: [POST] https://fpma.fao.org/giews/v4/global/api/token/
Body Parameters:
{
"username": "your-username",
"password": "your-password"
}
Example Response:
{
"refresh": "eyJ0eXAiOiJKV1QiLCJh.eyJ0b2t…………",
"access": "eyJ0eXAiOiJKV1QiLCJhbGciOi…………."
}
Use the access token from the response as the Bearer token in the Authorization header for POST, PUT, PATCH, and DELETE requests.
Endpoints Overview
Each reference table has endpoints that support the following operations:
- GET /Endpoint/: Fetch all records.
- GET /Endpoint/{id}/: Fetch a specific record by ID.
- POST /Endpoint/: Create a new record.
- PUT /Endpoint/{id}/: Update a specific record by ID.
- PATCH /Endpoint/{id}/: Partially update a specific record by ID.
- DELETE /Endpoint/{id}/: Delete a specific record by ID.
Endpoints
| Endpoint | Description |
|---|---|
| PriceType | Information about different types of prices available. |
| FxRate | Current and historical exchange rates. |
| Cpi | Consumer Price Index (CPI) data. |
| Market | Market information including location and type. |
| Commodity | Details about commodities covered by the FPMA. |
| Source | Information about data sources. |
| MeasureUnit | Measurement units used in the FPMA data. |
Example Endpoint
The Commodity endpoint provides details about the commodities tracked in the FPMA database.
Base URL:
https://fpma.fao.org/giews/v4/global/price_module/api/v1/Commodity/
GET List
Request:
GET /Commodity/
Sample Request:
curl -X GET "https://fpma.fao.org/giews/v4/global/price_module/api/v1/Commodity/"
Sample Response:
[
{
"id": 1,
"name": "Maize",
"hs_code": "100590",
"category": "Cereals"
},
{
"id": 2,
"name": "Wheat",
"hs_code": "100190",
"category": "Cereals"
}
]
GET Specific Entry by ID
Request:
GET /Commodity/{id}/
Sample Request:
curl -X GET "https://fpma.fao.org/giews/v4/global/price_module/api/v1/Commodity/1/"
Sample Response:
{
"id": 1,
"name": "Maize",
"hs_code": "100590",
"category": "Cereals"
}
POST Create New Entry
Request:
POST /Commodity/
Sample Request:
curl -X POST "https://fpma.fao.org/giews/v4/global/price_module/api/v1/Commodity/" \
-H "Authorization: Bearer your-access-token" \
-H "Content-Type: application/json" \
-d '{
"commodity_name": "Barley",
"commodity_hs_code": "100300"
# Other complete params
}'
PUT Update Existing Entry
Request:
PUT /Commodity/{id}/
Sample Request:
curl -X PUT "https://fpma.fao.org/giews/v4/global/price_module/api/v1/Commodity/1/" \
-H "Authorization: Bearer your-access-token" \
-H "Content-Type: application/json" \
-d '{
"commodity_id": 1,
"commodity_name": "Barley",
"commodity_hs_code": "100300"
# Other complete params
}'
PATCH Partially Update Existing Entry
Request:
PATCH /Commodity/{id}/
Sample Request:
curl -X PATCH "https://fpma.fao.org/giews/v4/global/price_module/api/v1/Commodity/1/" \
-H "Authorization: Bearer your-access-token" \
-H "Content-Type: application/json" \
-d '{
"commodity_id": 1,
"commodity_name": "Barley"
}'
DELETE Remove Entry
Request:
DELETE /Commodity/{id}/
Sample Request:
curl -X DELETE "https://fpma.fao.org/giews/v4/global/price_module/api/v1/Commodity/1/" \
-H "Authorization: Bearer your-access-token"
Other Endpoints
The following endpoints follow the same structure as the Commodity endpoint:
- PriceType
- FxRate
- Cpi
- Market
- Source
- MeasureUnit
For each of these endpoints, replace /Commodity/ in the URLs with the appropriate endpoint name (/PriceType/, /FxRate/, /Cpi/, /Market/, /Source/, or /MeasureUnit/).