Endpoints
About
Here we list all the available endpoints from Fields API. For easily calling them, we recommend using Leaf's Postman collection.
All HTTP methods should be prepended by this service's endpoint:
There is a REST resources section if you want to check it out.
This service has the following endpoints available:
Description | Endpoints |
---|---|
Get all fields | GET /fields |
Get a field | GET /users/{id}/fields/{id} |
Create a field | POST /users/{id}/fields |
Get all operations of a field | GET /users/{id}/fields/{id}/operations |
Get an operation of a field | GET /users/{id}/fields/{id}/operations/{id} |
Get fields by geometry | POST /fields/query/intersects |
Get intersection of fields | POST /users/{id}/fields/intersect |
Delete a field | DELETE /users/{id}/fields/{id} |
Get all farms | GET /farms |
Get a farm | GET /users/{id}/farms/{id} |
Get all growers | GET /growers |
Get a grower | GET /growers/{id} |
Endpoints
Get all fields
 GET /fields
Gets a paged list of Fields. It is possible to filter the results by passing some query parameters.
type
, only matches fields with this type (string).provider
, only matches fields from this provider (string).leafUserId
, only matches fields from this user (string).page
, an integer specifying the page being fetched.size
, an integer specifying the size of the page (defaults to 20).
These last two parameters are used exclusively for paging through results.
Response
A JSON array containing Fields.
- cURL
- Python
- JavaScript
- JSON Response
Get a field
 GET /users/{id}/fields/{id}
Gets a single Field by its id.
Response
A single Field as a JSON object.
- cURL
- Python
- JavaScript
Create a field
 POST /users/{id}/fields
Creates a Field for the user leafUserId
. A resquest body must be provided
containing the an entry "geometry"
, which represents the boundaries of the
Field being created as a GeoJSON geometry (it must be a "MultiPolygon"
).
The entry "id"
is optional. If no id is provided, an UUID will be generated.
The Field id CAN NOT be updated.
Request body example:
Response
A Field as a JSON object.
- cURL
- Python
- JavaScript
Get all operations of a field
 GET /users/{id}/fields/{id}/operations
Gets a paged list of all operation files of the Field and Leaf User specified in the URL.
It is possible to filter the results by passing some query parameters. They are listed below.
Parameter (to filter by) | Type | Description |
---|---|---|
operationType | String "harvested", "planted", "applied" or "other" | retrieve operations of given type |
provider | String "CNHI", "JohnDeere", "Trimble" or "ClimateFieldView" | retrieve operations of given provider |
origin | String "provider", "automerged", "merged" or "uploaded" | retrieve operations of given origin |
crop | String name of the crop, like "corn" or "soybeans". Entire crop list available here | retrieve operations with this crop. |
startTime | ISO 8601 datetime format | retrieve operations that started after this date |
endTime | ISO 8601 datetime format | retrieve operations that ended before this date |
You can also pass some parameters used exclusively for paging through results. They are:
page
, an integer specifying the page being fetchedsize
, an integer specifying the size of the page (defaults to 20)
Response
A JSON array of Files.
- cURL
- Python
- JavaScript
Get an operation of a field
 GET /users/{id}/fields/{id}/operations/{id}
Gets a single Operation File of a field by its id.
Response
A single Operation File.
- JavaScript
- Python
- cURL
Get Fields by geometry
 POST /fields/query/intersects
Gets a list of fields that intersect with the GeoJSON MultiPolygon sent in the request body.
Response
A JSON list of Fields.
- cURL
- Python
- JavaScript
- JSON sample response
Get intersection of fields
 POST /users/{id}/fields/intersect
Gets a GeoJSON MultiPolygon corresponding to the intersection of the Fields specified by the given id's. Such Field id's goes in a list, in the request body.
Response
A JSON in the format of a GeoJSON geometry.
- cURL
- Python
- JavaScript
- JSON sample response
Delete a field
 DELETE /users/{id}/fields/{id}
Deletes the field with the given id.
Get all farms
 GET /farms
Gets a paged list of all Farms. It is possible to pass some query parameters.
provider
, only matches Farms from this provider (string)leafUserId
, only matches Farms from this Leaf User (UUID)page
, an integer specifying the page being fetchedsize
, an integer specifying the size of the page (defaults to 20)
The parameters are used exclusively for paging through results.
Response
A JSON array containing Farms.
- cURL
- Python
- JavaScript
- JSON Response
Get a farm
 GET /users/{id}/farms/{id}
Gets a single Farm by its id.
Response
A single Farm as a JSON object.
- cURL
- Python
- JavaScript
- JSON Response
Get all growers
 GET /growers
Gets a paged list of all Growers. Use the following parameters for paging through results.
provider
, only matches Growers from this provider (string)leafUserId
, only matches Growers from this Leaf User (UUID)page
, an integer specifying the page being fetchedsize
, an integer specifying the size of the page (defaults to 20)
Response
A JSON array containing Growers.
- cURL
- Python
- JavaScript
- JSON Response
Get a grower
 GET /growers/{id}
Gets a single Grower by its id.
Response
A single Grower as a JSON object.
- cURL
- Python
- JavaScript
- JSON Response
REST Resources
See below the REST resources and their endpoints.
Field Resource
A field might have one or neither of the following keys:
- a "mergedFieldId" key or
- a "sources" key
A Field will only have one of the previous keys if it is either a field that has been merged with other one(s) or if it is a result of a merge. Leaf merges fields that have any sort of overlap. This makes it easier for you to query operations from a field by querying by the merged field. Because a field might exist in multiple providers, Leaf detects that and creates a single field that you can query for - and you can still query by the individual fields too.
Description | Endpoints |
---|---|
Get all fields | GET /fields |
Get a field | GET /users/{id}/fields/{id} |
Create a field | POST /users/{id}/fields |
Get fields by geometry | POST /fields/query/intersects |
Get intersection of fields | POST /users/{id}/fields/intersect |
Delete a field | DELETE /users/{id}/fields/{id} |
Operation Resource
Description | Endpoints |
---|---|
Get all operations of a field | GET /users/{id}/fields/{id}/operations |
Get an operation of a field | GET /users/{id}/fields/{id}/operations/{id} |
Farm Resource
Description | Endpoints |
---|---|
Get all farms | GET /farms |
Get a farm | GET /users/{id}/farms/{id} |
Grower Resource
Description | Endpoints |
---|---|
Get all growers | GET /growers |
Get a grower | GET /growers/{id} |