ObservationFieldController¶
- class pyinaturalist.controllers.ObservationFieldController(client)¶
Bases:
BaseControllerController for ObservationField and ObservationFieldValue requests
Methods
- __init__(client)¶
- delete(observation_field_value_id, **params)¶
Delete an observation field value from an observation.
Notes
API reference: DELETE /observation_field_values/{id}
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)
- search(q, **params) list[ObservationField]¶
Search observation fields by name.
Notes
API reference: GET /observation_fields
This uses the v0 API endpoint, which does not support
per_page
Example
>>> fields = client.observation_fields.search('vespawatch_id') >>> pprint(fields) ID Type Name Description ...
- Parameters:
- Return type:
- set(observation_id, observation_field_id, value, **params) dict[str, Any]¶
Create or update an observation field value on an observation.
Notes
API reference: POST /observation_field_values
To find an
observation_field_id, usesearch()or search on iNaturalist
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:
- Return type:
- Returns:
The newly created or updated observation field value record