# API ### Overview The main purpose of the CropNet server is to store and process weather data from the HOBO ONSET and CAMPBELL SCIENTIFIC weather stations in Hawaii and Guam. The stored weather data can be accessed through the URL queries. The CropNet server starts updating the database at 1:00 a.m. (Hawaii Local Time) in Hawaii and at 1:00 a.m. (Guam Local Time) in Guam. This process takes about one hour. The server provides reference evapotranspiration forecasts at each weather station for 1-3 days ahead. It also provides rainfall forecasts at each weather station for 1 day ahead. An Application Programming Interface (API) is developed for each weather station. Using the developed APIs, reference evapotranspiration and rainfall forecasts can be easily incorporated into CropManage.
### List of Stations This API uses the serial number or the code of each station to access the data. The following table lists all the available stations.
Serial No. Name Time Zone Latest Data Forecasts
21356106 ALOUN HELEMANO HOBO Hawaii 2024-05-17 [...]
21356099 HIRAKO HOBO Hawaii 2024-05-17 [...]
21356102 TEXEIRA HOBO Hawaii 2024-05-17 [...]
21356104 KULA AG PARK HOBO Hawaii 2024-05-17 [...]
21356101 MA'O HOBO Hawaii 2024-05-17 [...]
21446538 SEIZEN HOBO Hawaii 2024-05-17 [...]
PH1 CORTEVA GAY CAMPBELL Hawaii 2024-05-14 [...]
PH2 CORTEVA HELENANO CAMPBELL Hawaii 2024-05-17 [...]
GR1 WAIALUA Hawaii 2024-05-17 [...]
KMO KEMOO Hawaii 2024-05-17 [...]
21356103 WATSON HOBO Guam 2024-05-18 [...]
21356100 WUSSTIG HOBO Guam 2024-05-18 [...]
21356105 YIGO WATSO HOBO Guam 2024-05-18 [...]

### Get Daily Data This is the template URL to obtain the measured data by each individual station at any available date. The output is presented in JSON format and can be parsed in any programming languages.
https://cropnet.eng.hawaii.edu/api/<serial>/<date> + **serial**: The serial number or the code of a station listed [above](#list) + **date**: The measurement date in the YYYY-MM-DD format. https://cropnet.eng.hawaii.edu/api/<serial> **NOTE:** If `date` is not provided, the most recent collected data would be returned. *Example:* [https://cropnet.eng.hawaii.edu/api/21356106/2023-02-04](https://cropnet.eng.hawaii.edu/api/21356106/2023-02-04) which returns the following JSON that holds *Feb/04/2023* measurements for *ALOUN HELEMANO HOBO* station. ``` { "Data": { "ETo": "0.036", "Rain": "0.861", "Tmax": "21.61", "Tmin": "17.66" }, "Date": "2023-02-04", "Serial": "21356106", "Station": { "GPS": "21 32 8.9 N 158 02 05.0 W", "name": "ALOUN_HELEMANO New", "timeZone": "US/Hawaii" }, "Status": "success", "Units": { "ETo": "Inch/day", "Rainfall": "Inch", "Temperature": "Celsius" } } ``` The **Status** field is set to **"success"** if data is available and the query is successful, otherwise it is set to **"failed"**.
### Getting Historical Data Below is the template URL to obtain gap-filled ET and rainfall data from each station between two specific dates:
https://cropnet.eng.hawaii.edu/api/<serial>/<startdate>/<enddate> + **serial**: The serial number or the code of a station listed [above](#list) + **start date**: The starting date in the YYYY-MM-DD format. + **end date**: The ending date in the YYYY-MM-DD format. *Example:* [https://cropnet.eng.hawaii.edu/api/21356106/2023-02-04/2023-03-05](https://cropnet.eng.hawaii.edu/api/21356106/2023-02-04/2023-03-05) returns *ET* and *Rainfall* data between 04 February 2023 and 05 March 2023 for *ALOUN HELEMANO HOBO* station
### Get Daily Forecasts Here is the template URL to get the latest generated forecast for the coming days. Evapotranspiration (ETo) is predicted for the 1, 2 and 3 day(s) ahead. Rainfall is predicted for the next day. The output is returned in JSON format and can be parsed in any programming languages.
https://cropnet.eng.hawaii.edu/api/forecast/<serial>
+ **serial**: The serial number or the code of a station listed [above](#list) *Example:* [https://cropnet.eng.hawaii.edu/api/forecast/PH2](https://cropnet.eng.hawaii.edu/api/forecast/PH2) This returns the latest forecast data. **Note** that the following output example has been generated on the day of preparing this document. Therefore, the current output results depend on the day of sending of the query. The historical forecasts are not available at this time and only the latest forecasts are provided via this API. Some brief information about some of the parameters are provided in the **Metadata** field. Other parameters are self explanatory. The structure of the output JSON data might be slightly different than the following data as necasary updated as we upgrade/update the API and the back-end pipeline. ``` { "ETo_ave3": "0.173", "Forecast": { "Day1_ahead": { "Date": "2021-07-13", "ETo": { "ETo": "0.166", "MAE": "0.027", "R2": "0.54" }, "Rain": { "MAE": "0.139", "R2": "0.67", "Rain": "0.031" } }, "Day2_ahead": { "Date": "2021-07-14", "ETo": { "ETo": "0.166", "MAE": "0.029", "R2": "0.48" } }, "Day3_ahead": { "Date": "2021-07-15", "ETo": { "ETo": "0.167", "MAE": "0.030", "R2": "0.46" } } }, "Last_date": "2021-07-12", "Metadata": { "ETo_ave3": "The average of the measured ETo in the previous three days", "Last_date": "The most recent date with available measurements", "MAE": "Mean Absolute Error of the model that is evaluated based on the training data", "R2": "R-squared, a statistical measure of how closely the model fits the data", "Rain_ave3": "The average of the measured rainfall in the previous three days", "last_update": "The server clock when the latest forecasts were processed" }, "Rain_ave3": "0.017", "Serial": "PH2", "Station": { "GPS": "21.565335N -158.097097W", "Name": "CORTEVA HELENANO CAMPBELL", "timeZone": "US/Hawaii" }, "Units": { "ETo": "Inch/day", "Rainfall": "Inch", "Temperature": "Celsius" }, "last_update": "2021-07-13 02:03:23 HST", "status": "success" } ```