Documentatie/Blight-API.md

307 lines
7.7 KiB
Markdown
Raw Normal View History

2021-06-07 18:59:25 +00:00
# Blight API
2021-05-28 14:16:01 +00:00
[<< Home](README.md)
2021-06-07 18:59:25 +00:00
For the currently available public FarmMaps API you can take a look at swagger: https://farmmaps.eu/swagger
2021-05-28 14:16:01 +00:00
## API flow
2021-06-07 18:59:25 +00:00
* Authenticate
2021-05-28 14:58:47 +00:00
* Create cropping scheme (if not exists)
* Create crop field (if not exists)
* Get blight advice
* Create blight advice
* Add spray
* Add irrigation
2021-06-07 18:59:25 +00:00
* Get predefined fungicides
2021-05-28 14:58:47 +00:00
2021-06-07 18:59:25 +00:00
## Steps
2021-06-03 11:48:20 +00:00
2021-06-07 18:59:25 +00:00
### Authenticate
See [Authentication](Authentication.md)
2021-06-03 11:48:20 +00:00
2021-06-07 18:59:25 +00:00
### Create cropping scheme (if not exists)
See [Create Croppingscheme](Create-Croppingscheme.md)
2021-06-03 11:48:20 +00:00
2021-06-07 18:59:25 +00:00
### Create crop field (if not exists)
See [Create Cropfield](Create-Cropfield.md)
2021-06-03 11:48:20 +00:00
2021-08-26 11:15:39 +00:00
### <a name="create-advice"></a>Get blight advice
2021-06-07 18:59:25 +00:00
Blight is only available for potato fields.
The advice is automatically created when new potato fields are added and is scheduled to be updated at configured times.
It is also possible to create a new advice at any time, see [Create blight advice](#create-advice).
A blight advice is a child record of a crop field.
Use the crop field code to get the latest blight advice.
> Request
```javascript
GET /api/v1/items/{code}/children?it=vnd.farmmaps.itemtype.blight
```
> Response 200 OK
```javascript
[
{
"parentCode": "string",
"geometry": ...
"data": {
"advices": [
{
"date": "2021-03-19T00:00:00",
"weather": [
{
"hh": 0,
"rain": 0.0,
"humidity": 90.0,
"irrigation": 0.0,
"temperature": 2.0,
"precipitation": 0.0
},
{
"hh": 1,
"rain": 0.0,
"humidity": 91.0,
"irrigation": 0.0,
"temperature": 1.0,
"precipitation": 0.0
},...],
"sprayTime": null,
"sprayType": 3,
"ooSporesRisk": false,
"fungicideLeftPct": 0,
"sprayEffectivity": null,
"unprotectedGrowth": 0.0,
"tuberInfectionRisk": false,
"infectionRiskPerHour": [
0,...]
...
}
```
The data object contains the advices from emergence date and weather from planting date.
The date property respresents the advice date, the weather array contains 24 objects, 1 for each hour.
> Response 404 Not Found
There is no advice available, try to create a new advice, see [Create blight advice](#create-advice).
### <a name="create-advice"></a>Create blight advice
Task 'vnd.farmmaps.task.blight' must be executed to create an advice.
This task is automatically created for potato fields and is scheduled to run at configered times to keep the advice updated. But it is possible to create this task at any time.
Add the crop field code to the URL and execute the following request.
> Request
```javascript
POST /api/v1/items/{code}/tasks
{
"TaskType": "vnd.farmmaps.task.blight",
"Delay": null,
"attributes": {}
}
```
> Response 200
```javascript
{
"code": "{code}",
"taskType": "vnd.farmmaps.task.blight",
"attributes": {
"messagePriority": "10"
}
}
```
With the code in the response message and the code of the crop field, it is possible to check the task's state (error/ok/scheduled/processing). See [Check task status](Polling-task-status.md).
### Add spray
Sprays are stored as child item of a blight item.
This item also contains other parameters like pressure, disable/enable oospores and risc on tuber infection, wich are all used when the advice is created.
Changing these parameters will not create in a new advice automatically.
But is it possible to create an advice at any time, see [Create blight advice](#create-advice).
2021-08-26 11:15:39 +00:00
Get the blight advice code from [Get blight advice](#create-advice)
2021-06-07 18:59:25 +00:00
Use this code in the following request.
> Request
```javascript
GET api/v1/items/{code}/children?it=vnd.farmmaps.itemtype.user.input
```
> Response 200
```javascript
[
{
"code": "{code}",
// ....
"data": {
"sprays": [],
"phytoPressure": 0,
"ignoreOoSpores": true,
"ignoreTuberRisk": true,
"haulmKillingDate": null
}
}
```
Get the first objecy of the array, change the data, and push the object back.
Use the code from the response above.
```javascript
PUT /api/v1/items/{code}
{
"parentCode": "....",
// ....
"data": {
"sprays": [
{
"dose": 1,
"isVRA": false,
"fungicide": {
"ai1": "mandipropamid",
"ai2": null,
"ai3": null,
"code": "revus",
"name": "revus 0,6 l",
"maxdose": "0.6",
"mindose": "0.48",
"safedays": "3",
"emergence": true,
"newgrowth": "2",
"contentai1": "250",
"contentai2": "0",
"contentai3": "0",
"fastgrowth": true,
"contentunit": "g/l",
"rainfastness": "3",
"tuberfilling": false,
"aidescription": "mandipropamid (0.6 l/ha)",
"curativescore": "1",
"dryingtimemax": "1",
"dryingtimemin": "0.5",
"vracompatible": true,
"maxapplications": "6",
"preventivescore": "4",
"recommendeddose": "0.6",
"tuberprotection": "2",
"eradicativescore": "1.5",
"earlytubersetting": false,
"protectioncategory": "1",
"applicationrateunit": "l/ha",
"ctgbregistrationnumber": "12969 n"
},
"sprayTime": "2021-04-15T12:00:00Z"
}
],
"phytoPressure": 0,
"ignoreOoSpores": false,
"ignoreTuberRisk": true,
"haulmKillingDate": null
},
// ....
}
```
> Response 200
```javascript
{
"parentCode": "....",
// ....
}
```
### Add irrigation
Irrigations are stored as child item of a crop recording item.
First step is to get the crop recording item for the crop field.
#### 1. get the crop recording item for the crop field
> Request
```javascript
GET /api/v1/items/{code}/children?it=vnd.farmmaps.itemtype.crprec
```
> Response 200
```javascript
[
{
"code": "{code}",
// ....
"data":
{
}
}
```
#### 2. Add irrigation to the crop field
Use the crop recording code, got from the previous call, and change the desired fields (from, to, quantity, etc):
> Request
```javascript
POST /api/v1/items/
{
"data": {
"from": "2021-05-05T08:00:00.000Z",
"to": "2021-05-05T13:00:00.000Z",
"quantity": 80,
"name": "Irrigation",
"status": "3",
"method": "90100",
"contractor": false,
"operationCode": "9",
"product": "OW"
},
"parentCode": "{code}",
"itemType": "vnd.farmmaps.itemtype.crprec.operation",
"name": "CrpRec Operation, Irrigation"
}
```
### Get predefined fungicides
A list of predefined fungicides can be requested by getting the "vnd.farmmaps.itemtype.codelist.fm002" items from farmmaps.
2021-06-03 11:48:20 +00:00
> Request
```javascript
GET /api/v1/items/?it=vnd.farmmaps.itemtype.codelist.fm002
```
> Response 200
```javascript
[
{
2021-06-07 18:59:25 +00:00
"code": "...",
// ...
2021-06-03 11:48:20 +00:00
"data":
{
"ai1": "fluazinam",
"ai2": null,
"ai3": null,
"code": "shirlangold",
"name": "shirlan gold ",
"maxdose": "0.4",
"mindose": "0.32",
"safedays": "7",
"emergence": false,
"newgrowth": "0.5",
"contentai1": "500",
"contentai2": "0",
"contentai3": "0",
"fastgrowth": true,
"contentunit": "g/l",
"rainfastness": "2.5",
"tuberfilling": false,
"aidescription": "fluazinam (0.4 l/ha)",
"curativescore": "0",
"dryingtimemax": "2",
"dryingtimemin": "1",
"vracompatible": false,
"maxapplications": "10",
"preventivescore": "2.9",
"recommendeddose": "0.4",
"tuberprotection": "3.3",
"eradicativescore": "0",
"earlytubersetting": true,
"protectioncategory": "1",
"applicationrateunit": "l/ha",
"ctgbregistrationnumber": "14744 n"
}
},
...
]
2021-06-07 18:59:25 +00:00
```