Skip to content

Instantly share code, notes, and snippets.

const axios = require('axios')
const endpoint = 'https://api.withleaf.io/api/authenticate'
const data = { username:'username', password:'password', rememberMe:'true'}
axios.post(endpoint, { data })
.then(res => console.log(res.data))
.catch(console.error)
import requests
url = "https://api.withleaf.io/api/authenticate"
data = {'username':'your email', 'password':'your password', 'rememberMe':'true'}
headers = {'Content-Type': 'application/json'}
response = requests.request("POST", url, headers=headers, json=data)
curl -X POST \
-H 'Content-Type: application/json' \
-d '{ "username":"username", "password":"password", "rememberMe":"true" }' \
'https://api.withleaf.io/api/authenticate'
images_to_list(get_newest_image(external_id, "planet"))
['NDRE.tif',
'NDRE_color.tif',
'NDVI.tif',
'NDVI_color.tif',
'RGB.tif',
'ortho_analytic_8b_sr.tif',
'NDRE.png',
'NDRE_absolute.png',
external_id = "field_demo"
field = get_sat_field(external_id)
def get_newest_image(field_id, provider, image=None, format=None):
endpoint = f'https://api.withleaf.io/services/satellite/api/fields/{field_id}/processes'
params = {'startDate': '2023-07-21', 'maxClouds' : 5, "coverage": 100, "provider": provider, "sort": "date,desc"}
headers = {'Authorization': f'Bearer {TOKEN}'}
response = requests.get(endpoint, headers=headers, params=params)
image_info = response.json()[0]
images = image_info['images']
external_id = "field_demo"
field = get_sat_field(external_id)
def get_newest_image(field_id, provider, image=None, format=None):
endpoint = f'https://api.withleaf.io/services/satellite/api/fields/{field_id}/processes'
params = {'startDate': '2023-07-21', 'maxClouds' : 5, "coverage": 100, "provider": provider, "sort": "date,desc"}
headers = {'Authorization': f'Bearer {TOKEN}'}
response = requests.get(endpoint, headers=headers, params=params)
image_info = response.json()[0]
images = image_info['images']
def create_new_satellite_field(external_id, days_before, coordinates):
endpoint = 'https://api.withleaf.io/services/satellite/api/fields'
headers = {'Authorization': f'Bearer {TOKEN}'}
payload = {"externalId" : external_id, "providers" : providers, "daysBefore": days_before, "geometry": {"type": "MultiPolygon", "coordinates": coordinates}}
response = requests.post(endpoint, headers=headers, json=payload)
return response
external_id = 'field__demo'
providers = ['planet', 'sentinel']
days_before = 365
https://connections.deere.com/connections/{clientId}/select-organizations?redirect_uri={redirectUri}
https://api.withleaf.io/services/beta/api/users/{leafUserId}/layers?fieldId={fieldId}&provider=Sentera&type=RGB
https://api.withleaf.io/services/beta/api/users/{leafUserId}/layers?fieldId={fieldId}&provider=Sentera&type=NDVI