Documentatie/Blight-API.md

7.5 KiB

Blight API

<< Home

For the currently available public FarmMaps API you can take a look at swagger: https://farmmaps.eu/swagger

API flow

  • Authenticate
  • Create cropping scheme (if not exists)
  • Create crop field (if not exists)
  • Get blight advice
  • Create blight advice
  • Add spray
  • Add irrigation
  • Get predefined fungicides

Steps

Authenticate

See Authentication

Create cropping scheme (if not exists)

See Create Croppingscheme

Create crop field (if not exists)

See Create Cropfield

Get blight advice

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.

A blight advice is a child record of a crop field. Use the crop field code to get the latest blight advice.

1. get the blight item code

Request

GET /api/v1/items/{code}/children?it=vnd.farmmaps.itemtype.blight

Response 200 OK

[
    {
        "parentCode": "string",
        "geometry": ...
        "url": ...
		"code": ...
		"size": ...
        "data": {
            "itemtask": {
                "runs": {
                    "last": "2023-02-22T03:02:01.8775194Z",
                    "success": "2023-02-22T03:02:01.8775194Z"
                },
                "state": "ok",
                "messages": []
            },		
		...
	}

Response 404 Not Found

There is no advice available, try to create a new advice, see Create blight advice.

Check the data field for itemtask/state. If state is "ok" there should be an advice.

2. get advice for the blight item

Use the code found in the previous call (or use url) to get the advice.

Request

GET /api/v1/items/{code}/data

Response 200 OK

[
    {
        "sprayTime": null,
        "date": "2022-03-01T00:00:00",
        "weather": [
            {
                "temperature": 3.0,
                "precipitation": 0.0,
                "rain": 0.0,
                "irrigation": 0.0,
                "humidity": 71.0,
                "hh": 0,
                "leafwetnessmm": null
      },...
	}

Response 404 Not Found

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

POST /api/v1/items/{code}/tasks
{
    "TaskType": "vnd.farmmaps.task.blight",
    "Delay": null,
    "attributes": {}
}

Response 200

{
    "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.

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.

Get the blight advice code from Get blight advice
Use this code in the following request.

Request

GET api/v1/items/{code}/children?it=vnd.farmmaps.itemtype.user.input

Response 200

[
{
	"code": "{code}",
    // ....
	"data": {
		"sprays": [],
		"phytoPressure": 0,
		"ignoreOoSpores": true,
		"ignoreTuberRisk": true,
		"haulmKillingDate": null
	}
}

Get the first object of the array, change the data, and push the object back.
Use the code from the response above.

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

{
	"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

GET /api/v1/items/{code}/children?it=vnd.farmmaps.itemtype.crprec

Response 200

[
{
	"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

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.

Request

GET /api/v1/items/?it=vnd.farmmaps.itemtype.codelist.fm002

Response 200

[
{   
    "code": "...",
    // ...
    "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"
    }
},
...
]