Skip to main content

Python client for GBIF

Project description

pygbif
======

|pypi| |docs| |ghactions| |coverage| |black|

Python client for the `GBIF API
<https://www.gbif.org/developer/summary>`_

`Source on GitHub at sckott/pygbif <https://github.com/sckott/pygbif>`_

Other GBIF clients:

* R: `rgbif`, `ropensci/rgbif <https://github.com/ropensci/rgbif>`_
* Ruby: `gbifrb`, `sckott/gbifrb <https://github.com/sckott/gbifrb>`_
* PHP: `php-gbif`, `restelae/php-gbif <https://gitlab.res-telae.cat/restelae/php-gbif>`_

Contributing: `CONTRIBUTING.md <https://github.com/sckott/pygbif/blob/master/.github/CONTRIBUTING.md>`_

Installation
============

Stable from pypi

.. code-block:: console

pip install pygbif

Development version

.. code-block:: console

[sudo] pip install git+git://github.com/sckott/pygbif.git#egg=pygbif


`pygbif` is split up into modules for each of the major groups of API methods.

* Registry - Datasets, Nodes, Installations, Networks, Organizations
* Species - Taxonomic names
* Occurrences - Occurrence data, including the download API
* Maps - Maps, get raster maps from GBIF as png or mvt

You can import the entire library, or each module individually as needed.

In addition there is a utils module, currently with one method: `wkt_rewind`, and
a `caching` method to manage whether HTTP requests are cached or not. See `?pygbif.caching`.

Registry module
===============

registry module API:

* `organizations`
* `nodes`
* `networks`
* `installations`
* `datasets`
* `dataset_metrics`
* `dataset_suggest`
* `dataset_search`

Example usage:

.. code-block:: python

from pygbif import registry
registry.dataset_metrics(uuid='3f8a1297-3259-4700-91fc-acc4170b27ce')

Species module
==============

species module API:

* `name_backbone`
* `name_suggest`
* `name_usage`
* `name_lookup`
* `name_parser`

Example usage:

.. code-block:: python

from pygbif import species
species.name_suggest(q='Puma concolor')

Occurrences module
==================

registry module API:

* `search`
* `get`
* `get_verbatim`
* `get_fragment`
* `count`
* `count_basisofrecord`
* `count_year`
* `count_datasets`
* `count_countries`
* `count_schema`
* `count_publishingcountries`
* `download`
* `download_meta`
* `download_list`
* `download_get`

Example usage:

.. code-block:: python

from pygbif import occurrences as occ
occ.search(taxonKey = 3329049)
occ.get(key = 252408386)
occ.count(isGeoreferenced = True)
occ.download('basisOfRecord = LITERATURE')
occ.download('taxonKey = 3119195')
occ.download('decimalLatitude > 50')
occ.download_list(user = "sckott", limit = 5)
occ.download_meta(key = "0000099-140929101555934")
occ.download_get("0000066-140928181241064")

Maps module
===========

maps module API:

* `map`

Example usage:

.. code-block:: python

from pygbif import maps
out = maps.map(taxonKey = 212, year = 1998, bin = "hex",
hexPerTile = 30, style = "classic-noborder.poly")
out.response
out.path
out.img
out.plot()

.. image:: https://github.com/sckott/pygbif/raw/master/gbif_map.png
:width: 25%
:scale: 25%

utils module
============

utils module API:

* `wkt_rewind`

Example usage:

.. code-block:: python

from pygbif import utils
x = 'POLYGON((144.6 13.2, 144.6 13.6, 144.9 13.6, 144.9 13.2, 144.6 13.2))'
utils.wkt_rewind(x)



Contributors
============

* `Scott Chamberlain <https://github.com/sckott>`_
* `Robert Forkel <https://github.com/xrotwang>`_
* `Jan Legind <https://github.com/jlegind>`_
* `Stijn Van Hoey <https://github.com/stijnvanhoey>`_
* `Peter Desmet <https://github.com/peterdesmet>`_
* `Nicolas Noé <https://github.com/niconoe>`_

