The examples on this page can be called using curl or wget, by passing your API key as x-api-key in the header.
Example curl request:
curl -H "x-api-key: your api key" "https://api.precisionsustainableag.org/onfarm/raw?table=biomass_in_field&affiliation=MD"
Each table below includes a protocols column, which has flags to indicate which parts of the on-farm experiment each site completed:
For additional documentation on the meaning of each column and table, see https://github.com/precision-sustainable-ag/crowndb-public/wiki
These tables can be filtered by code, year, affiliation, producer_id, last_name, and subplot. You can have multiple filters, and each filter can contain multiple items.
Table:
Affiliation:
Column completeness:
Tables weather and rainfall can also be filtered by a range of dates.
Example:
PATHonfarm/raw?table=rainfall&start=2017-11-05&end=2017-11-08
These tables can be queried and filtered by serial numbers, timestamps, and project IDs (if applicable).
Example: ambient_sensor_data, serial no 18000147, start date July 1 2020, end date July 30 2020:
PATHonfarm/raw?table=ambient_sensor_data&serial_no=18000147&start=2020-07-01&end=2020-07-30
Table stresscam_ratings can be filtered by device:
PATHonfarm/raw?table=stresscam_ratings&device=1047782
You can get the number of rows for any query using this parameter:
summary=true
Example: Number of producers:
PATHonfarm/raw?table=producer_ids&summary=trueExample: Number of producers with affiliation MD:
PATHonfarm/raw?table=producer_ids&summary=true&affiliation=MDYou can output grouping totals using this parameter:
group=column1[,column2…]
Note that the group parameter works only in conjunction with summary=true.
Example: Number of producers per affiliation:
PATHonfarm/raw?table=producer_ids&summary=true&group=affiliationExample: Number of producers per affiliation per year:
PATHonfarm/raw?table=producer_ids&summary=true&group=affiliation,yearAny parameter that is output by a query can be used as a grouping column.
Output for all Onfarm queries can be limited to specific columns using this parameter:
cols=col1[,col2…]
Example:
PATHonfarm/raw?table=biomass_in_field&affiliation=MD&cols=cid,code,yearwater_sensor_data: | PATHonfarm/soil_moisture?type=tdr&code=lac&start=2019-06-01&end=2019-06-30 |
water_gateway_data: | PATHonfarm/soil_moisture?type=gateway&code=lac&start=2019-06-01&end=2019-06-30 |
water_node_data: | PATHonfarm/soil_moisture?type=node&code=lac&start=2019-06-01&end=2019-06-30 |
ambient_sensor_data: | PATHonfarm/soil_moisture?type=ambient&code=lac&start=2019-06-01&end=2019-06-30 |
Sensor locations can be output for these view using the parameter location=true. However, note that all lat/longs are currently null:
Example:
PATHonfarm/locationsCan be filtered by one or more codes, years, affiliations, and producer_ids. (Case-insensitive)
Examples:
Codes AAZ and DAA | PATHonfarm/locations?code=aaz,daa |
Years 2018-2019 | PATHonfarm/locations?year=2018-2019 |
Affiliation MD | PATHonfarm/locations?affiliation=MD |
Producer 2018PA002 | PATHonfarm/locations?producer_id=2018PA002 |
Example:
PATHonfarm/affiliationsReturns the entire affiliations table.
Example:
PATHonfarm/producersCan be filtered by one or more codes, years, affiliations, first_names, last_names, or producer_ids. (Case-insensitive)
Examples:
Codes AAZ and DAA | PATHonfarm/producers?code=aaz,daa |
Years 2018-2019 | PATHonfarm/producers?year=2018-2019 |
Affiliation MD | PATHonfarm/producers?affiliation=MD |
Producer 2018PA002 | PATHonfarm/producers?producer_id=2018PA002 |
Example:
PATHonfarm/datesCan be filtered by one or more codes, years, affiliations, or producer_ids. (Case-insensitive)
Examples:
Codes AAZ and DAA | PATHonfarm/dates?code=aaz,daa |
Years 2018-2019 | PATHonfarm/dates?year=2018-2019 |
Affiliation MD | PATHonfarm/dates?affiliation=MD |
Producer 2018PA002 | PATHonfarm/dates?producer_id=2018PA002 |
Parameter | Notes | |
---|---|---|
biomass | yield | PATHonfarm/biomass | This parameter calls R scripts developed by Resham Thapa. By default, all data is output in JSON format. However, the output can be changed and filtered using the parameters below. |
&output=json | csv | html | PATHonfarm/biomass?output=csv | Output defaults to json, but it can also be CSV or HTML. |
&subplot=combined | separate | 1 | 2 | PATHonfarm/biomass?subplot=combined PATHonfarm/biomass?subplot=separate PATHonfarm/biomass?subplot=1 PATHonfarm/biomass?subplot=2 | Subplots are combined by default, but they can be viewed separated or individually. |
&year=single year | range of years | PATHonfarm/biomass?year=2017-2018 | Data can be filtered by year or range of years. |
&affiliation=affiliation[,affiliation,…] | PATHonfarm/biomass?affiliation=NC,GA | Data can be filtered by one or more affiliations. |
&code=code1[,code2,…] | PATHonfarm/biomass?code=CCS,CDA | Data can be filtered by one or more site codes. |
SSURGO data can be output for table site_information by using parameters &table=site_information&ssurgo=true, along with options listed at the SSURGO documentation.
Multiple sites can be output, and sites without lat/lon will be excluded.
Examples:
Queries involving site_information exclude unenrolled sites.
To include them, use the parameter &options=include_unenrolled_sites
Description | Enrolled sites | Unenrolled sites |
---|---|---|
site_information table | PATHonfarm/raw?table=site_information&affiliation=MD | PATHonfarm/raw?table=site_information&affiliation=MD&options=include_unenrolled_sites |
Number of sites | PATHonfarm/raw?table=site_information&summary=true | PATHonfarm/raw?table=site_information&summary=true&options=include_unenrolled_sites |
Maryland producers | PATHonfarm/producers?affiliation=MD | PATHonfarm/producers?affiliation=MD&options=include_unenrolled_sites |
Maryland dates | PATHonfarm/dates?affiliation=MD | PATHonfarm/dates?affiliation=MD&options=include_unenrolled_sites |
Maryland locations | PATHonfarm/locations?affiliation=MD | PATHonfarm/locations?affiliation=MD&options=include_unenrolled_sites |