Worked Examples of connecting to, and receiving data back from the AHDB RB209 Web API Application
These examples all contain four sections:
• The first contains details on the scenario that the example is modeling.
• The second is how to structure the data input for collating data together in the required format to match the scenario. Note that all classes within the input structure need to be provided even if there is no data to provide within them.
• The third is example code in C# for calling the main endpoint of the API with the input data structure attached.
• While the last is the data output returned from the call to the API. Note that these have been condensed for brevity just to show the relevant sections for the example.
• The first contains details on the scenario that the example is modeling.
• The second is how to structure the data input for collating data together in the required format to match the scenario. Note that all classes within the input structure need to be provided even if there is no data to provide within them.
• The third is example code in C# for calling the main endpoint of the API with the input data structure attached.
• While the last is the data output returned from the call to the API. Note that these have been condensed for brevity just to show the relevant sections for the example.
Example 1 - Arable
• The crop to be grown is winter barley for feed, in England and Wales.
• Grown on a sandy loam soil over clay (medium).
• Average rainfall of 650 mm (Table 4.3, SNS = 1).
• Previous crop was winter wheat.
• Expected yield of 8 t/ha (+1.5 t/ha, +30 kg N/ha).
• Table 4.18: 170 kg N/ha.
• + 30 kg N/ha = 200 kg N/ha.
• Grown on a sandy loam soil over clay (medium).
• Average rainfall of 650 mm (Table 4.3, SNS = 1).
• Previous crop was winter wheat.
• Expected yield of 8 t/ha (+1.5 t/ha, +30 kg N/ha).
• Table 4.18: 170 kg N/ha.
• + 30 kg N/ha = 200 kg N/ha.
Data Input for Example 1
{
"field": {
"fieldType": 1,
"multipleCrops": false,
"arable": [
{
"cropOrder": 1,
"cropGroupId": 0,
"cropTypeId": 1,
"cropInfo1Id": 1,
"cropInfo2Id": 1,
"sowingDate": "2025-09-01T00:00:00",
"expectedYield": 8.0
}
],
"grassland": {},
"grass": {},
"soil": {
"soilTypeId": 2,
"nvzActionProgrammeId": 1,
"soilAnalyses": [
{
"soilAnalysisDate": "2026-02-01T00:00:00",
"soilPh": 6.5,
"sulphurDeficient": false,
"snsIndexId": null,
"pIndexId": 1,
"kIndexId": 0,
"mgIndexId": null,
"snsMethodologyId": null,
"pMethodologyId": 1,
"kMethodologyId": 4,
"mgMethodologyId": 4
}
]
},
"harvestYear": 2026,
"area": 1.0,
"postcode": "AB12 3CD",
"altitude": 0,
"rainfallAverage": 650.0,
"excessWinterRainfall": 0.0,
"mannerManures": false,
"organicMaterials": [],
"mannerOutputs": [],
"previousCropping": {
"previousGrassId": 1,
"previousCropGroupId": 0,
"previousCropTypeId": 0,
"grassHistoryId": null
},
"countryId": 1
},
"nutrients": {
"nitrogen": true,
"phosphate": true,
"potash": true,
"magnesium": true,
"sodium": true,
"sulphur": true,
"lime": true
},
"totals": false,
"referenceValue": "Winter Barley feed crop"
}
C# code to connect to API
//API Connection Details
var accessToken = "..."; //Your access token
var apiConnection = "https://rb209api.ahdb.org.uk";
//Serialize input details
var content = new StringContent(JsonConvert.SerializeObject(dataInput), Encoding.UTF8, "application/json");
//Add Authentication details
var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
//Connect to API & retrieve data
var url = $"{apiConnection}/api/Recommendation/recommendations";
var task = client.PostAsync(url, content);
var returnedData = task.Result.Content.ReadAsStringAsync().Result;
//Deserialize output details
var dataOutputDetails = JsonConvert.DeserializeObject<DataOutput>(returnedData);
Data Output for Example 1
{
"calculations": [
{
"nutrientId": 0,
"type": "A",
"sequenceId": 1,
"defoliationId": 1,
"indexPh": "1",
"recommendation": 170.0,
"applied": null,
"cropNeed": 170,
"breakdown": false,
"description": "Nitrogen Recommendation (kg/ha) based on crop group, crop type, crop info 1, soil type and soil nitrogen index.",
"snsStatus": null,
"totalAvailable": null
},
{
"nutrientId": 0,
"type": "A",
"sequenceId": 1,
"defoliationId": 1,
"indexPh": "1",
"recommendation": 30.0,
"applied": null,
"cropNeed": 30,
"breakdown": false,
"description": "Nitrogen Yield Adjustment for Winter Barley Feed",
"snsStatus": null,
"totalAvailable": null
},
{
"nutrientId": 0,
"type": "A",
"sequenceId": 1,
"defoliationId": 1,
"indexPh": "1",
"recommendation": 200,
"applied": null,
"cropNeed": 200,
"breakdown": true,
"description": "Total",
"snsStatus": null,
"totalAvailable": null
},
{
"nutrientId": 1,
"type": "A",
"sequenceId": 1,
"defoliationId": 1,
"indexPh": null,
"recommendation": 55.0,
"applied": null,
"cropNeed": 55,
"breakdown": false,
"description": "Phosphate Recommendation (kg/ha) based on crop group, crop type, crop info 1 and phosphate soil index.",
"snsStatus": null,
"totalAvailable": null
},
{
"nutrientId": 1,
"type": "A",
"sequenceId": 1,
"defoliationId": 1,
"indexPh": null,
"recommendation": 12.8,
"applied": null,
"cropNeed": 13,
"breakdown": false,
"description": "Phosphate Recommendation (kg/ha) based on crop yield",
"snsStatus": null,
"totalAvailable": null
},
{
"nutrientId": 1,
"type": "A",
"sequenceId": 1,
"defoliationId": 1,
"indexPh": "2",
"recommendation": 70,
"applied": null,
"cropNeed": 70,
"breakdown": true,
"description": "Total",
"snsStatus": null,
"totalAvailable": null
},
{
"nutrientId": 2,
"type": "A",
"sequenceId": 1,
"defoliationId": 1,
"indexPh": null,
"recommendation": 70.0,
"applied": null,
"cropNeed": 70,
"breakdown": false,
"description": "Potash Recommendation (kg/ha) based on crop group, crop type, crop info 1 and potash soil index.",
"snsStatus": null,
"totalAvailable": null
},
{
"nutrientId": 2,
"type": "A",
"sequenceId": 1,
"defoliationId": 1,
"indexPh": null,
"recommendation": 15.8,
"applied": null,
"cropNeed": 16,
"breakdown": false,
"description": "Potash Recommendation (kg/ha) based on crop yield",
"snsStatus": null,
"totalAvailable": null
},
{
"nutrientId": 2,
"type": "A",
"sequenceId": 1,
"defoliationId": 1,
"indexPh": "2",
"recommendation": 85,
"applied": null,
"cropNeed": 85,
"breakdown": true,
"description": "Total",
"snsStatus": null,
"totalAvailable": null
},
{
"nutrientId": 3,
"type": "A",
"sequenceId": 1,
"defoliationId": 1,
"indexPh": null,
"recommendation": 0.0,
"applied": null,
"cropNeed": 0,
"breakdown": false,
"description": "Magnesium Recommendation (kg/ha) based on crop group, crop type and magnesium soil index",
"snsStatus": null,
"totalAvailable": null
},
{
"nutrientId": 3,
"type": "A",
"sequenceId": 1,
"defoliationId": 1,
"indexPh": "2",
"recommendation": 0,
"applied": null,
"cropNeed": 0,
"breakdown": true,
"description": "Total",
"snsStatus": null,
"totalAvailable": null
},
{
"nutrientId": 4,
"type": "A",
"sequenceId": 1,
"defoliationId": 1,
"indexPh": null,
"recommendation": 0,
"applied": null,
"cropNeed": 0,
"breakdown": false,
"description": "Sodium Recommendation (Na2O kg/ha) based on crop type, crop into 1 id, soil type and potash index.",
"snsStatus": null,
"totalAvailable": null
},
{
"nutrientId": 4,
"type": "A",
"sequenceId": 1,
"defoliationId": 1,
"indexPh": null,
"recommendation": 0,
"applied": null,
"cropNeed": 0,
"breakdown": true,
"description": "Total",
"snsStatus": null,
"totalAvailable": null
},
{
"nutrientId": 5,
"type": "A",
"sequenceId": 1,
"defoliationId": 1,
"indexPh": null,
"recommendation": 50.0,
"applied": null,
"cropNeed": 50,
"breakdown": false,
"description": "Sulphur Recommendation (SO3 kg/ha) based on crop group and crop type.",
"snsStatus": null,
"totalAvailable": null
},
{
"nutrientId": 5,
"type": "A",
"sequenceId": 1,
"defoliationId": 1,
"indexPh": null,
"recommendation": 50,
"applied": null,
"cropNeed": 50,
"breakdown": true,
"description": "Total",
"snsStatus": null,
"totalAvailable": null
},
{
"nutrientId": 6,
"type": "A",
"sequenceId": 1,
"defoliationId": 1,
"indexPh": null,
"recommendation": 0,
"applied": null,
"cropNeed": 0,
"breakdown": false,
"description": "Lime Recommendation (t/ha) based on soil pH, soil type and current crop type.",
"snsStatus": null,
"totalAvailable": null
},
{
"nutrientId": 6,
"type": "A",
"sequenceId": 1,
"defoliationId": 1,
"indexPh": "6.5",
"recommendation": 0,
"applied": null,
"cropNeed": 0,
"breakdown": true,
"description": "Total",
"snsStatus": null,
"totalAvailable": null
}
],
"adviceNotes": [
{
"nutrientId": 0,
"sequenceId": 1,
"note": "Apply three splits, with 40% during late tillering in mid-February/early March, 40% at GS30–31 and 20% at GS32."
},
{
"nutrientId": 0,
"sequenceId": 1,
"note": "Reduce the recommendation by 25 kg N/ha if the lodging risk is high."
},
{
"nutrientId": 0,
"sequenceId": 1,
"note": "Where the expected yield is greater than 6.5 t/ha, the N recommendation has been increased by 10 kg N/ha for each 0.5 t/ha additional yield above 6.5 t/ha up to a maximum of 11 t/ha. Where the expected yield is below 6.5 t/ha, the N recommendation has been reduced by 10 kg N/ha for each 0.5 t/ha below 6.5 t/ha."
},
{
"nutrientId": 1,
"sequenceId": 1,
"note": "A new soil analysis is needed. Use of soil analysis results that are more than 4-5 years old may give misleading recommendations."
},
{
"nutrientId": 1,
"sequenceId": 1,
"note": "Phosphate may be applied when convenient (see the Nutrient Management Guide)."
},
{
"nutrientId": 2,
"sequenceId": 1,
"note": "A new soil analysis is needed. Use of soil analysis results that are more than 4-5 years old may give misleading recommendations."
},
{
"nutrientId": 2,
"sequenceId": 1,
"note": "Potash may be applied when convenient (see the Nutrient Management Guide)."
},
{
"nutrientId": 3,
"sequenceId": 1,
"note": "A new soil analysis is needed. Use of soil analysis results that are more than 4-5 years old may give misleading recommendations."
},
{
"nutrientId": 5,
"sequenceId": 1,
"note": "Where deficiency has been recognised or is expected in winter- or spring-sown cereals, apply 25-50 kg/ha SO3 as a sulphate-containing fertiliser between early March to the end of April for all cereals, taking into account the drilling date."
},
{
"nutrientId": 6,
"sequenceId": 1,
"note": "A new soil analysis is needed. Use of soil analysis results that are more than 4-5 years old may give misleading recommendations."
},
{
"nutrientId": 6,
"sequenceId": 1,
"note": "The lime recommendation may be different in mixed grass/arable rotations (see the Nutrient Management Guide)."
}
],
"referenceValue": "Winter Barley feed crop",
"versionNumber": "v1.0.2"
}
Example 2 - Grass
• The crop is first cut of silage plus grazing, in England and Wales.
• Moderate SNS
• Average GGC
• Target yield: 11 t/ha
Nitrogen for first cut silage:
• Table 3.8: Nitrogen recommendations for grass silage
• Target annual DM yield: 9-12 t/ha
• N application rate = 100 kg N/ha
Nitrogen for grazed sward:
• Table 3.9: Nitrogen recommendations for grazed swards
• Indicative DM yield: 9-12 t/ha
• N application rate = 40 kg N/ha, 40 kg N/ha, 40 kg N/ha
Total N recommendation = 220 kg N/ha
• Moderate SNS
• Average GGC
• Target yield: 11 t/ha
Nitrogen for first cut silage:
• Table 3.8: Nitrogen recommendations for grass silage
• Target annual DM yield: 9-12 t/ha
• N application rate = 100 kg N/ha
Nitrogen for grazed sward:
• Table 3.9: Nitrogen recommendations for grazed swards
• Indicative DM yield: 9-12 t/ha
• N application rate = 40 kg N/ha, 40 kg N/ha, 40 kg N/ha
Total N recommendation = 220 kg N/ha
Data Input for Example 2
{
"field": {
"fieldType": 2,
"multipleCrops": false,
"arable": [],
"grassland": {},
"grass": {
"cropOrder": 1,
"swardTypeId": 1,
"swardManagementId": 4,
"defoliationSequenceId": 16,
"grassGrowthClassId": 3,
"yield": 11,
"seasonId": 1
},
"soil": {
"soilTypeId": 2,
"kReleasingClay": null,
"nvzActionProgrammeId": 1,
"soilAnalyses": [
{
"soilAnalysisDate": "2026-02-01T00:00:00",
"soilPh": 6.5,
"sulphurDeficient": false,
"snsIndexId": 0,
"pIndexId": 1,
"kIndexId": 0,
"mgIndexId": null,
"snsMethodologyId": 4,
"pMethodologyId": 1,
"kMethodologyId": 4,
"mgMethodologyId": null
}
]
},
"harvestYear": 2026,
"area": 1.0,
"postcode": "AB12 3CD",
"altitude": 75,
"rainfallAverage": 70.0,
"excessWinterRainfall": 0.0,
"mannerManures": false,
"organicMaterials": [],
"mannerOutputs": [],
"previousCropping": {
"previousGrassId": 1,
"previousCropGroupId": 0,
"PreviousCropTypeId": 1,
"grassHistoryId": null
},
"countryId": 1
},
"nutrients": {
"nitrogen": true,
"phosphate": true,
"potash": true,
"magnesium": true,
"sodium": true,
"sulphur": true,
"lime": true
},
"totals": true,
"referenceValue": "grass"
}
C# code to connect to API
//API Connection Details
var accessToken = "..."; //Your access token
var apiConnection = "https://rb209api.ahdb.org.uk";
//Serialize input details
var content = new StringContent(JsonConvert.SerializeObject(dataInput), Encoding.UTF8, "application/json");
//Add Authentication details
var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
//Connect to API & retrieve data
var url = $"{apiConnection}/api/Recommendation/recommendations");
var task = client.PostAsync(url, content);
var returnedData = task.Result.Content.ReadAsStringAsync().Result;
//Deserialize output details
var dataOutputDetails = JsonConvert.DeserializeObject<DataOutput>(returnedData);
Data Output for Example 2
{
"calculations": [
{
"nutrientId": 0,
"type": "G",
"sequenceId": 1,
"defoliationId": 1,
"indexPh": "0",
"recommendation": 100,
"applied": null,
"cropNeed": 100,
"breakdown": true,
"description": "Total",
"snsStatus": null,
"totalAvailable": null
},
{
"nutrientId": 0,
"type": "G",
"sequenceId": 1,
"defoliationId": 2,
"indexPh": "0",
"recommendation": 40,
"applied": null,
"cropNeed": 40,
"breakdown": true,
"description": "Total",
"snsStatus": null,
"totalAvailable": null
},
{
"nutrientId": 0,
"type": "G",
"sequenceId": 1,
"defoliationId": 3,
"indexPh": "0",
"recommendation": 40,
"applied": null,
"cropNeed": 40,
"breakdown": true,
"description": "Total",
"snsStatus": null,
"totalAvailable": null
},
{
"nutrientId": 0,
"type": "G",
"sequenceId": 1,
"defoliationId": 4,
"indexPh": "0",
"recommendation": 40,
"applied": null,
"cropNeed": 40,
"breakdown": true,
"description": "Total",
"snsStatus": null,
"totalAvailable": null
},
/* Data for other nutrients is returned, but contents not shown for brevity */
],
"adviceNotes": [
/* Data for other nutrients is returned, but contents not shown for brevity */
],
"referenceValue": "grass",
"versionNumber": "v1.0.2"
}
Example 3 - Organic Materials
• 6% DM Cattle Slurry applied at 30 m3/ha, in England and Wales.
Values returned are (numbers in brackets are RB209 values unrounded where different):
• 78 kg N/ha - Total
• 36 kg P2O5/ha - Total
• 18 kg P2O5/ha - Available
• 75 kg K2O/ha - Total
• 68 (67.5) kg K2O/ha - Available
• 18 kg MgO/ha - Total
• 21 kg SO3/ha - Total
If optional inputs are provided, then the availability of N and SO3 will also be returned. In this example, the application was made during the autumn, and on a medium soil:
• 20 (19.5) kg N/ha - Available
• 2 (1.6) kg SO3/ha - Available
Values returned are (numbers in brackets are RB209 values unrounded where different):
• 78 kg N/ha - Total
• 36 kg P2O5/ha - Total
• 18 kg P2O5/ha - Available
• 75 kg K2O/ha - Total
• 68 (67.5) kg K2O/ha - Available
• 18 kg MgO/ha - Total
• 21 kg SO3/ha - Total
If optional inputs are provided, then the availability of N and SO3 will also be returned. In this example, the application was made during the autumn, and on a medium soil:
• 20 (19.5) kg N/ha - Available
• 2 (1.6) kg SO3/ha - Available
The total and available values (where applicable) are returned within the 'totalAvailable' object of each nutrient.
The relevant item also populates the applied object for the nutrient. This is then used in the calculation to determine the final crop need for the nutrient: recommendation - applied = cropNeed.
The relevant item also populates the applied object for the nutrient. This is then used in the calculation to determine the final crop need for the nutrient: recommendation - applied = cropNeed.
Data Input for Example 3
{
"field": {
"fieldType": 1,
"multipleCrops": false,
"arable": [
{
"cropOrder": 1,
"cropGroupId": 0,
"cropTypeId": 0,
"cropInfo1Id": 1,
"CropInfo2Id": 1,
"sowingDate": "2025-09-01T00:00:00",
"expectedYield": 8.0
}
],
"grassland": {},
"grass": {},
"soil": {
"soilTypeId": 2,
"nvzActionProgrammeId": 1,
"soilAnalyses": [
{
"soilAnalysisDate": "2026-01-01T00:00:00",
"soilPh": null,
"sulphurDeficient": false,
"snsIndexId": 0,
"pIndexId": 1,
"kIndexId": 0,
"mgIndexId": null,
"snsMethodologyId": 4,
"pMethodologyId": 1,
"kMethodologyId": 4,
"mgMethodologyId": 4
}
]
},
"harvestYear": 2026,
"area": 1.0,
"postcode": "AB12 3CD",
"altitude": 0,
"rainfallAverage": 0.0,
"excessWinterRainfall": 0.0,
"mannerManures": false,
"organicMaterials": [
{
"Id": 1,
"defoliationId": 1,
"applicationDate": "2025-10-18T00:00:00",
"applicationRate": 30.0,
"incorporationMethodId": 5,
"materialId": 18
}
],
"mannerOutputs": [],
"previousCropping": {
"previousGrassId": 1,
"previousCropGroupId": 0,
"PreviousCropTypeId": 0,
"grassHistoryId": null
},
"countryId": 1
},
"nutrients": {
"nitrogen": true,
"phosphate": true,
"potash": true,
"magnesium": true,
"sodium": true,
"sulphur": true,
"lime": true
},
"totals": true,
"referenceValue": "Organic Materials"
}
C# code to connect to API
//API Connection Details
var accessToken = "..."; //Your access token
var apiConnection = "https://rb209api.ahdb.org.uk";
//Serialize input details
var content = new StringContent(JsonConvert.SerializeObject(dataInput), Encoding.UTF8, "application/json");
//Add Authentication details
var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
//Connect to API & retrieve data
var url = $"{apiConnection}/api/Recommendation/recommendations";
var task = client.PostAsync(url, content);
var returnedData = task.Result.Content.ReadAsStringAsync().Result;
//Deserialize output details
var dataOutputDetails = JsonConvert.DeserializeObject<DataOutput>(returnedData);
Data Output for Example 3
{
"calculations": [
{
"nutrientId": 0,
"type": "A",
"sequenceId": 1,
"defoliationId": 1,
"indexPh": "0",
"recommendation": 250,
"applied": 20,
"cropNeed": 230,
"breakdown": true,
"description": "Total",
"snsStatus": null,
"totalAvailable": [
{
"total": 78,
"available": 20
}
]
},
{
"nutrientId": 1,
"type": "A",
"sequenceId": 1,
"defoliationId": 1,
"indexPh": "1",
"recommendation": 85,
"applied": 18,
"cropNeed": 67,
"breakdown": true,
"description": "Total",
"snsStatus": null,
"totalAvailable": [
{
"total": 36,
"available": 18
}
]
},
{
"nutrientId": 2,
"type": "A",
"sequenceId": 1,
"defoliationId": 1,
"indexPh": "0",
"recommendation": 145,
"applied": 68,
"cropNeed": 77,
"breakdown": true,
"description": "Total",
"snsStatus": null,
"totalAvailable": [
{
"total": 75,
"available": 68
}
]
},
{
"nutrientId": 3,
"type": "A",
"sequenceId": 1,
"defoliationId": 1,
"indexPh": "2",
"recommendation": 0,
"applied": null,
"cropNeed": 0,
"breakdown": true,
"description": "Total",
"snsStatus": null,
"totalAvailable": [
{
"total": 18,
"available": null
}
]
},
{
"nutrientId": 4,
"type": "A",
"sequenceId": 1,
"defoliationId": 1,
"indexPh": null,
"recommendation": 0,
"applied": null,
"cropNeed": 0,
"breakdown": true,
"description": "Total",
"snsStatus": null,
"totalAvailable": null
},
{
"nutrientId": 5,
"type": "A",
"sequenceId": 1,
"defoliationId": 1,
"indexPh": null,
"recommendation": 0,
"applied": 2,
"cropNeed": 0,
"breakdown": true,
"description": "Total",
"snsStatus": null,
"totalAvailable": [
{
"total": 21,
"available": 2
}
]
},
{
"nutrientId": 6,
"type": "A",
"sequenceId": 1,
"defoliationId": 1,
"indexPh": "6.5",
"recommendation": 0,
"applied": 0,
"cropNeed": 0,
"breakdown": true,
"description": "Total",
"snsStatus": null,
"totalAvailable": null
}
],
"adviceNotes": [
/* Data for advice notes is returned, but contents not shown for brevity */
],
"referenceValue": "Organic Materials",
"versionNumber": "v1.0.2"
}
Example 4 - Manner Outputs
Outputs from Manner can be passed directly into the API as part of a request. These values will be used as part of the calculations, and will be returned in the response.
Manner output values:
• 80 kg N/ha - Total
• 20 kg N/ha - Available
• 35 kg P2O5/ha - Total
• 25 kg P2O5/ha - Available
• 75 kg K2O/ha - Total
• 70 kg K2O/ha - Available
• 15 kg MgO/ha - Total
• 10 kg SO3/ha - Total
• 5 kg SO3/ha - Available
Manner output values:
• 80 kg N/ha - Total
• 20 kg N/ha - Available
• 35 kg P2O5/ha - Total
• 25 kg P2O5/ha - Available
• 75 kg K2O/ha - Total
• 70 kg K2O/ha - Available
• 15 kg MgO/ha - Total
• 10 kg SO3/ha - Total
• 5 kg SO3/ha - Available
The total and available values (where applicable) are returned within the 'totalAvailable' object of each nutrient.
The relevant item also populates the applied object for the nutrient. This is then used in the calculation to determine the final crop need for the nutrient: recommendation - applied = cropNeed.
The relevant item also populates the applied object for the nutrient. This is then used in the calculation to determine the final crop need for the nutrient: recommendation - applied = cropNeed.
Data Input for Example 4
{
"field": {
"fieldType": 1,
"multipleCrops": false,
"arable": [
{
"cropOrder": 1,
"cropGroupId": 0,
"cropTypeId": 0,
"cropInfo1Id": 1,
"cropInfo2Id": 1,
"sowingDate": "2025-09-01T00:00:00",
"expectedYield": 8.0
}
],
"grassland": {},
"grass": {},
"soil": {
"soilTypeId": 2,
"nvzActionProgrammeId": 1,
"soilAnalyses": [
{
"soilAnalysisDate": "2026-02-01T00:00:00",
"soilPh": null,
"sulphurDeficient": false,
"snsIndexId": 0,
"pIndexId": 1,
"kIndexId": 0,
"mgIndexId": null,
"snsMethodologyId": 4,
"pMethodologyId": 1,
"kMethodologyId": 4,
"mgMethodologyId": 4
}
]
},
"harvestYear": 2026,
"area": 1.0,
"postcode": "AB12 3CD",
"altitude": 0,
"rainfallAverage": 0.0,
"excessWinterRainfall": 0.0,
"mannerManures": true,
"organicMaterials": [],
"mannerOutputs": [
{
"id": "1",
"defoliationId": "1",
"totalN": 80,
"availableN": 20,
"totalP": 35,
"availableP": 25,
"totalK": 75,
"availableK": 70,
"totalM": 15,
"totalS": 10,
"availableS": 5
}
],
"previousCropping": {
"previousGrassId": 1,
"previousCropGroupId": 0,
"previousCropTypeId": 0,
"grassHistoryId": null
},
"countryId": 1
},
"nutrients": {
"nitrogen": true,
"phosphate": true,
"potash": true,
"magnesium": true,
"sodium": true,
"sulphur": true,
"lime": true
},
"totals": true,
"referenceValue": "Manner Outputs"
}
C# code to connect to API
//API Connection Details
var accessToken = "..."; //Your access token
var apiConnection = "https://rb209api.ahdb.org.uk";
//Serialize input details
var content = new StringContent(JsonConvert.SerializeObject(dataInput), Encoding.UTF8, "application/json");
//Add Authentication details
var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
//Connect to API & retrieve data
var url = $"{apiConnection}/api/Recommendation/recommendations";
var task = client.PostAsync(url, content);
var returnedData = task.Result.Content.ReadAsStringAsync().Result;
//Deserialize output details
var dataOutputDetails = JsonConvert.DeserializeObject<DataOutput>(returnedData);
Data Output for Example 4
{
"calculations": [
{
"nutrientId": 0,
"type": "A",
"sequenceId": 1,
"defoliationId": 1,
"indexPh": "0",
"recommendation": 250,
"applied": 20,
"cropNeed": 230,
"breakdown": true,
"description": "Total",
"snsStatus": null,
"totalAvailable": [
{
"total": 80,
"available": 20
}
]
},
{
"nutrientId": 1,
"type": "A",
"sequenceId": 1,
"defoliationId": 1,
"indexPh": "1",
"recommendation": 85,
"applied": 25,
"cropNeed": 60,
"breakdown": true,
"description": "Total",
"snsStatus": null,
"totalAvailable": [
{
"total": 35,
"available": 25
}
]
},
{
"nutrientId": 2,
"type": "A",
"sequenceId": 1,
"defoliationId": 1,
"indexPh": "0",
"recommendation": 145,
"applied": 70,
"cropNeed": 75,
"breakdown": true,
"description": "Total",
"snsStatus": null,
"totalAvailable": [
{
"total": 75,
"available": 70
}
]
},
{
"nutrientId": 3,
"type": "A",
"sequenceId": 1,
"defoliationId": 1,
"indexPh": "2",
"recommendation": 0,
"applied": null,
"cropNeed": 0,
"breakdown": true,
"description": "Total",
"snsStatus": null,
"totalAvailable": [
{
"total": 15,
"available": null
}
]
},
{
"nutrientId": 4,
"type": "A",
"sequenceId": 1,
"defoliationId": 1,
"indexPh": null,
"recommendation": 0,
"applied": null,
"cropNeed": 0,
"breakdown": true,
"description": "Total",
"snsStatus": null,
"totalAvailable": null
},
{
"nutrientId": 5,
"type": "A",
"sequenceId": 1,
"defoliationId": 1,
"indexPh": null,
"recommendation": 0,
"applied": 5,
"cropNeed": 0,
"breakdown": true,
"description": "Total",
"snsStatus": null,
"totalAvailable": [
{
"total": 10,
"available": 5
}
]
},
{
"nutrientId": 6,
"type": "A",
"sequenceId": 1,
"defoliationId": 1,
"indexPh": "6.5",
"recommendation": 0,
"applied": 0,
"cropNeed": 0,
"breakdown": true,
"description": "Total",
"snsStatus": null,
"totalAvailable": null
}
],
"adviceNotes": [
/* Data for advice notes is returned, but contents not shown for brevity */
],
"referenceValue": "Manner Outputs",
"versionNumber": "v1.0.2"
}
Example 5 - Lab Analysis
• 30 m3/ha DM Cattle Slurry applied in the spring before the first silage cut, in England and Wales.
A lab analysis is carried out on a sample of slurry, the returned values are:
• 2.0 kg N/ha - Total
• 1.1 kg P2O5/ha - Total
• 3.4 kg K2O/ha - Total
• 0.7 kg SO3/ha - Total
• 0.6 kg MgO/ha - Total
The API will use these input values instead of the default values associated to the organic material.
Values returned using the lab analysis inputs are (numbers in brackets are RB209 values unrounded):
• 24 (24.0) kg N/ha - Available
• 17 (16.5) kg P2O5/ha - Available
• 92 (91.8) kg K2O/ha - Available
• 9 (9.45) kg SO3/ha - Available
A lab analysis is carried out on a sample of slurry, the returned values are:
• 2.0 kg N/ha - Total
• 1.1 kg P2O5/ha - Total
• 3.4 kg K2O/ha - Total
• 0.7 kg SO3/ha - Total
• 0.6 kg MgO/ha - Total
The API will use these input values instead of the default values associated to the organic material.
Values returned using the lab analysis inputs are (numbers in brackets are RB209 values unrounded):
• 24 (24.0) kg N/ha - Available
• 17 (16.5) kg P2O5/ha - Available
• 92 (91.8) kg K2O/ha - Available
• 9 (9.45) kg SO3/ha - Available
The total and available values (where applicable) are returned within the 'totalAvailable' object of each nutrient.
Data Input for Example 5
{
"field": {
"fieldType": 1,
"multipleCrops": false,
"arable": [
{
"cropOrder": 1,
"cropGroupId": 0,
"cropTypeId": 0,
"cropInfo1Id": 1,
"cropInfo2Id": 1,
"sowingDate": "2025-09-01T00:00:00",
"expectedYield": 8.0
}
],
"grassland": {},
"soil": {
"soilTypeId": 2,
"nvzActionProgrammeId": 1,
"soilAnalyses": [
{
"soilAnalysisDate": "2026-01-01T00:00:00",
"soilpH": null,
"sulphurDeficient": false,
"snsIndexId": 0,
"pIndexId": 1,
"kIndexId": 0,
"mgIndexId": null,
"snsMethodologyId": 4,
"pMethodologyId": 1,
"kMethodologyId": 4,
"mgMethodologyId": 4
}
]
},
"harvestYear": 2026,
"area": 1.0,
"postcode": "AB12 3CD",
"altitude": 0,
"SiteClassId": 3,
"rainfallAverage": 0.0,
"excessWinterRainfall": 0.0,
"mannerManures": false,
"organicMaterials": [
{
"id": 1,
"applicationDate": "2025-10-18T00:00:00",
"applicationRate": 30.0,
"incorporationMethodId": 1,
"materialId": 18,
"nitrogen": 2.0,
"phosphate": 1.1,
"potash": 3.4,
"sulphur": 0.7,
"magnesium": 0.6
}
],
"mannerOutputs": [],
"previousCropping": {
"previousGrassId": 1,
"previousCropGroupId": 0,
"PreviousCropTypeId": 0
},
"countryId": 1
},
"nutrients": {
"nitrogen": true,
"phosphate": true,
"potash": true,
"magnesium": true,
"sodium": true,
"sulphur": true,
"lime": true
},
"totals": true,
"referenceValue": "Lab Analysis"
}
C# code to connect to API
//API Connection Details
var accessToken = "..."; //Your access token
var apiConnection = "https://rb209api.ahdb.org.uk";
//Serialize input details
var content = new StringContent(JsonConvert.SerializeObject(dataInput), Encoding.UTF8, "application/json");
//Add Authentication details
var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
//Connect to API & retrieve data
var url = $"{apiConnection}/api/Recommendation/recommendations";
var task = client.PostAsync(url, content);
var returnedData = task.Result.Content.ReadAsStringAsync().Result;
//Deserialize output details
var dataOutputDetails = JsonConvert.DeserializeObject<DataOutput>(returnedData);
Data Output for Example 5
{
"calculations": [
{
"nutrientId": 0,
/* Data is returned, but contents not shown for brevity */
"totalAvailable": [
{
"total": 60,
"available": 24
}
]
},
{
"nutrientId": 1,
/* Data is returned, but contents not shown for brevity */
"totalAvailable": [
{
"total": 33,
"available": 17
}
]
},
{
"nutrientId": 2,
/* Data is returned, but contents not shown for brevity */
"totalAvailable": [
{
"total": 102,
"available": 92
}
]
},
{
"nutrientId": 3,
/* Data is returned, but contents not shown for brevity */
"totalAvailable": [
{
"total": 18.00,
"available": null
}
]
},
{
"nutrientId": 4,
/* Data is returned, but contents not shown for brevity */
"totalAvailable": null
},
{
"nutrientId": 5,
/* Data is returned, but contents not shown for brevity */
"totalAvailable": [
{
"total": 21,
"available": 9
}
]
},
{
"nutrientId": 6,
/* Data is returned, but contents not shown for brevity */
"totalAvailable": null
}
],
"adviceNotes": [
/* Data is returned, but contents not shown for brevity */
],
"referenceValue": "Lab Analysis",
"versionNumber": "v1.0.2"
}