Skip to main content

Python client for the iNaturalist APIs

Project description

https://badge.fury.io/py/pyinaturalist.png https://www.travis-ci.com/niconoe/pyinaturalist.svg?branch=master Documentation Status

Python client for the iNaturalist APIs.

Status

Work in progress: features are implemented one by one, as time allows and as the authors needs them.

That being said, many things are already possible (searching observations, creating a new observation, …) and contributions are welcome!

Python 3 only.

Examples

Search all observations matching a criteria:

from pyinaturalist.node_api import get_all_observations

obs = get_all_observations(params={'user_id': 'niconoe'})

see available parameters.

For authenticated API calls, you first need to obtain a token for the user:

from pyinaturalist.rest_api import get_access_token

token = get_access_token(username='<your_inaturalist_username>', password='<your_inaturalist_password>',
                         app_id='<your_inaturalist_app_id>',
                         app_secret=<your_inaturalist_app_secret>)

Note: you’ll need to create an iNaturalist app.

Create a new observation:

from pyinaturalist.rest_api import create_observations

params = {'observation':
            {'taxon_id': 54327,  # Vespa Crabro
             'observed_on_string': datetime.datetime.now().isoformat(),
             'time_zone': 'Brussels',
             'description': 'This is a free text comment for the observation',
             'tag_list': 'wasp, Belgium',
             'latitude': 50.647143,
             'longitude': 4.360216,
             'positional_accuracy': 50, # meters,

             # sets vespawatch_id (an observation field whose ID is 9613) to the value '100'.
             'observation_field_values_attributes':
                [{'observation_field_id': 9613,'value': 100}],
             },
}

r = create_observations(params=params, access_token=token)

new_observation_id = r[0]['id']

Upload a picture for this observation:

from pyinaturalist.rest_api import add_photo_to_observation

r = add_photo_to_observation(observation_id=new_observation_id,
                             file_object=open('/Users/nicolasnoe/vespa.jpg', 'rb'),
                             access_token=token)

Update an existing observation of yours:

from pyinaturalist.rest_api import update_observation

p = {'ignore_photos': 1,  # Otherwise existing pictures will be deleted
     'observation': {'description': 'updated description !'}}
r = update_observation(observation_id=17932425, params=p, access_token=token)

Get a list of all (globally available) observation fields:

from pyinaturalist.rest_api import get_all_observation_fields

r = get_all_observation_fields(search_query="DNA")

Sets an observation field value to an existing observation:

from pyinaturalist.rest_api import put_observation_field_values

put_observation_field_values(observation_id=7345179,
                             observation_field_id=9613,
                             value=250,
                             access_token=token)

History

0.9.1 (2020-05-26)

0.9.0 (2020-05-06)

  • new taxa-related functions: node_api.get_taxa(), node_api.get_taxa_autocomplete(), node_api.get_taxa_by_id(). Many thanks to Jordan Cook!

0.8.0 (2019-07-11)

  • all functions now take an optional user-agent parameter in order to identify yourself to iNaturalist. If not set, Pyinaturalist/<VERSION> will be used.

0.7.0 (2019-05-08)

  • rest_api.delete_observation() now raises ObservationNotFound if the observation doesn’t exists

  • minor dependencies update for security reasons

0.6.0 (2018-11-15)

  • New function: rest_api.delete_observation()

0.5.0 (2018-11-05)

  • New function: node_api.get_observation()

0.4.0 (2018-11-05)

  • create_observation() now raises exceptions in case of errors.

0.3.0 (2018-11-05)

  • update_observation() now raises exceptions in case of errors.

0.2.0 (2018-10-31)

  • Better infrastructure (type annotations, documentation, …)

  • Dropped support for Python 2.

  • New function: update_observation()

  • rest_api.AuthenticationError is now exceptions.AuthenticationError

0.1.0 (2018-10-10)

  • First release on PyPI.

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

pyinaturalist-0.9.1.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

pyinaturalist-0.9.1-py2.py3-none-any.whl (11.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pyinaturalist-0.9.1.tar.gz.

File metadata

  • Download URL: pyinaturalist-0.9.1.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3.post20200330 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for pyinaturalist-0.9.1.tar.gz
Algorithm Hash digest
SHA256 d0b5e7d26db2587b936a75cfdb6866a18f0f78e4ab5f0f4d01ae30bc9275eb46
MD5 61d19fce13ac7ff47e285c12ca762e4c
BLAKE2b-256 97297b0a6dd62660c39b0ffa764cc9ad0d6b26a409ede87eb08734d52dfb845e

See more details on using hashes here.

File details

Details for the file pyinaturalist-0.9.1-py2.py3-none-any.whl.

File metadata

  • Download URL: pyinaturalist-0.9.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3.post20200330 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for pyinaturalist-0.9.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 98bbe99814aa4e74dc9c574a0b42e89f6c3b8ce769b3c73e3d6be1383689ae12
MD5 951c59eed201241d1523ec817a173fdf
BLAKE2b-256 1f569a2917734b6f3c2a14d9c5f8f72848f664ddcaac0ca3056b04f6c56cf93f

See more details on using hashes here.

Supported by

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