Before you start
- A Leaf account with API credentials (email and password). Register here if you don’t have one.
- At least one provider account (John Deere, Climate FieldView, CNHi, etc.) with farm data, or test data from Leaf’s sample user.
- cURL, Python 3, or Node.js installed.
Step 1: Get your Leaf token
Authenticate with your Leaf credentials to get a bearer token. This token is required for all subsequent API calls.id_token from the response. You’ll pass it as a Bearer token in the Authorization header on every request.
Step 2: Create a Leaf user
A Leaf user represents a single data owner (typically a grower or consultant). All provider credentials and data are organized under Leaf users.Your account includes a sample Leaf user with pre-loaded data. You can skip this step if you just want to explore the sample data. Query
GET /users to find it.id from the response. This is your leafUserId.
Step 3: Connect a provider
The fastest way to connect a provider is with Magic Link. It generates a shareable URL that walks the grower through OAuth without any front-end code on your side. First, configure your provider application credentials using the provider setup guides. Then create a Magic Link:link to the grower. They authenticate with their provider account, and Leaf stores the credentials automatically.
To restrict which providers appear, add "allowedProviders": ["JohnDeere", "ClimateFieldView"] to the request body.
Confirm the connection worked
After the grower completes the Magic Link flow, verify that the provider now appears for the Leaf user:cURL
Step 4: Wait for data processing
Once a provider is connected, Leaf begins syncing machine files. The sync-to-operations pipeline works like this:- Machine files are fetched from the provider and converted to Leaf’s standard canonical format (available as GeoJSON or GeoParquet).
- Field operations are created by merging machine files that overlap in time and field boundary.
Step 5: Query your field operations
Once processing finishes, query the operations for your Leaf user.operationType of planted, applied, harvested, or tillage.
Step 6: Get operation details
For any operation, you can fetch the summary (aggregated stats) and the standard GeoJSON (point-level data). Summary:yieldVolume, seedRate, appliedRate, etc. You can filter by operationType, startTime, endTime, and other parameters.
What you built
You now have a working pipeline that:- Authenticates with the Leaf API
- Creates Leaf users to represent growers
- Connects data providers via Magic Link
- Retrieves standardized field operations across providers
- Set up alerts to react to new data automatically
- Explore machine file conversion for lower-level file access
- Review configuration to tune merge behavior and data cleaning
- Try manual file upload for thumb drive data

