API Examples
Create Crop ID APS Job
- cURL
- Python
- JavaScript
const axios = require('axios')
const ADMA_API_VERSION = 'LATEST_APS_SUPPORTED_ADMA_API_VERSION' //ie. 2023-11-01-preview
const ADMA_INSTANCE_URL = 'YOUR_ADMA_INSTANCE_URL'
const TOKEN = 'YOUR_TOKEN'
const endpoint = `${ADMA_INSTANCE_URL}/solutions/bayerAgPowered.cropid:create?api-version=${ADMA_API_VERSION}`
const headers = {
'Authorization': `Bearer ${TOKEN}`,
'Content-Type': 'application/json'
}
const data = {
"requestPath": "/v1/crop-id/1234",
"partnerRequestBody": {
"partyId": "53b8f2b9-04b3-4462-ac52-9c821feb0ee2",
"startYear": "2021",
"endYear": "2023",
"resourceId": "dfa70d7c-5132-4949-bc2d-92906c838d22",
"resourceType": "Field"
}
}
axios.post(endpoint, data, headers)
.then(res => console.log(res.data))
.catch(console.error)
import requests
ADMA_API_VERSION = "LATEST_APS_SUPPORTED_ADMA_API_VERSION" # ie. 2023-11-01-preview
ADMA_INSTANCE_URL = "YOUR_ADMA_INSTANCE_URL"
ADMA_RESOURCE_ID = "YOUR_ADMA_RESOURCE_ID"
TOKEN = "YOUR_TOKEN"
endpoint = "{ADMA_INSTANCE_URL}/solutions/bayerAgPowered.cropid:create?api-version={ADMA_API_VERSION}".format(
ADMA_INSTANCE_URL=ADMA_INSTANCE_URL, ADMA_API_VERSION=ADMA_API_VERSION
)
headers = {"Authorization": "Bearer " + TOKEN, "Content-Type": "application/json"}
data = {
"requestPath": "/v1/crop-id/1234",
"partnerRequestBody": {
"partyId": "53b8f2b9-04b3-4462-ac52-9c821feb0ee2",
"startYear": "2021",
"endYear": "2023",
"resourceId": "dfa70d7c-5132-4949-bc2d-92906c838d22",
"resourceType": "Field",
},
}
response = requests.post(endpoint, json=data, headers=headers)
print(response.json())
curl --location \
--request POST '{ADMA_INSTANCE_URL}/solutions/bayerAgPowered.cropid:create?api-version={ADMA_API_VERSION}' \
--header 'Authorization: Bearer {TOKEN}' \
--header 'Content-Type: application/json' \
--data-raw '{
"requestPath": "/v1/crop-id/1234",
"partnerRequestBody": {
"partyId": "53b8f2b9-04b3-4462-ac52-9c821feb0ee2",
"startYear": "2021",
"endYear": "2023",
"resourceId": "dfa70d7c-5132-4949-bc2d-92906c838d22",
"resourceType": "Field"
}
}'
Create Job Response Sample
{
"id": "1234",
"message": "MSIMAGE-01001: Job queued successfully.",
"status": "WAITING",
"jobCreatedDateTime": "2023-04-28T00:00:00Z",
"jobLastActionDateTime": "2023-04-28T00:27:00Z",
"e2eid": "a1853978d9ae412ccd55923ca41891c7",
"partnerRequestBody": {
"solutionId": "bayerAgPowered.cropid",
"partyId": "53b8f2b9-04b3-4462-ac52-9c821feb0ee2",
"startYear": "2021",
"endYear": "2023",
"resourceId": "dfa70d7c-5132-4949-bc2d-92906c838d22",
"resourceType": "Field"
}
}
Fetch Crop ID APS Job Status
This will provide the status of the running job. Possible status values are: WAITING
, RUNNING
, SUCCEEDED
,
FAILED
, CANCELLED
.
- cURL
- Python
- JavaScript
const axios = require('axios')
const ADMA_API_VERSION = 'LATEST_APS_SUPPORTED_ADMA_API_VERSION' //ie. 2023-11-01-preview
const ADMA_INSTANCE_URL = 'YOUR_ADMA_INSTANCE_URL'
const TOKEN = 'YOUR_TOKEN'
const endpoint = `${ADMA_INSTANCE_URL}/solutions/bayerAgPowered.cropid:fetch?api-version=${ADMA_API_VERSION}`
const headers = {
'Authorization': `Bearer ${TOKEN}`,
'Content-Type': 'application/json'
}
const data = {
"requestPath":"/v1/crop-id/1234"
}
axios.post(endpoint, data, headers)
.then(res => console.log(res.data))
.catch(console.error)
import requests
ADMA_API_VERSION = "LATEST_APS_SUPPORTED_ADMA_API_VERSION" # ie. 2023-11-01-preview
ADMA_INSTANCE_URL = "YOUR_ADMA_INSTANCE_URL"
TOKEN = "YOUR_TOKEN"
endpoint = "{ADMA_INSTANCE_URL}/solutions/bayerAgPowered.cropid:fetch?api-version={ADMA_API_VERSION}".format(
ADMA_INSTANCE_URL=ADMA_INSTANCE_URL, ADMA_API_VERSION=ADMA_API_VERSION
)
headers = {"Authorization": "Bearer " + TOKEN, "Content-Type": "application/json"}
data = {"requestPath": "/v1/crop-id/1234"}
response = requests.post(endpoint, json=data, headers=headers)
print(response.json())
curl --location \
--request POST '<ADMA Instance URL>/solutions/bayerAgPowered.cropid:fetch?api-version=2022-11-01-preview' \
--header 'Authorization: Bearer <JWT>' \
--header 'Content-Type: application/json' \
--data-raw '{
"requestPath":"/v1/crop-id/1234"
}'
Fetch Job Status Response Sample
{
"id": "1234",
"message": "MSIMAGE-02001: Job is completed successfully",
"status": "SUCCEEDED",
"jobCreatedDateTime": "2023-04-28T00:00:00Z",
"jobProcessingStartDateTime": "2023-04-28T00:05:00Z",
"jobProcessingEndDateTime": "2023-04-28T00:27:00Z",
"jobLastActionDateTime": "2023-04-28T00:27:00Z",
"jobProcessincropidrationInSeconds": 22,
"e2eid": "a1853978d9ae412ccd55923ca41891c7",
"partnerRequestBody": {
"solutionId": "bayerAgPowered.cropid",
"partyId": "53b8f2b9-04b3-4462-ac52-9c821feb0ee2",
"startYear": "2021",
"endYear": "2023",
"resourceId": "dfa70d7c-5132-4949-bc2d-92906c838d22",
"resourceType": "Field"
}
}
Cancel Crop ID APS Job
Jobs can only be cancelled if they are in a cancellable state: WAITING
or RUNNING
.
- cURL
- Python
- JavaScript
const axios = require('axios')
const ADMA_API_VERSION = 'LATEST_APS_SUPPORTED_ADMA_API_VERSION' //ie. 2023-11-01-preview
const ADMA_INSTANCE_URL = 'YOUR_ADMA_INSTANCE_URL'
const TOKEN = 'YOUR_TOKEN'
const endpoint = `${ADMA_INSTANCE_URL}/solutions/bayerAgPowered.cropid:cancel?api-version=${ADMA_API_VERSION}`
const headers = {
'Authorization': `Bearer ${TOKEN}`,
'Content-Type': 'application/json'
}
const data = {
"requestPath":"/v1/crop-id/1234"
}
axios.post(endpoint, data, headers)
.then(res => console.log(res.data))
.catch(console.error)
import requests
ADMA_API_VERSION = "LATEST_APS_SUPPORTED_ADMA_API_VERSION" # ie. 2023-11-01-preview
ADMA_INSTANCE_URL = "YOUR_ADMA_INSTANCE_URL"
TOKEN = "YOUR_TOKEN"
endpoint = "{ADMA_INSTANCE_URL}/solutions/bayerAgPowered.cropid:cancel?api-version={ADMA_API_VERSION}".format(
ADMA_INSTANCE_URL=ADMA_INSTANCE_URL, ADMA_API_VERSION=ADMA_API_VERSION
)
headers = {"Authorization": "Bearer " + TOKEN, "Content-Type": "application/json"}
data = {"requestPath": "/v1/crop-id/1234"}
response = requests.post(endpoint, json=data, headers=headers)
print(response.json())
curl --location \
--request POST '{ADMA_INSTANCE_URL}/solutions/bayerAgPowered.cropid:cancel?api-version=
{ADMA_API_VERSION}' \
--header 'Authorization: Bearer {TOKEN}' \
--header 'Content-Type: application/json' \
--data-raw '{
"requestPath":"/v1/crop-id/1234"
}'
Cancel Job Response Sample
{
"id": "1234",
"message": "MSIMAGE-02002: Job is cancelled successfully.",
"status": "CANCELLED",
"jobCreatedDateTime": "2023-04-28T00:00:00Z",
"jobLastActionDateTime": "2023-04-28T00:27:00Z",
"jobProcessingStartDateTime": "2023-04-28T00:05:00Z",
"jobProcessingEndDateTime": "2023-04-28T00:27:00Z",
"jobProcessingDurationInSeconds": 22,
"e2eid": "a1853978d9ae412ccd55923ca41891c7",
"partnerRequestBody": {
"solutionId": "bayerAgPowered.cropid",
"partyId": "53b8f2b9-04b3-4462-ac52-9c821feb0ee2",
"startYear": "2021",
"endYear": "2023",
"resourceId": "dfa70d7c-5132-4949-bc2d-92906c838d22",
"resourceType": "Field"
}
}
Get Crop ID APS Output
The Crop ID APS produces a single value of the calculated Crop ID stored in a JSON output. This JSON can be accessed via the ADMA Insights API.
Insights API Request Sample
- cURL
- Python
- JavaScript
const axios = require('axios')
const ADMA_API_VERSION = 'LATEST_APS_SUPPORTED_ADMA_API_VERSION' //ie. 2023-11-01-preview
const ADMA_INSTANCE_URL = 'YOUR_ADMA_INSTANCE_URL'
const PARTY_ID = 'YOUR_ADMA_PARTY_ID'
const FIELD_ID = 'YOUR_ADMA_FIELD_ID'
const CROPID_JOB_ID = 'YOUR_CROPID_JOB_ID'
const TOKEN = 'YOUR_TOKEN'
const endpoint = `${ADMA_INSTANCE_URL}/parties/${PARTY_ID}/models/bayerAgPowered.cropid/resource-types/Field/resources/${FIELD_ID}/insights/${CROPID_JOB_ID}/?api-version=${ADMA_API_VERSION}
const headers = {
'Authorization': `Bearer ${TOKEN}`,
'Content-Type': 'application/json'
}
axios.get(endpoint, headers)
.then(res => console.log(res.data))
.catch(console.error)
import requests
ADMA_API_VERSION = "LATEST_APS_SUPPORTED_ADMA_API_VERSION" # ie. 2023-11-01-preview
ADMA_INSTANCE_URL = "YOUR_ADMA_INSTANCE_URL"
PARTY_ID = "YOUR_ADMA_PARTY_ID"
FIELD_ID = "YOUR_ADMA_FIELD_ID"
CROPID_JOB_ID = "YOUR_CROPID_JOB_ID"
TOKEN = "YOUR_TOKEN"
endpoint = "{ADMA_INSTANCE_URL}/parties/{PARTY_ID}/models/bayerAgPowered.cropid/resource-types/Field/resources/{FIELD_ID}/insights/{CROPID_JOB_ID}/?api-version={ADMA_API_VERSION}".format(
PARTY_ID=PARTY_ID,
FIELD_ID=FIELD_ID,
CROPID_JOB_ID=CROPID_JOB_ID,
ADMA_INSTANCE_URL=ADMA_INSTANCE_URL,
ADMA_API_VERSION=ADMA_API_VERSION,
)
headers = {"Authorization": "Bearer " + TOKEN, "Content-Type": "application/json"}
response = requests.get(endpoint, headers=headers)
print(response.json())
curl --location \
--request GET '{ADMA_INSTANCE_URL}/parties/{PARTY_ID}/models/bayerAgPowered.cropid/resource-types/Field/resources/{FIELD_ID}/insights/{CROPID_JOB_ID}/?api-version={ADMA_API_VERSION}'
--header 'Content-Type: application/json'
--header 'Authorization: Bearer {TOKEN}'
Response Sample
{
"calculated_representative_point": {
"lat": 41.64569965438514,
"lon": -93.92756291287111
},
"cropid_errors": [],
"cropid_summary": [
{
"area_hectares": 23.311475,
"crop_name": "soybeans",
"crop_confidence": {
"grass": 0.0044,
"other": 0.0133,
"soybeans": 0.9823
},
"crop_year": 2022,
"iou": 0.931829
}, {
"area_hectares": 23.027851,
"crop_name": "maize",
"crop_confidence": {
"grass": 0.0044,
"maize": 0.9823,
"other": 0.0133
},
"crop_year": 2023,
"iou": 0.935912
}
],
"partner_request_body": {
"model_spec": {
"endYear": 2023,
"startYear": 2022
},
"resource_id": "90c9ffec-1111-4bfc-8a52-39dacd61756c",
"resource_type": "Field"
}
}