Machine File Conversion Endpoints

About

All HTTP methods should be prepended by this service's endpoint:

https://api.withleaf.io/services/operations/api

This service has the following endpoints available:

DescriptionEndpoints
Get all filesGET /files
Get a fileGET /files/{id}
Get a file summaryGET /files/{id}/summary
Get a file's imagesGET /files/{id}/images
Get a file's unitsGET /files/{id}/units
Upload a filePOST /batch
Get a batchGET /batch/{id}
Get all batchesGET /batch
Retry a batchPUT /batch/{id}/retry
Merge filesPOST /files/merge
Get a file statusGET /files/{id}/status

For easily testing these endpoints, we recommend using our Postman collection.

requires Leaf User with credentials

To have access to operation files, you will need a Leaf User with valid credentials from the provider you want to access data. If you don't have a Leaf User or you have not connected it with any provider yet, see how to create a Leaf User or how to add credentials to a Leaf User for each of the providers.

Get all files

ย GET /files

Gets a paged list of files that belong to the current logged in user. It is possible to filter the results by passing some query parameters. They are listed below.

Parameter (to filter by)Values
leafUserIduuid of one of your users
providerCNHI, JohnDeere, Trimble, ClimateFieldView, AgLeader or Leaf
statusprocessed, failed or processing
originprovider, automerged, merged or uploaded
organizationIdthe provider organizationId (only available for John Deere)
batchIduuid of the upload response (only available for uploaded files)
createdTimeISO 8601 date. Returns operations from the createdTime onward
startTimeISO 8601 date. Returns operations from the startTime onward
endTimeISO 8601 date. Returns operations until the endTime
operationTypeapplied, planted or harvested
minAreaa number (Double) representing the minimum area (square meters) of the operations to be returned

Also, for operationType: harvested we can process the yield properties related to the operation using the crop density and standard moisture available in this table.

You can also pass some parameters used exclusively for paging through results. They are:

  • page, an integer specifying the page being fetched (default is 0)
  • size, an integer specifying the size of the page (max is 100)
the default value for page size is 20

If the parameters page and size are not set, the endpoint will return 20 results.

curl -X GET \
-H 'Authorization: Bearer YOUR_TOKEN' \
'https://api.withleaf.io/services/operations/api/files'

Response

The response is a JSON with the key "operations" referring to a list of files. Here's a link with sample responses for "planted", "applied", "harvested" and "tillage" operation files.

{
"message": "SUCCESS",
"operations": [OPERATIONS]
}

Get a file

ย GET /files/{id}

Gets a single file by its id.

curl -X GET \
-H 'Authorization: Bearer YOUR_TOKEN' \
'https://api.withleaf.io/services/operations/api/files/{id}'

Response

Here's a link with sample responses for "planted", "applied", "harvested" and "tillage" operation files.

Get a file summary

ย GET /files/{id}/summary

Gets the summary, if available, for the file id.

curl -X GET \
-H 'Authorization: Bearer YOUR_TOKEN' \
'https://api.withleaf.io/services/operations/api/files/{id}/summary'

Response

Here's a link with sample responses for "planted", "applied", "harvested" and "tillage" operation files.

Get a file's images

ย GET /files/{id}/images

Gets a list of PNG images generated from the operation's file properties.

curl -X GET \
-H 'Authorization: Bearer YOUR_TOKEN' \
'https://api.withleaf.io/services/operations/api/files/{id}/images'

Returns a JSON list of the following format:

[
{
"property": "elevation",
"ramp": {
"0%": [200, 0, 0],
"35%": [255, 40, 0],
"45%": [255, 150, 0],
"55%": [255, 240, 0],
"65%": [ 0, 230, 0],
"75%": [ 0, 190, 0],
"100%": [ 0, 130, 0],
"nv": [ 0, 0, 0, 0]
},
"url": "string"
},
....
]

The property refers to the property extracted from files' data to generate the image. In the example above, the image would represent the elevation.

