hievpy

HIEvPy is a python wrapper around the API interface of the HIEv, a data capture application used by the Hawkesbury Institute for the Environment at Western Sydney University.

View the Project on GitHub gdevine/hievpy

To search for records within the HIEv, you can use the hievpy search function:

import hievpy as hp
hp.search(api_token, base_url, search_params)

where

  1. api_token: HIEv API token string
  2. base_url: the base url string of the HIEv instance
  3. search_params: Object containing metadata key-value pairs for searching

The following search parameters may be used: (see this link for further information )

It is highly recommended that you supply at least one search query to your search to limit returning the full database in one call

Example

You can download a Jupyter notebook version of this example from the /examples folder on the github project page.

As an example, to search for all records matching the filename ‘DRL_AUTO_450LO_SOIL_R’ between 2nd January 2017 and 1st Januaruy 2018, and then print the resulting filenames to screen:

Import hievpy library
import hievpy as hp
Import the credentials file (or use your preset environment variable) and set the API token
import credentials as c
api_token = c.hiev_api_key
Set the base URL of the HIEv instance being called against
base_url = 'https://hiev.westernsydney.edu.au/'
Set the search parameters
search_params = {"filename": "DRL_AUTO_450LO_SOIL_R",
                 "from_date": "2017-01-02",
                 "to_date": "2018-01-01"}
Run the hievpy search function using the search parameters
records = hp.search(api_token, base_url, search_params)
Check the results
for record in records: print(record['filename'])
DRL_AUTO_450LO_SOIL_R_20171130.dat
DRL_AUTO_450LO_SOIL_R_20170131.dat
DRL_AUTO_450LO_SOIL_R_20170731.dat
DRL_AUTO_450LO_SOIL_R_20170430.dat
DRL_AUTO_450LO_SOIL_R_20171031.dat
DRL_AUTO_450LO_SOIL_R_20170331.dat
DRL_AUTO_450LO_SOIL_R_20170228.dat
DRL_AUTO_450LO_SOIL_R_20170630.dat
DRL_AUTO_450LO_SOIL_R_20180131.dat
DRL_AUTO_450LO_SOIL_R_20170531.dat
DRL_AUTO_450LO_SOIL_R_20170930.dat
DRL_AUTO_450LO_SOIL_R_20170831.dat
DRL_AUTO_450LO_SOIL_R_20171231.dat `