Skip to content

Commit 539c9f6

Browse files
authored
initial work on the device docs (#30)
* initial work on the device docs * address Tony's comments * update /deletedeviceaoi
1 parent 7310b49 commit 539c9f6

1 file changed

Lines changed: 173 additions & 1 deletion

File tree

pasturekey.md

Lines changed: 173 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,31 @@ See our
66
[online Pasture Key API docs](https://data.pasturekey.cibolabs.com/swagger)
77
for the list of endpoints.
88

9+
## Introduction
10+
11+
The Pasture Key API supports two Pasture Key related services:
12+
13+
1. Pasture Key properties
14+
2. Pasture Key Devices
15+
16+
** Pasture Key properties **
17+
18+
A Pasture Key property is associated with one or more paddocks. Users create their property and map their paddocks using the the Cibolabs application (the frontend).
19+
20+
The backend processes satellite imagery for the property's paddocks.
21+
22+
A property's data is retrievable via the pasturekey endpoints by specifying the property ID and optional paddock IDs. See the examples below.
23+
24+
** Pasture Key devices **
25+
26+
A Pasture Key device is associated with one or more areas of interest (AOIs). A device and its AOIs are created (and deleted) using the device endpoints. See the device examples below.
27+
28+
Once AOIs have been added in this manner the backend will process the imagery.
29+
There will be a delay before the data is available to be queried.
30+
31+
A device's data is retrievable using the pasture key endpoints. When using these endpoints for a device, specify the device ID (instead of the property ID) and optional AOI IDs (instead of paddock IDs).
32+
33+
934
## Examples
1035

1136
These examples use the curl program in a linux terminal
@@ -463,7 +488,7 @@ Note the expiry time in the URL.
463488

464489
**Request**
465490

466-
GET https://data-uat.pasturekey.cibolabs.com/downloaddata/20250521/e354f641-fce2-4299-a7d4-561dc31597d2?product=nbar&product=tsdm
491+
GET https://data.pasturekey.cibolabs.com/downloaddata/20250521/e354f641-fce2-4299-a7d4-561dc31597d2?product=nbar&product=tsdm
467492

468493
```bash
469494
imagedate="20250210"
@@ -542,6 +567,153 @@ order_894.zip 100%[=============================================
542567
2025-05-29 06:47:37 (161 MB/s) - ‘order_894.zip’ saved [1183718/1183718]
543568
```
544569

570+
571+
### /newdevice
572+
573+
Create a new device and return the device ID. This is a POST request and takes no parameters. The returned
574+
JSON contains the newly allocated device ID. This device ID can be used with the /adddevicepointaoi endpoint
575+
as described below.
576+
577+
** Request **
578+
579+
```bash
580+
curl -s -X POST \
581+
--output data.json \
582+
-H "Content-Type: application/json" \
583+
-H "Authorization: Bearer ${TOKEN}" \
584+
"https://data.pasturekey.cibolabs.com/newdevice"
585+
```
586+
587+
** Response **
588+
589+
```json
590+
{
591+
"device_id": "cbcd085f-0865-46d8-b496-ce5c2291943b"
592+
}
593+
```
594+
595+
### /adddevicepointaoi
596+
597+
Add an AOI to an existing device. The is a POST request and it takes parameters on the endpoint
598+
path. These parameters describe the AOI its center and radius in decimal degrees. The response
599+
is JSON and contains the AOI ID of the newly created AOI.
600+
601+
Once the AOI is added and the backprocessing has completed then data will be able to be
602+
queried on the device and AOI with the endpoints described above.
603+
604+
** Request **
605+
606+
```bash
607+
device_id=cbcd085f-0865-46d8-b496-ce5c2291943b
608+
longitude=144.1
609+
latitude=-27.1
610+
radius=0.00001
611+
curl -s -X POST \
612+
--output data.json \
613+
-H "Content-Type: application/json" \
614+
-H "Authorization: Bearer ${TOKEN}" \
615+
"https://data.pasturekey.cibolabs.com/adddevicepointaoi/${device_id}/${longitude}/${latitude}/${radius}"
616+
```
617+
618+
** Response **
619+
620+
```json
621+
{
622+
"aoi_id": "8531fb3f-3fdd-4f19-a95a-071d9f0b2fc3"
623+
}
624+
```
625+
626+
### /deletedeviceaoi
627+
628+
Delete a device AOI. This is a POST request and takes the device ID and AOI ID as a path parameters.
629+
Once a call to the endpoint has been made, the data for the AOI will no longer be updated
630+
by the backend.
631+
632+
```bash
633+
device_id=cbcd085f-0865-46d8-b496-ce5c2291943b
634+
aoi_id=8531fb3f-3fdd-4f19-a95a-071d9f0b2fc3
635+
curl -s -X POST \
636+
--output data.json \
637+
-H "Content-Type: application/json" \
638+
-H "Authorization: Bearer ${TOKEN}" \
639+
"https://data.pasturekey.cibolabs.com/deletedeviceaoi/${device_id}/${aoi_id}"
640+
```
641+
642+
** Response **
643+
644+
```json
645+
{
646+
"message": "AOI 8531fb3f-3fdd-4f19-a95a-071d9f0b2fc3 deleted"
647+
}
648+
```
649+
650+
### /canceldevice
651+
652+
Cancel a device. Any AOIs for the device will no longer be updated by the backend.
653+
This endpoint takes a single path parameter which is the device ID. This is a POST
654+
request.
655+
656+
** Request **
657+
658+
```bash
659+
device_id=cbcd085f-0865-46d8-b496-ce5c2291943b
660+
curl -s -X POST \
661+
--output data.json \
662+
-H "Content-Type: application/json" \
663+
-H "Authorization: Bearer ${TOKEN}" \
664+
"https://data.pasturekey.cibolabs.com/canceldevice/${device_id}"
665+
```
666+
667+
** Response **
668+
669+
```json
670+
{
671+
"message": "Device cbcd085f-0865-46d8-b496-ce5c2291943b deleted"
672+
}
673+
```
674+
675+
## Device examples
676+
677+
Below is a worked example for the device endpoints. It creates a new device and AOI then deletes them.
678+
679+
```bash
680+
# create a new device and save the device_id into newdevice.json
681+
curl -s -X POST \
682+
--output newdevice.json \
683+
-H "Content-Type: application/json" \
684+
-H "Authorization: Bearer ${TOKEN}" \
685+
"https://data.pasturekey.cibolabs.com/newdevice"
686+
687+
# using the device_id from above, create a new aoi
688+
device_id=`cat newdevice.json | jq -r '.device_id'`
689+
longitude=144.1
690+
latitude=-27.1
691+
radius=0.00001
692+
curl -s -X POST \
693+
--output newaoi.json \
694+
-H "Content-Type: application/json" \
695+
-H "Authorization: Bearer ${TOKEN}" \
696+
"https://data.pasturekey.cibolabs.com/adddevicepointaoi/${device_id}/${longitude}/${latitude}/${radius}"
697+
698+
# extract the AOI id
699+
aoi_id=`cat newaoi.json | jq -r '.aoi_id'`
700+
701+
# Now delete the AOI
702+
curl -s -X POST \
703+
--output data.json \
704+
-H "Content-Type: application/json" \
705+
-H "Authorization: Bearer ${TOKEN}" \
706+
"https://data.pasturekey.cibolabs.com/deletedeviceaoi/${device_id}/${aoi_id}"
707+
708+
# and the device
709+
curl -s -X POST \
710+
--output data.json \
711+
-H "Content-Type: application/json" \
712+
-H "Authorization: Bearer ${TOKEN}" \
713+
"https://data.pasturekey.cibolabs.com/canceldevice/${device_id}"
714+
```
715+
716+
545717
## Chaining
546718

547719
You can chain multiple calls to the PastureKey API endpoints together, in sequence.

0 commit comments

Comments
 (0)