The ramp is the color ramp used to generate the image. The percentages correspond to the minimum (0%) and maximum (100%) values in the image. The listed values correspond to RGB values used. The nv refers to no value. It is used internally to make the image transparent on places without data. Currently, this ramp is the same in all images processed.

We also generate an auxiliary xml with geographic information to handle this image on GIS environments. You just need to append the ".aux.xml" string to the png url.

Get a file's units

ย GET /files/{id}/units

Gets the file's properties and their units.

curl -X GET \
-H 'Authorization: Bearer YOUR_TOKEN' \
'https://api.withleaf.io/services/operations/api/files/{id}/units'

Returns a JSON like the following:

{
"distance": "ft",
"heading": "arcdeg",
"speed": "mi/hr",
"elevation": "ft",
"harvestMoisture": "prcnt",
"wetMass": "lb",
"yieldVolume": "bu",
"equipmentWidth": "ft"
}

These properties vary depending on the operationType, but you can expect the same, standardized keys, across different providers.

Units usually don't change for the same Leaf User, since the providers units configuration is based on their location. But keep in mind that it's best to always take the units into consideration, just to be sure.

Upload a file

ย POST /batch

Creates a new file in Leaf. The file must be sent as a zip.

This endpoint accepts a .zip of operation files, detects which files are in the .zip, and returns the ID of the process, which can in turn be used to retrieve the ID's of the files being processed.

File size limit of 3 GB

Currently, our upload endpoints accepts files with the maximum size limited to 3 gigabytes.

This endpoint receives two required URL parameters, a leafUserId and provider

A provider can be set as one of the following:

Other
ClimateFieldView
CNHI
JohnDeere
Trimble
AgLeader
Farmobile
PrecisionPlanting

If provider is set to "Other", Leaf will detect which files are present in the .zip file and process them accordingly.

Leaf will detect files present in the uploaded .zip and create file ids for the files that are detected in the uploaded .zip. These files can then be accessed individually by their file ID, batch ID, or their associated field boundary.

Expected file structures from each provider are listed below. Very often these default file structures are edited by users. In these cases Leaf attempts to automatically repair the file structure and find all necessary files within any uploaded .zip.

The following file formats from each provider are supported:

JohnDeere