Meta
====

* License: MIT, see `LICENSE file <LICENSE>`_
* Please note that this project is released with a `Contributor Code of Conduct <CONDUCT.md>`_. By participating in this project you agree to abide by its terms.

.. |pypi| image:: https://img.shields.io/pypi/v/pygbif.svg
:target: https://pypi.python.org/pypi/pygbif

.. |docs| image:: https://readthedocs.org/projects/pygbif/badge/?version=latest
:target: http://pygbif.rtfd.org/

.. |ghactions| image:: https://github.com/sckott/pygbif/workflows/Python/badge.svg
:target: https://github.com/sckott/pygbif/actions?query=workflow%3APython

.. |coverage| image:: https://codecov.io/gh/sckott/pygbif/branch/master/graph/badge.svg?token=frXPREGk1D
:target: https://codecov.io/gh/sckott/pygbif

.. |black| image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/psf/black


Changelog
=========

0.6.0 (2021-07-08)
------------------
- Fixe for `occurrences.download` when giving `geometry` as a string rather than using `add_geometry`; predicates were being split on whitespace, which doesn't work for WKT `81` `84`
- Moved to using the `logging` module instead of `print()` for giving information on occurrence download methods `78`
- Clarify that `occurrences.count` for length 1 inputs only; see `occurrences.search` for > 1 value `75` `77`
- Improved documentation for `species.name_usage` method, mostly for the `language` parameter `68`
- Gains download method `download_cancel` for cancelling/deleting a download request `59`

