Observation Fields#

Summary#

Classes

Functions

delete_observation_field(...)

Delete an observation field value from an observation

set_observation_field(observation_id, ...)

Create or update an observation field value on an observation

Module Contents#

pyinaturalist.v1.observation_fields.delete_observation_field(observation_field_value_id, **params)#

Delete an observation field value from an observation

Notes

Example

>>> # Observation field value IDs can be found on observation records:
>>> response = get_observation(70963477)
>>> ofv_ids = [ofv['id'] for ofv in response['ofvs']]
>>> for ofv_id in ofv_ids:
...     delete_observation_field(ofv_id)
Parameters:
  • observation_field_value_id (Union[int, str]) – ID or UUID of the observation field value to delete

  • access_token – An access token required for user authentication, as returned by get_access_token()

Return type:

Dict[str, Any]

pyinaturalist.v1.observation_fields.set_observation_field(observation_id, observation_field_id, value, **params)#

Create or update an observation field value on an observation

Notes

Parameters:
  • observation_id (int) – ID of the observation receiving this observation field value

  • observation_field_id (int) – ID of the observation field for this observation field value

  • value (Any) – Value for the observation field

  • access_token (Optional[str]) – An access token for user authentication, as returned by get_access_token()

  • dry_run (Optional[bool]) – Just log the request instead of sending a real request

  • session (Optional[Session]) – An existing Session object to use instead of creating a new one

Example

>>> # First find an observation field by name, if the ID is unknown:
>>> response = get_observation_fields('vespawatch_id')
>>> observation_field_id = response[0]['id']
>>> set_observation_field(
...     7345179,
...     observation_field_id,
...     value=250,
...     access_token=token,
... )
Example Response
{
  "id": 31,
  "observation_id": 18166477,
  "observation_field_id": 31,
  "value": "fouraging",
  "created_at": "2012-09-29T11:05:44.935+02:00",
  "updated_at": "2018-11-13T10:49:47.985+01:00",
  "user_id": 1,
  "updater_id": 1263313,
  "uuid": "b404b654-1bf0-4299-9288-52eeda7ac0db",
  "created_at_utc": "2012-09-29T09:05:44.935Z",
  "updated_at_utc": "2018-11-13T09:49:47.985Z"
}
Return type:

Dict[str, Any]

Returns:

The newly updated field value record