Tutorial

Translating USB Thumb Drive Data with Leaf

Easily translate local raw monitor data



     Farm data management is moving to the cloud, but there are often still instances where you need to manage local machine data files. 

     Below is a quick guide to upload and translate your user's thumb drive files via Leaf. Let's go!

Get API Keys and Start Building Today!

Summary

Step 1: Authentication with Leaf

     First you will need to create a Leaf account via User registration. (In the case you are already registered with Leaf, you can skip this step).

     You will then receive an activation email and will need to click "activate" in that email. After that you can use your username and password to generate a token that will give you access to Leaf's API. To do this,  POST:

https://api.withleaf.io/api/authenticate

     

     The response of the request should look like this:

     

     The token generated will grant permission to access our services and should be embedded as a header on all other requests to Leaf's API.

 

Step 2: Find Our Sample Leaf User

     In production, it's best to create new users in Leaf to organize individual farmer's data. For now, we add a sample user with sample data to each new Leaf account. We're going to find that user and then upload some data to it. Let's find the sample user with this endpoint.

     The response should contain at least the sample Leaf User that will be used to manage other resources inside Leaf’s services. You'll notice the user has an "id" key. This id will be used to specify to which user we are uploading the data. 

Step 3: Upload A File To Be Converted  

     Great! Now, we will upload the raw local files from the monitor (often found on thumb drives, so we call it thumb drive data) into Leaf (check if Leaf has support for your monitor data here). Make sure to have all your thumb drive data downloaded into .zip files in order to use the following endpoint. Leaf will recursively unzip and identify which files are in the uploaded folder and then send them through the appropriate translation process.

Sent a POST to:

https://api.withleaf.io/services/operations/api/batch?leafUserId=leafUserId&provider=Other

     Each one of the compressed folders can be inserted in the body of the request as a payload, with CURL we have the following format.

 

     Or, you can use our Postman Collection to select your file by clicking on the highlighted button.

 

Step 4: Retrieve The Converted File

     The previous request should generate a batch_id which will contain a list of Leaf Files processed from the original uploaded files. These files can be accessed using the endpoint.

     There you have it! A list with your Leaf Files and their translated GeoJSON's, summaries, Field Operations, and Images will be available for you to use. This same format is used for files coming in via connected APIs so local files and remote files can be used interchangeably in your apps. 

 

Schedule a Call With Our Team Today

     Software developers use Leaf’s API to build and scale a wide range of products including farm optimization tools, lending products, outcome-based financing, land and input marketplaces, agronomic recommendations, traceability applications, equipment maintenance forecasting, and more.

Learn more at Leaf’s website.

Similar posts

Stay in the loop with all of Leaf's future insights, technical updates and latest case studies.

Subscribe to receive our monthly newsletter and newest blog posts with industry leading insights, company updates and more.