0.5.0 (2020-09-29)
------------------
- `occurrences.search` now supports `recordedByID` and `identifiedByID` search parameters `62`
- clean up the Contributing file, thanks @niconoe `64`
- clean up internal imports in the library, thanks @niconoe `65`
- fix usage of `is` and `==`, was using them inappropriately sometimes (via https://realpython.com/python-is-identity-vs-equality/), `69`
- remove redundant parameter in a doc string, thanks @faroit `71`
- make a test for internal fxn `gbif_GET_write` more general to avoid errors if GBIF changes content type response header slightly `72`

0.4.0 (2019-11-20)
------------------
- changed base url to https for all requests; was already https for maps and downloads in previous versions
- occurrences, species, and registry modules gain docstrings with brief summary of each method
- pygbif gains ability to cache http requests. caching is off by default. See `?pygbif.caching` for all the details `52` `56` via @nleguillarme
- made note in docs that if you are trying to get the same behavior as the GBIF website for name searching, `species.name_backbone` is likely what you want `55` thanks @qgroom
- for parameters that expect a `bool`, convert them to lowercase strings internally before doing HTTP requests

0.3.0 (2019-01-25)
------------------
- pygbif is Python 3 only now `19`
- Gains maps module with maps.map method for working with the GBIF maps API `41` `49`
- Gains new module utils with one method `wkt_rewind` `46` thanks @aubreymoore for the inspiration
- Fixed bug in registry.installations: typo in one of the parameters `identifierTyp` instead of `identifierType` `48` thanks @data-biodiversity-aq
- Link to GitHub issues from Changelog 🎉
- Fix a occurrence download test `47`
- Much more thorough docs `25`

0.2.0 (2016-10-18)
------------------
- Download methods much improved `16` `27` thanks @jlegind @stijnvanhoey @peterdesmet !
- MULTIPOLYGON now supported in `geometry` parameter `35`
- Fixed docs for `occurrences.get`, and `occurrences.get_verbatim`, `occurrences.get_fragment` and demo that used occurrence keys that no longer exist in GBIF `39`
- Added `organizations` method to `registry` module `12`
- Added remainder of datasets methods: `registry.dataset_search` (including faceting support `37`) and `registry.dataset_suggest`, for the `/dataset/search` and `/dataset/suggest` routes, respectively `40`
- Added remainder of species methods: `species.name_lookup` (including faceting support `38`) and `species.name_usage`, for the `/species/search` and `/species` routes, respectively `18`
- Added more tests to cover new methods
- Changed `species.name_suggest` to give back data stucture as received from GBIF. We used to parse out the classification data, but for simplicity and speed, that is left up to the user now.
- `start` parameter in `species.name_suggest`, `occurrences.download_list`, `registry.organizations`, `registry.nodes`, `registry.networks`, and `registry.installations`, changed to `offset` to match GBIF API and match usage throughout remainder of `pygbif`

0.1.5.4 (2016-10-01)
--------------------
- Added many new `occurrence.search` parameters, including `repatriated`, `kingdomKey`, `phylumKey`, `classKey`, `orderKey`, `familyKey`, `genusKey`, `subgenusKey`, `establishmentMeans`, `facet`, `facetMincount`, `facetMultiselect`, and support for facet paging via `**kwargs` `30` `34`
- Fixes to `**kwargs` in `occurrence.search` so that facet parameters can be parsed correctly and `requests` GET request options are collected correctly `36`
- Added `spellCheck` parameter to `occurrence.search` that goes along with the `q` parameter to optionally spell check full text searches `31`

0.1.4 (2016-06-04)
------------------
- Added variable types throughout docs
- Changed default `limit` value to 300 for `occurrences.search` method
- `tox` now included, via @xrotwang `20`
- Added more registry methods `11`
- Started occurrence download methods `16`
- Added more names methods `18`
- All requests now send user-agent headers with `requests` and `pygbif` versions `13`
- Bug fix for `occurrences.download_get` `23`
- Fixed bad example for `occurrences.get` `22`
- Fixed wheel to be universal for 2 and 3 `10`
- Improved documentation a lot, autodoc methods now

0.1.1 (2015-11-03)
------------------
- Fixed distribution for pypi

0.1.0 (2015-11-02)
------------------
- First release


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pygbif-0.6.0.tar.gz (51.2 kB view details)

Uploaded Source

Built Distributions

pygbif-0.6.0-py3.9.egg (135.7 kB view details)

Uploaded Egg

pygbif-0.6.0-py2.py3-none-any.whl (62.5 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pygbif-0.6.0.tar.gz.

File metadata

  • Download URL: pygbif-0.6.0.tar.gz
  • Upload date:
  • Size: 51.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.6

File hashes

Hashes for pygbif-0.6.0.tar.gz
Algorithm Hash digest
SHA256 6f67b1549f79c16f4f493aeac0a65af8f232c2e0acbba394110bb8ec8091d94f
MD5 7ba3ea0cff7659f5803e63d746cf842f
BLAKE2b-256 2c25045fcb251e62b2c0032d4055ef151685c7a1d82aceca5f9fe1e841e96cb6

See more details on using hashes here.

File details

Details for the file pygbif-0.6.0-py3.9.egg.

File metadata

  • Download URL: pygbif-0.6.0-py3.9.egg
  • Upload date:
  • Size: 135.7 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.6

File hashes

Hashes for pygbif-0.6.0-py3.9.egg
Algorithm Hash digest
SHA256 575aee5d03f4f706153df2664188b7d9976b5f3c43984023a0d3920cdff51491
MD5 a28ae5943b76b1f272a781ddff078e28
BLAKE2b-256 cf5e31df44f7e83f687d1782091f3cda558f2ca5fae87ea0680b3422b3278718

See more details on using hashes here.

File details

Details for the file pygbif-0.6.0-py2.py3-none-any.whl.

File metadata

  • Download URL: pygbif-0.6.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 62.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.6

File hashes

Hashes for pygbif-0.6.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 77f517613e64e044be3137f3c35b56926f114efb9c82f56de4483320dd8bcc86
MD5 a8e988fd8a0f71144f3948859b9c1727
BLAKE2b-256 378186cbd7d335f6f6e9a89700823a915b08e0816aaac5bfe7a73f067c93d448

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page