Skip to content

Repository files navigation

idigbio-python-client

A python client for the iDigBio iDigBio v2 API.

Installation

pip install idigbio

If you want to use the Pandas Data Frame interface you need to install pandas as well.

pip install idigbio pandas

If you see InsecurePlatformWarning or have other SSL certificate verification issues, you may wish to install urllib3 with the secure extra.

pip install urllib3[secure]

Basic Usage

Returning JSON from the API.

importidigbioapi=idigbio.json()
json_output=api.search_records()

Returning a Pandas Data Frame.

importidigbioapi=idigbio.pandas()
pandas_output=api.search_records()

See the Search API docs for info about the endpoint parameters.

Examples

View a Record By UUID

importidigbioapi=idigbio.json()
record=api.view("records","1db58713-1c7f-4838-802d-be784e444c4a")

Search for a Record by scientific name

importidigbioapi=idigbio.json()
record_list=api.search_records(rq={"scientificname": "puma concolor"})

Search for Records that have images

importidigbioapi=idigbio.json()
record_list=api.search_records(rq={"scientificname": "puma concolor", "hasImage": True})

Search for a MediaRecords by record property

importidigbioapi=idigbio.json()
mediarecord_list=api.search_media(rq={"scientificname": "puma concolor", "hasImage": True})

Create a heat map for a genus

importidigbioapi=idigbio.json()
m=api.create_map(rq={"genus": "acer"}, t="geohash")
m.save_map_image("acer_map_geohash", 2)

Create a point map for a genus

importidigbioapi=idigbio.json()
m=api.create_map(rq={"genus": "acer"}, t="points")
m.save_map_image("acer_map_points", 2)

Create a zoomed in point map for a bounding box

importidigbioapi=idigbio.json()
bbox= {"type": "geo_bounding_box", "bottom_right": {"lat": 29.642979999999998, "lon": -82.00}, "top_left": {"lat": 29.66298, "lon": -82.35315800000001}}
m=api.create_map(
rq={"geopoint": bbox}
)
m.save_map_image("test.png", None, bbox=bbox)

Create a summary of kingdom and phylum data

importidigbioapi=idigbio.json()
summary_data=api.top_records(fields=["kingdom", "phylum"])

Get the number of Records for a search by scientific name

importidigbioapi=idigbio.json()
count=api.count_records(rq={"scientificname": "puma concolor"})

Get the number of MediaRecords for a search by scientific name

importidigbioapi=idigbio.json()
count=api.count_media(rq={"scientificname": "puma concolor"})

Get the histogram of Collection Dates for a search by record property, for the last 10 years

importidigbioapi=idigbio.json()
histogram_data=api.datehist(
rq={"scientificname": "puma concolor"},
top_fields=["institutioncode"], min_date="2005-01-01")

Development

To contribute code to this project, please submit a pull request to the repo on github:

https://github.com/idigbio/idigbio-python-client/

To set up a development environment, run the following from inside a python virtual environment in your local repo directory:

pip install -e .

About

A python client for the idigbio v2 API

Resources

Stars

11 stars

Watchers

13 watching

Forks

Releases

Packages

Used by

Contributors

Languages