File FormatMonitor ModelDetails
GS3GreenStar 3 โ€“ 2630/GS3_2630/profile/RCD/EIC/global.ver
Gen4Gen 4 - 4600/4630/JD-Data/log/user defined name/*.jdl
ShapefileExported from MyJohnDeereShapefile with extra metadata in a .json file
Expected file structure

GreenStar 4 (4600+)

jd-data
โ””โ”€โ”€ log
โ””โ”€โ”€ *.jdl

GreenStar 3 (2630)

GS3_2630
โ””โ”€โ”€ RCD
โ””โ”€โ”€ EIC
โ””โ”€โ”€ global.ver
โ””โ”€โ”€ documentation
โ””โ”€โ”€ ...
โ”œโ”€โ”€ *.fdd
โ””โ”€โ”€ *.fdl

Green Star 2 (2600)

...
โ””โ”€โ”€ RCD
โ”œโ”€โ”€ *.fdd
โ””โ”€โ”€ *.fdl

Climate FieldView

File FormatMonitor ModelDetails
datAll files from Climate FieldViewA zip with .dat files
Expected file structure

20|20 SeedSense Generation 1 and Generation 2

...
โ”œโ”€โ”€ harvest_*.dat โ€“ Harvest data
โ”œโ”€โ”€ field_map_*.dat โ€“ Planting data
โ””โ”€โ”€ liquid_map_*.dat - AsApplied spraying data

20|20 SeedSense Generation 3

...
โ””โ”€โ”€ *.2020

CNHI

File FormatMonitor ModelDetails
CN1CaseIH monitors or exported from CNH Connects/file.cn1/index.vy1
Expected file structure

Voyager 2

*.cn1
โ””โ”€โ”€ ...
โ””โ”€โ”€ *.vy1

AgLeader

File FormatMonitor ModelDetails
yldYM2000, PFAdvantage & other OEM systemsA zip with .yld files
ilfINTEGRA / Insight / EdgeA zip with .ilf files
agdataINTEGRA / VERSA / COMPASSA zip with .agdata files
Expected file structure

AgLeader Integra (versions 3.5+), Versa

...
โ”œโ”€โ”€ *.agdata
โ””โ”€โ”€ *.agsetup

AgLeader Edge, Insight, and Integra (version 3.4)

...
โ””โ”€โ”€ *.ilf

AgLeader PF Advantage, PF 3000, PF 3000 Pro, YM2000

...
โ””โ”€โ”€ *.yld

Trimble

File FormatMonitor ModelDetails
AgDataFMX and CFX monitors/AgData/
AgGPSTMX and GFX monitors/AgGPS/
Expected file structure

GFX-750, TMX-2050

Agdata
โ”œโ”€โ”€ Fields
โ””โ”€โ”€ *.agf
โ”œโ”€โ”€ implements
โ””โ”€โ”€ *.agi
โ”œโ”€โ”€ prescriptions
โ””โ”€โ”€ *.agm
โ”œโ”€โ”€ Tasks
โ””โ”€โ”€ *.agt
โ”œโ”€โ”€ Users
โ””โ”€โ”€ *.agu
โ””โ”€โ”€ vehicles
โ””โ”€โ”€ *.agv

CFX-750, FMX

AgGPS
โ””โ”€โ”€ Data
โ””โ”€โ”€ "Grower"
โ””โ”€โ”€ Farm
โ””โ”€โ”€ field
โ””โ”€โ”€ "Task"
โ”œโ”€โ”€ *.cpg
โ”œโ”€โ”€ *.dbf
โ”œโ”€โ”€ *.shp
โ””โ”€โ”€ *.shx

Precision Planting (beta)

File FormatMonitor ModelDetails
PP202020|20A zip with .2020 files.
Expected file structure

20|20 SeedSense Generation 1 and Generation 2

...
โ”œโ”€โ”€ harvest_*.dat โ€“ Harvest data
โ”œโ”€โ”€ field_map_*.dat โ€“ Planting data
โ””โ”€โ”€ liquid_map_*.dat - AsApplied spraying data

20|20 SeedSense Generation 3

...
โ””โ”€โ”€ *.2020

ISOXML

Expected file structure
TASKDATA
โ”œโ”€โ”€ *.XML
โ””โ”€โ”€ *.bin

CLAAS

Expected file structure
TASKDATA
โ”œโ”€โ”€ *.XML
โ””โ”€โ”€ *.bin

Kuhn

Expected file structure
TASKDATA
โ”œโ”€โ”€ *.XML
โ””โ”€โ”€ *.bin

Kverneland Group

Expected file structure
TASKDATA
โ”œโ”€โ”€ *.XML
โ””โ”€โ”€ *.bin

Mรผller-Elektronik

Expected file structure
TASKDATA
โ”œโ”€โ”€ *.XML
โ””โ”€โ”€ *.bin

Teknomika

Expected file structure
TASKDATA
โ”œโ”€โ”€ *.XML
โ””โ”€โ”€ *.bin

Topcon Precision Agriculture

Expected file structure
TASKDATA
โ”œโ”€โ”€ *.XML
โ””โ”€โ”€ *.bin

Farmobile

File FormatDetails
GeoJSONGeoJSON files exported from Farmobile. Since GeoJSON files do not contain information on the units used, we assume the default units from Farmobile are being used.

Other

File FormatDetails
ShapefileShapefiles exported from SMS. Since Shapefiles do not contain information on the units used, we assume the default units from SMS are being used.
curl -X POST \
-H 'Authorization: Bearer YOUR_TOKEN' \
-F 'file=shapefile.zip' \
'https://api.withleaf.io/services/operations/api/batch' \
'provider=JohnDeere&leafUserId=id'
Response

Returns a single JSON object, as shown below:

{
"id": "996aea67-52bc-4d4b-9b77-028756dc0ee9",
"leafUserId": "ede8f781-1d55-4b2d-83a1-6785ddab6e1d",
"fileName": "Climate.zip",
"size": 8652951,
"provider": "Other",
"status": "RECEIVED",
"uploadTimestamp": "2021-03-12T19:50:55.567755Z"
}

This id can then be queried to retrieve on Get batch to get the individual file ID's. Then you can query each of the files individually with Get a File or all of them, filtering by batchId, on Get all Files.

Batch status

The status key will evolve accordingly to the following states:

StatusDescription
RECEIVEDIs the default state for every batch created
PROCESSEDWhen all the files included in the batch were processed, and at least one file have status SUCCESS
FAILEDThe batch did not generated any leaf files with status SUCCESS

The messages with FAILED status have the key statusDetails. The statusDetails are just informative and should not be used programatically.

{
"id": "996aea67-52bc-4d4b-9b77-028756dc0ee9",
"leafUserId": "ede8f781-1d55-4b2d-83a1-6785ddab6e1d",
"fileName": "Climate.zip",
"size": 8652951,
"provider": "Other",
"status": "FAILED",
"statusDetails": "No operation found. Check file format before re-trying or contact support. Check file format before re-trying or contact support",
"uploadTimestamp": "2021-03-12T19:50:55.567755Z"
}

The following status can be present on statusDetails:

StatusDescription
No valid files foundUnable to find a valid file based on supported extensions and expected file structure
Leaf internal error. Please contact SupportInternal error that need to be reported
Files found but unable to read. Please check file format before re-trying or contact SupportA valid file was found but could not be converted

Get Batch upload

ย GET /batch/{batch_id}

Once you've uploaded files, you can then query these files individually, merge the files, or query for them via Get all Files. You can also query the batch upload ID to see a list of files generated in the upload and a status of the upload with this endpoint.

import requests
TOKEN = 'YOUR_TOKEN'
endpoint = 'https://api.withleaf.io/services/operations/api/batch/{batch_id}'
headers = {'Authorization': f'Bearer {TOKEN}'}
response = requests.put(endpoint, headers=headers)
print(response.json())
Response:

When you query a batch upload ID, you will receive a single JSON object:

{
"id": "f893c921-0f38-4f39-9f3e-be765ac61df0",
"leafUserId": "bdf5f624-fb9b-4294-949c-29e979f0ce5a",
"provider": "Other",
"status": "PROCESSED",
"leafFiles": [
"8334f4bb-48de-44e2-903b-6dedd6db6683",
"81778f58-8eed-41cc-a025-e653ea85b01e",
"0f606bef-b529-4899-854c-9b698cd08762",
"84fec273-b458-4be7-8feb-44204502f126",
"92b7367b-2ffd-4a82-ba9b-5a40e8b68714",
"90e7e130-8f33-4752-b8f4-3a132246f047",
"cb97857e-61b0-4fbe-a5c1-1083cfa6738f",
"0cded205-7734-40fb-8906-b82d36e35845",
"dc24d491-983c-4ebe-b961-8c749943529f",
"67af8697-47bc-4886-935f-5880d1eba31d",
"8b7d8b7b-e682-4c3e-aee2-3b7713cc81a4",
"e5067ed3-8463-43b9-a8a5-3b3c1eee44bc",
"b9d30d3a-0207-410f-81da-afb31a1b36cb",
"eace9b90-a520-4c4c-af89-4c3fd5da68fa",
"6ea55c68-203f-448b-9e7f-dcd014c31cc3"
]
}

Get all Batches

ย GET /batch

Once you've uploaded files, you can then query these files individually, merge the files, or query for them via Get all Files. You can also query the batch upload ID to see a list of files generated in the upload and a status of the upload with this endpoint.

import requests
TOKEN = 'YOUR_TOKEN'
endpoint = 'https://api.withleaf.io/services/operations/api/batch'
headers = {'Authorization': f'Bearer {TOKEN}'}
response = requests.put(endpoint, headers=headers)
print(response.json())
Response:

When you query a batch upload ID, you will receive a JSON with list of batches:

[
{
"id": "f893c921-0f38-4f39-9f3e-be765ac61df0",
"leafUserId": "bdf5f624-fb9b-4294-949c-29e979f0ce5a",
"provider": "Other",
"status": "PROCESSED",
"leafFiles": [
"8334f4bb-48de-44e2-903b-6dedd6db6683",
"81778f58-8eed-41cc-a025-e653ea85b01e",
"0f606bef-b529-4899-854c-9b698cd08762",
"84fec273-b458-4be7-8feb-44204502f126",
"92b7367b-2ffd-4a82-ba9b-5a40e8b68714",
"90e7e130-8f33-4752-b8f4-3a132246f047",
"cb97857e-61b0-4fbe-a5c1-1083cfa6738f",
"0cded205-7734-40fb-8906-b82d36e35845",
"dc24d491-983c-4ebe-b961-8c749943529f",
"67af8697-47bc-4886-935f-5880d1eba31d",
"8b7d8b7b-e682-4c3e-aee2-3b7713cc81a4",
"e5067ed3-8463-43b9-a8a5-3b3c1eee44bc",
"b9d30d3a-0207-410f-81da-afb31a1b36cb",
"eace9b90-a520-4c4c-af89-4c3fd5da68fa",
"6ea55c68-203f-448b-9e7f-dcd014c31cc3"
]
}
]

Retry a batch

ย PUT /batch/{id}/retry

If a batch upload does not complete as expected, this endpoint allows you to try again. This action will reprocess the fragments of uploaded data that didn't succeed processing before, keeping existing converted files unaffected.

curl -X PUT \
-H 'Authorization: Bearer YOUR_TOKEN' \
'https://api.withleaf.io/services/operations/api/batch/{id}/retry'
Response

Returns a single JSON object, similar to the upload endpoint response:

{
"id": "uuid",
"leafUserId": "uuid",
"fileName": "filename.zip",
"size": 8652951,
"provider": "Other",
"status": "RECEIVED",
"uploadTimestamp": "2021-03-12T19:50:55.567755Z"
}

Merge files

ย POST /files/merge

Posts a merge operation to our server.

A merge operation is performed asynchronously. This call will return immediately with the newly created file entry, but at this point, the file is not already processed and available. You will need to make a new GET /files request for the new id and check the status. A status value of processed means the file is done merging.

A merge process has some validations, the files passed must belong to the same leafUserId, be of the same operation type and have the status as processed. If any of those filters fail, the endpoint will result in HTTP 400 error.

It receives a single JSON object with the ids entry. Example:

{
"ids": [ "id1", "id2", "so on" ]
}
curl -X POST \
-H 'Authorization: Bearer YOUR_TOKEN' \
-d '{ "ids": [ "id1", "id2" ] }'
'https://api.withleaf.io/services/operations/api/files/merge'

Returns a single JSON object:

{
"id": "id",
"status": "SENT_TO_MERGE"
}

After a few minutes, you can consult the result of Leaf processing over this file by performing GET consults in this.

Get a file status

ย GET /files/{id}/status

Get status by file processing step by id.

curl -X PUT \
-H 'Authorization: Bearer YOUR_TOKEN' \
'https://api.withleaf.io/services/operations/api/files/{id}/status'

Response

{
"rawGeojson": {
"status": "processed",
"message": "ok"
},
"normalizedGeojson": {
"status": "processed",
"message": "ok"
},
"standardGeojson": {
"status": "processed",
"message": "ok"
},
"propertiesPNGs": {
"status": "processed",
"message": "ok"
},
"areaAndYield": {
"status": "processed",
"message": "ok"
},
"summary": {
"status": "processed",
"message": "ok"
},
"units": {
"status": "processed",
"message": "ok"
},
"originalFile": {
"status": "processed",
"message": "ok"
},
"cleanupGeojson": {
"status": "processed",
"message": "ok"
}
}

Alerts

With Alerts you can be notified when something happens or changes instead of needing to repeatedly query for changes. Leaf Alerts support events that happen within Leaf and events that happen within supported 3rd party software.

List of Operations Events

Leaf Operations Service can Alert you on these events: list of Operations Events