ObservationFieldController

class pyinaturalist.controllers.ObservationFieldController(client)

Bases: BaseController

Controller for ObservationField and ObservationFieldValue requests

Methods

__init__(client)
delete(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:

>>> obs = client.observations(70963477)
>>> for ofv in obs.ofvs:
...     client.observation_fields.delete(ofv.id)
Parameters:

observation_field_value_id (int | str) – ID or UUID of the observation field value to delete

from_ids(*object_ids, **params) Paginator

Get records by ID

Return type:

Paginator

search(q, **params) list[ObservationField]

Search observation fields by name.

Notes

Example

>>> fields = client.observation_fields.search('vespawatch_id')
>>> pprint(fields)
 ID     Type   Name             Description
 ...
Parameters:

q (str | None) – Search query for observation field name

Return type:

list[ObservationField]

set(observation_id, observation_field_id, value, **params) dict[str, Any]

Create or update an observation field value on an observation.

Notes

Example

First find an observation field by name, if the ID is unknown:

>>> fields = client.observation_fields.search('vespawatch_id')
>>> field_id = fields[0].id

Then set the value on an observation:

>>> client.observation_fields.set(
...     observation_id=7345179,
...     observation_field_id=field_id,
...     value=250,
... )
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

Return type:

dict[str, Any]

Returns:

The newly created or updated observation field value record