The Gro Intelligence Python API client library provides access to Gro's agricultural data platform.
Please see our developer documentation at https://developers.gro-intelligence.com/ for install instructions, API reference documentation, and guides.
The short version:
- Install the
library:
pip install groclient
orconda install -c conda-forge groclient
- Get an API authentication token.
- Check out the examples below.
Navigate to api/client/samples/ and try executing the provided examples.
-
Start with quick_start.py. This script creates an authenticated
GroClient
object and uses theget_data_series()
andget_data_points()
methods to find Area Harvested series for Ukrainian Wheat from a variety of different sources and output the time series points to a CSV file. You will likely want to revisit this script as a starting point for building your own scripts.Note that the script assumes you have your authentication token set to a
GROAPI_TOKEN
environment variable (see Saving your token as an environment variable). If you don't wish to use environment variables, you can modify the sample script to setACCESS_TOKEN
in some other way.python quick_start.py
If the API client is installed and your authentication token is set, a csv file called
gro_client_output.csv
should be created in the directory where the script was run. -
Try out soybeans.py to see the
CropModel
class and itscompute_crop_weighted_series()
method in action. In this example, NDVI (Normalized difference vegetation index) for provinces in Brazil is weighted against each province's historical soybean production to put the latest NDVI values into context. This information is put into a pandas dataframe, the description of which is printed to the console.python crop_models/soybeans.py
-
See brazil_soybeans.ipynb for a longer, more detailed demonstration of many of the API's capabilities in the form of a Jupyter notebook.
-
You can also use the included
gro_client
tool as a quick way to request a single data series right on the command line. Try the following:gro_client --metric="Production Quantity mass" --item="Corn" --region="United States" --token YOUR_GRO_API_TOKEN
The
gro_client
command line interface does a keyword search for the inputs and finds a random matching data series. It displays the data series it picked and the data points to the console. This tool is useful for simple queries, but anything more complex should be done using the provided Python packages.