Overview
The Agriflux API gives developers access to location-specific agricultural intelligence across Nigeria. It is built for farmers, agribusinesses, cooperatives, and government agricultural agencies.
Every request is built around a Loccode — a unique identifier from the Maiaddy platform that pinpoints a specific geographic area at postcode-level precision. Send a loccode, and the API returns data for that exact location: climate conditions, pest risk, yield forecasts, or supply chain routing.
The four endpoints
NOTE
You must include Content-Type: application/json in every request header.
The Loccode
Every request requires at least one loccode. Understanding how to use it correctly will save you from the most common errors.
What is a loccode?
A loccode is a structured alphanumeric code that maps to a specific postcode-level area in Nigeria. It is generated and validated by the Maiaddy location intelligence platform, which links GPS-confirmed coordinates to a unique code for that location.
Think of it like a postcode, except it maps to a real, GPS-confirmed area rather than a general postal district. Each loccode resolves to a specific state, city, and set of coordinates.
Examples of loccodes used in this document:
- KD10A 4SE
- OY6A 1EZ
- LA11A 2TQ
- LA5A 2YM
- LG01B 2AA
- ABJ 900107
The Loccode must be exact
A loccode must be submitted exactly as it was issued, with correct characters and correct spacing. The API does not correct or guess. Any mistake will cause the request to fail.
There are two types of loccode errors, and they return different status codes:
- 400 Bad Request: The loccode field is missing entirely from the request body.
- 404 Not Found: A loccode was submitted, but it is either formatted incorrectly or, if correctly formatted, does not exist in the database.
In short: 400 means you forgot to include it. 404 means something about the loccode itself is wrong or unregistered.
IMPORTANT
If you are unsure of the exact format for a Loccode, retrieve it from the Maiaddy app. Do not guess or construct one manually.
The Loccode echoed back in a response may look slightly different from what you sent; for example, KD10A 4SE may return as KD10A-4SE. This is only a display difference in the response output. It does not mean the API accepts both formats as input.
Authentication & Requests
API key
An API key is required for every request. Include it in the authorisation header:
Authorization: Bearer YOUR_API_KEYCreate an API Key here.
WARNING
Never put your API key in the client-side code or any publicly visible location (including GitHub). Always make Agriflux API calls from your server. Store your key in an environment variable; never hardcode it.
Request format
Every request to the Agriflux API must include the following headers.
Bearer YOUR_API_KEYapplication/jsonThe request body must be valid JSON. Field names and string values are case-sensitive unless otherwise stated.
Response format
A successful request returns HTTP 200 OK with a JSON body. The response always echoes back the Loccode that was sent. If something goes wrong, the API returns a non-200 status code with an error body. See Error reference for cross-endpoint HTTP semantics and the error JSON envelope. For machine-readable codes per route, see Get Climate errors, Get Pests errors, Get Crop Yield errors, and Supply errors.
Endpoint details
Get Climate by Loccode
Returns current climate and soil conditions for a location; temperature, humidity, rainfall, and soil data along with a plain-language interpretation of each reading written for farmers. The interpretation is ready to display directly to end users.
https://api.maiaddy.com/agriflux/api/v1/data/climate/by-loccode?loccode=KD10A 4SEHeaders
Bearer YOUR_API_KEYapplication/jsonBody — Request parameters
loccodestringYesThe Loccode for the target location. Must be exactly as issued. See The Loccode. Example: KD10A 4SEExample request body
{"loccode": "KD10A 4SE"}Full curl command
curl -X POST \
"https://api.maiaddy.com/agriflux/api/v1/data/climate/by-loccode" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"loccode": "KD10A 4SE"}'Response — 200 OK
{
"loccode": "KD10A 4SE",
"climate_data": [
{
"loccode": "KD10A 4SE",
"state": "Kaduna",
"city": "Kaduna South",
"latitude": 10.814,
"longitude": 7.427,
"temperature_2m": 29.4,
"relative_humidity_2m": 40.0,
"precipitation": 0.0,
"soil_moisture_0_10cm": 0.031,
"soil_moisture_10_40cm": 0.115,
"soil_temperature_0cm": 36.5,
"soil_temperature_6cm": 29.5,
"event_timestamp": "2026-04-09T09:15",
"farmer_interpretation": {
"temperature": "29.4°C — Favourable for rice, vegetables, and legumes.",
"humidity": "40.0% — Dry air. Watch for spider mites and thrips.",
"rainfall": "No rainfall recorded. Irrigation required for any active crop.",
"soil_moisture": "0.031 m³/m³ — Dry soil. Irrigate immediately.",
"soil_temperature": "36.5°C — Very hot topsoil. Mulch to retain moisture.",
"overall_outlook": "Challenging",
"outlook_summary": "Heat stress or severely dry soil. Prioritise irrigation."
}
}
]
}Response fields
loccodestringThe Loccode echoed on the response root (matches the loccode you sent).climate_dataarrayArray of climate records for the location. Typically contains one object.climate_data[].statestringNigerian state for this Loccode.climate_data[].citystringCity or Local Government Area.climate_data[].latitudenumberLatitude of the Loccode area.climate_data[].longitudenumberLongitude of the Loccode area.climate_data[].temperature_2mnumberAir temperature 2 m above ground, in °C.climate_data[].relative_humidity_2mnumberRelative humidity 2 m above ground, as a percentage (0–100).climate_data[].precipitationnumberTotal rainfall in mm: 0.0 means no rainfall recorded.climate_data[].soil_moisture_0_10cmnumberSoil water content at 0–10 cm depth, in m³/m³.climate_data[].soil_moisture_10_40cmnumberSoil water content at 10–40 cm depth, in m³/m³.climate_data[].soil_temperature_0cmnumberSoil surface temperature at 0 cm depth, in °C.climate_data[].soil_temperature_6cmnumberSoil temperature at 6 cm depth, in °C.climate_data[].event_timestampstringISO 8601 timestamp of when the data was recorded.climate_data[].farmer_interpretationobjectPlain-language explanations of each reading, written for farmers. See sub-fields below.farmer_interpretation.temperaturestringWhat the temperature means for crops.farmer_interpretation.humiditystringHumidity reading with pest and irrigation implications.farmer_interpretation.rainfallstringRainfall status and irrigation recommendation.farmer_interpretation.soil_moisturestringSoil moisture level and what action to take.farmer_interpretation.soil_temperaturestringSoil surface temperature and management recommendation.farmer_interpretation.overall_outlookstringOne-word summary: Challenging, Favourable, or Moderate.farmer_interpretation.outlook_summarystringOne sentence on the most urgent action given current conditions.Errors
Get Pests for Crop by Loccode
Returns pest and disease risk information for a location. This endpoint works in two modes depending on whether you include a crop name in the query string.
- With a crop name: Returns a crop-specific pest profile, dominant pests, climate conditions affecting pest activity, and a targeted management recommendation.
- Without a crop name: Returns a general location-level pest overview, active climate conditions, any active pests at the site, and a prompt to add a crop for deeper analysis.
Both modes use the same URL and return 200 OK on success. The difference is in what you send and what you get back.
https://api.maiaddy.com/agriflux/api/v1/monitoring/pests/by-loccode?loccode=OY6A 1EZHeaders
Bearer YOUR_API_KEYapplication/jsonQuery parameters
loccodestringYesThe loccode for the target location. Must be exactly as issued. See The Loccode. Example: OY6A 1EZcropstringNoThe crop to assess pest risk for. When included, the response is tailored to that crop. When omitted, the API returns a general location overview. Example: milletMode A — With a crop name
Example query string
?loccode=OY6A 1EZ&crop=milletFull curl command
curl -G \ "https://api.maiaddy.com/agriflux/api/v1/monitoring/pests/by-loccode" \ -H "Authorization: Bearer YOUR_API_KEY" \ --data-urlencode "loccode=OY6A 1EZ" \ --data-urlencode "crop=millet"
Example response — 200 OK
{
"loccode": "OY6A 1EZ",
"crop": "millet",
"location": "Ibadan North Oyo",
"risk_level": "medium",
"dominant_pests": ["Stalk borer", "Aphids", "Millet head miner"],
"climate_conditions_affecting_pests": ["none currently detected"],
"recommended_action": "Pearl millet is drought-tolerant. Thin to proper spacing to reduce stalk borer."
}Response fields
loccodestringThe Loccode queried.cropstringThe crop name as submitted.locationstringHuman-readable location name (e.g. Ibadan North Oyo).risk_levelstringPest risk level for this crop at this location. Values: low, medium, high.dominant_pestsarray of stringsMost prevalent pests for this crop and location.climate_conditions_affecting_pestsarray of stringsClimate factors driving or suppressing pest activity. Returns "none currently detected" when conditions are safe.recommended_actionstringPractical management recommendation for this crop and pest profile.Mode B — Without a crop name
Example query string
?loccode=OY6A 1EZFull curl command
curl -G \ "https://api.maiaddy.com/agriflux/api/v1/monitoring/pests/by-loccode" \ -H "Authorization: Bearer YOUR_API_KEY" \ --data-urlencode "loccode=OY6A 1EZ"
Example response — 200 OK
{
"loccode": "OY6A 1EZ",
"location": "Ibadan North Oyo",
"state": "Oyo",
"zone": "southwest",
"risk_level": "low",
"active_climate_conditions": [
"high_humidity"
],
"climate_risk_notes": [
"High humidity (>75% RH) favours aphids, whitefly and fungal disease — IITA/NIMET threshold."
],
"dominant_pests_in_location": [
"Aphids (Aphis gossypii)",
"Fungal pathogens (black pod, blight)",
"Whitefly (Bemisia tabaci)",
"Yam beetle (Heteroligus meles)",
"Cutworms (Agrotis spp.)",
"Mango fruit fly (Ceratitis cosyra)",
"Aphids"
],
"crops_at_risk": [
"pepper", "tomato", "cocoa", "maize", "rice", "plantain"
],
"seasonal_alert": "Yam beetle peak. Mango ripening — fruit fly critical.",
"seasonal_key_pests": [
"Yam beetle (Heteroligus meles)",
"Cutworms (Agrotis spp.)",
"Mango fruit fly (Ceratitis cosyra)",
"Aphids"
],
"data_sources": "IITA Pest Management Guides 2023-2025, NIMET, CRIN, NIHORT, FAO Nigeria, ARCN",
"tip": "Include 'crop' for crop-specific IPM advice and risk assessment."
}Response fields (location mode)
loccodestringThe Loccode queried.locationstringHuman-readable location namestatestringNigerian state for this loccodezonestringGeopolitical zone of the location (e.g. southwest, north-central).risk_levelstringOverall pest risk level at this location, independent of any crop. Values: low, medium, high.active_climate_conditionsarray of stringsClimate conditions currently active at the site that may drive pest activity. Example: high_humidity.climate_risk_notesarray of stringsPlain-language explanations of each active climate condition and its pest implications, with the data source threshold cited.dominant_pests_in_locationarray of stringsPests currently active at this location regardless of crop, with scientific names where available.crops_at_riskarray of stringsCrops at elevated risk under current conditions and pest pressure.seasonal_alertstringA short, plain-language summary of the most time-sensitive pest risks for the current season.seasonal_key_pestsarray of stringsThe pests most critical to monitor right now based on season and location.data_sourcesstringThe research and data sources used to generate pest information for this location.tipstringA prompt from the API to include a crop name for crop-specific IPM advice and risk assessment.NOTE — Two response shapes
The response shape is different between the two modes, for example, dominant_pests (crop mode) versus dominant_pests_in_location (location mode). If your application supports both call types, make sure it handles both response shapes. Include crop when you know what the farmer is growing and want specific pest risks and a recommended action.
Omit crop when checking site conditions in general or building a dashboard that shows location-level pest status.
Errors
Get Crop Yield by Loccode
Returns a yield prediction for a specific crop at a given location. The forecast is expressed in multiple units, bags (50 kg), kilograms, and tonnes, and comes with a seasonal suitability note and location-specific growing advice.
https://api.maiaddy.com/agriflux/api/v1/predict/yield/by-loccode?loccode=LA11A 2TQ&crop=RICERequest
Headers
Bearer YOUR_API_KEYapplication/jsonQuery parameters
loccodestringYesThe Loccode for the target location. Must be exactly as issued. See The Loccode. Example: LA11A 2TQcropstringYesThe crop to forecast yield for. Not case-sensitive. Example: RICE or riceExample query string
?loccode=LA11A 2TQ&crop=RICEFull curl command
curl -G \ "https://api.maiaddy.com/agriflux/api/v1/predict/yield/by-loccode" \ -H "Authorization: Bearer YOUR_API_KEY" \ --data-urlencode "loccode=LA11A 2TQ" \ --data-urlencode "crop=RICE"
Response — 200 OK
{
"loccode": "LA11A 2TQ",
"crop": "rice",
"land_size_ha": 1.0,
"location": "Ikeja Lagos",
"yield_prediction": {
"total_yield": "approximately 28 50kg bags from 1.0 hectare(s)",
"unit": "50kg bags",
"total_count": 28.0,
"total_kg": 1400.0,
"total_tonnes": 1.4,
"per_hectare": "approximately 28 50kg bags per hectare",
"tonnes_per_hectare": 1.4
},
"seasonal_note": "Conditions are suitable for the expected growing season.",
"growing_advice": "Drain fields periodically to reduce planthopper breeding. Use certified seed."
}Response fields
loccodestringThe Loccode queried.cropstringThe crop name, normalised to lowercase by the API regardless of how it was submitted.land_size_hanumberLand size in hectares used for the calculation. Currently always 1.0. All yield values are per hectare — multiply by your actual land size to calculate total yield for a larger farm.locationstringHuman-readable location name for the Loccode.yield_predictionobjectThe yield forecast, broken down across multiple units.yield_prediction.total_yieldstringHuman-readable summary of total predicted yield.yield_prediction.unitstringPrimary unit of measurement. Currently: 50kg bags.yield_prediction.total_countnumberTotal number of 50 kg bags predicted.yield_prediction.total_kgnumberTotal yield in kilograms.yield_prediction.total_tonnesnumberTotal yield in metric tonnes.yield_prediction.per_hectarestringHuman-readable per-hectare yield summary.yield_prediction.tonnes_per_hectarenumberYield in metric tonnes per hectare.seasonal_notestringWhether current conditions suit this crop's growing season.growing_advicestringPractical, location-specific cultivation recommendations.Errors
Supply Farm Produce by Loccode
Returns logistics information for moving produce between two locations. Send an origin Loccode and a destination Loccode, and the API returns the optimal transport route, the nearest distribution hub at the destination, estimated distance and travel time, and a breakdown of which crops will survive the journey and which will not.
https://api.maiaddy.com/agriflux/api/v1/logistics/supplyRequest
Headers
Bearer YOUR_API_KEYapplication/jsonBody — Request parameters
origin_loccodestringYesThe Loccode for the starting location (farm, warehouse, or collection point). Must be exactly as issued. Example: KD10A 4SEdestination_loccodestringYesThe Loccode for the destination (market, distribution centre, or port). Must be exactly as issued. Example: LA5A 2YMExample request body
{"origin_loccode": "KD10A 4SE", "destination_loccode": "LA5A 2YM"}Full curl command
curl -X POST \
"https://api.maiaddy.com/agriflux/api/v1/logistics/supply" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"origin_loccode": "KD10A 4SE", "destination_loccode": "LA5A 2YM"}'Response — 200 OK
{
"origin_loccode": "KD10A 4SE",
"destination_loccode": "LA5A 2YM",
"origin": { "state": "Kaduna", "city": "Kaduna South", "latitude": 10.814, "longitude": 7.427 },
"destination": { "state": "Lagos", "city": "Apapa", "latitude": 6.449136, "longitude": 3.325697 },
"route": {
"distance_km": 748.2,
"estimated_transit_hours": 6.0,
"transport_mode": "Warehouse/truck",
"hub_type": "Port",
"hub_description": "Apapa Port - largest container port in West Africa",
"data_source": "OpenStreetMap"
},
"crops_that_survive_transit": ["cassava","cocoa_wet","cowpea","groundnut","kola_nut",
"millet","pepper","plantain","rice","rubber_latex","sorghum","watermelon","yam"],
"crops_that_will_spoil": ["leafy_veg", "tomato"]
}Response fields
origin_loccodestringThe origin Loccode as submitted.destination_loccodestringThe destination Loccode as submitted.originobjectResolved location details for the origin.origin.statestringState name of the origin.origin.citystringCity or LGA name of the origin.origin.latitudenumberLatitude of the origin.origin.longitudenumberLongitude of the origin.destinationobjectResolved location details for the destination.destination.statestringState name of the destination.destination.citystringCity or LGA name of the destination.destination.latitudenumberLatitude of the destination.destination.longitudenumberLongitude of the destination.routeobjectLogistics details for the route.route.distance_kmnumberEstimated road distance in kilometres.route.estimated_transit_hoursnumberEstimated travel time in hours.route.transport_modestringRecommended transport mode. Example: Warehouse/truck.route.hub_typestringType of distribution hub at the destination. Examples: Port, Market, Warehouse.route.hub_descriptionstringDescription of the distribution hub.route.data_sourcestringMapping data source used to calculate the route. Example: OpenStreetMap.crops_that_survive_transitarray of stringsCrops expected to remain viable for the full journey.crops_that_will_spoilarray of stringsCrops expected to degrade significantly in transit. Consider special handling, refrigeration, or an alternative route.Errors
Error reference
This section lists HTTP error patterns the Agriflux API can return across any endpoint. Each endpoint also documents its own error codes and remediation copy under its Errors subsection. Missing or invalid API keys typically produce 401 Unauthorized with the same JSON error envelope.
HTTP status codes — all endpoints
Error response examples
When an error occurs, the API returns a JSON body alongside the error status code:
{
"error": {
"code": "ERROR_CODE_STRING",
"message": "A plain-language description of what went wrong.",
"details": "Optional: additional context, such as which field failed."
}
}Quick reference
Endpoints at a glance
NOTE
All requests require Content-Type: application/json and Authorization: Bearer YOUR_API_KEY.
Supported crop names
The following crop names are accepted by the pests and yield endpoints. Values are not case-sensitive.
yam cassava maize rice groundnut sorghum cowpea millet tomato pepper cocoa palm plantain cocoyam kola_nut mango_green watermelon pineapple onion_dried bambara_groundnut rubber_latex
Further Resources
Everything you need to go further with the Agriflux API.
SDK documentation
SDKs for Python and Java are available and cover all four endpoints. The SDK documentation provides installation instructions, authentication setup, and working code examples for every endpoint — as a companion to this API reference.
The Loccode
Loccodes are generated and validated by the Maiaddy location intelligence platform. Retrieve them from the Maiaddy app, do not guess or construct one manually. The API returns 404 for any Loccode that is malformed or unregistered.
Getting help
For bug reports, feature requests, or integration questions, contact the Maiaddy team directly.
- Email: developer@maiaddy.com
- Web: maiaddy.com