pyinaturalist.rest_api module¶
Code used to access the (read/write, but slow) Rails based API of iNaturalist See: https://www.inaturalist.org/pages/api+reference
Functions¶
Upload a local photo and assign it to an existing observation. |
|
Create a new observation. |
|
Create a new observation. |
|
Delete an observation. |
|
Get an access token using the user’s iNaturalist username and password. |
|
Like |
|
Search observation fields. |
|
Get observation data, optionally in an alternative format. |
|
Set an observation field (value) on an observation. |
|
Update a single observation. |
-
pyinaturalist.rest_api.
add_photo_to_observation
(observation_id, photo, access_token, user_agent=None)[source]¶ Upload a local photo and assign it to an existing observation.
API reference: https://www.inaturalist.org/pages/api+reference#post-observation_photos
Example
>>> token = get_access_token('...') >>> add_photo_to_observation( >>> 1234, >>> '~/observation_photos/2020_09_01_14003156.jpg', >>> access_token=token, >>> )
Example Response
{ "id": 1234, "observation_id": 1234, "photo_id": 1234, "position": null, "created_at": "2020-09-24T21:06:16.964-05:00", "updated_at": "2020-09-24T21:06:16.964-05:00", "old_uuid": null, "uuid": "f4ec883f-e835-4590-ab3e-97900bd454a5", "created_at_utc": "2020-09-25T02:06:16.964Z", "updated_at_utc": "2020-09-25T02:06:16.964Z", "photo": { "id": 1234, "user_id": 1234, "native_photo_id": "1234", "square_url": null, "thumb_url": null, "small_url": null, "medium_url": null, "large_url": null, "created_at": "2020-09-24T21:06:15.212-05:00", "updated_at": "2020-09-24T21:06:15.212-05:00", "native_page_url": null, "native_username": "username", "native_realname": "Firstname Lastname", "license": 2, "subtype": null, "native_original_image_url": null, "uuid": "632dddc1-85ad-4664-8438-de6e0afd7746", "license_name": "Creative Commons Attribution-NonCommercial License", "license_url": "http://creativecommons.org/licenses/by-nc/4.0/", "attribution": "(c) Firstname Lastname, some rights reserved (CC BY-NC)", "type": "LocalPhoto" } }
- Parameters
observation_id (
int
) – the ID of the observationphoto (
Union
[BinaryIO
,str
]) – An image file, file-like object, or pathaccess_token (
str
) – the access token, as returned byget_access_token()
user_agent (
Optional
[str
]) – a user-agent string that will be passed to iNaturalist.
- Returns
Information about the newly created photo
-
pyinaturalist.rest_api.
create_observation
(params=None, access_token=None, user_agent=None, **kwargs)[source]¶ Create a new observation.
API reference: https://www.inaturalist.org/pages/api+reference#post-observations
Example
>>> token = get_access_token('...') >>> create_observation( >>> access_token=token, >>> species_guess='Pieris rapae', >>> local_photos='~/observation_photos/2020_09_01_14003156.jpg', >>> observation_fields={297: 1}, # 297 is the obs. field ID for 'Number of individuals' >>> )
Example Response
[ { "id": 18124406, "observed_on": null, "description": null, "latitude": null, "longitude": null, "map_scale": null, "timeframe": null, "species_guess": "Pieris rapae", "user_id": 1263313, "taxon_id": 55626, "created_at": "2018-11-05T11:08:19.150+01:00", "updated_at": "2018-11-05T11:08:19.215+01:00", "place_guess": null, "id_please": false, "observed_on_string": null, "iconic_taxon_id": 47158, "num_identification_agreements": 0, "num_identification_disagreements": 0, "time_observed_at": null, "time_zone": "Brussels", "location_is_exact": false, "delta": false, "positional_accuracy": null, "private_latitude": null, "private_longitude": null, "private_positional_accuracy": null, "geoprivacy": null, "quality_grade": "casual", "positioning_method": null, "positioning_device": null, "out_of_range": null, "license": "CC-BY-NC", "uri": null, "observation_photos_count": 0, "comments_count": 0, "zic_time_zone": "Europe/Brussels", "oauth_application_id": 278, "observation_sounds_count": 0, "identifications_count": 1, "captive": false, "community_taxon_id": null, "site_id": 1, "old_uuid": null, "public_positional_accuracy": null, "mappable": false, "cached_votes_total": 0, "last_indexed_at": "2018-11-05T02:08:19.652-08:00", "private_place_guess": null, "uuid": "0f0581ce-1be5-4ba5-9d0b-ecac994b50ed", "user_login": "vespawatch", "iconic_taxon_name": "Insecta", "project_observations": [], "created_at_utc": "2018-11-05T10:08:19.150Z", "updated_at_utc": "2018-11-05T10:08:19.215Z", "time_observed_at_utc": null, "faves_count": 0, "owners_identification_from_vision": false } ]
Example Response (failure)
{ "errors": [ [ "Observed on can't be in the future", "Latitude doit être inférieur ou égal à 90" ] ] }
- Parameters
params (
Optional
[Dict
[str
,Any
]]) – [DEPRECATED] Request parameters as a dict instead of keyword argumentsaccess_token (
Optional
[str
]) – An access token required for user authentication, as returned byget_access_token()
species_guess (str) – Equivalent to the “What did you see?” field on the observation form. iNat will try to choose a single taxon based on this, but it may fail if it’s ambuguous
taxon_id (int) – ID of the taxon to associate with this observation
observed_on_string (Union[datetime.date, datetime.datetime, str]) – Date/time of the observation. Time zone will default to the user’s time zone if not specified.
time_zone (str) – Time zone the observation was made in
description (str) – Observation description
tag_list (Union[str, List[str]]) – Comma-separated list of tags
place_guess (str) – Name of the place where the observation was recorded. Note: iNat will not try to automatically look up coordinates based on this string
latitude (float) – Latitude of the observation; presumed datum is WGS84
longitude (float) – Longitude of the observation; presumed datum is WGS84
map_scale (int) – Google Maps zoom level (from 0 to 19) at which to show this observation’s map marker.
positional_accuracy (int) – Positional accuracy of the observation coordinates, in meters
geoprivacy (str) – Geoprivacy for the observation
observation_fields (Union[Dict, List[Dict]]) – Dict of observation fields in the format
{id: value}
. Alias forobservation_field_values_attributes
.flickr_photos (Union[int, List[int]]) – Flickr photo ID(s) to add as photos for this observation. User must have their Flickr and iNat accounts connected, and the user must own the photo(s) on Flickr.
picasa_photos (Union[str, List[str]]) – Picasa photo ID(s) to add as photos for this observation. User must have their Picasa and iNat accounts connected, and the user must own the photo(s) on Picasa.
facebook_photos (Union[str, List[str]]) – Facebook photo IDs to add as photos for this observation. User must have their Facebook and iNat accounts connected, and the user must own the photo on Facebook.
local_photos (Iterable[Union[BinaryIO, str]]) – Image files, file-like objects, and/or paths for local photos to upload
user_agent (
Optional
[str
]) – A custom user-agent string to provide to the iNaturalist APIobservation_field_values_attributes (Union[Dict, List[Dict]]) –
- Return type
List
[Dict
[str
,Any
]]- Returns
JSON response containing the newly created observation(s)
- Raises
error 422 (unprocessable entity) if it rejects the observation data (for example an –
observation date in the future or a latitude > 90. In that case the exception's –
response attribute gives more details about the errors. –
-
pyinaturalist.rest_api.
create_observations
(params=None, **kwargs)[source]¶ Create a new observation. Note: Creating multiple observations sould be possible according to the docs, but it does not appear to work.
- Parameters
params (Dict[str, Any]) –
-
pyinaturalist.rest_api.
delete_observation
(observation_id, access_token=None, user_agent=None)[source]¶ Delete an observation.
API reference: https://www.inaturalist.org/pages/api+reference#delete-observations-id
Example
>>> token = get_access_token('...') >>> delete_observation(17932425, token)
- Parameters
observation_id (
int
) – iNaturalist observation IDaccess_token (
Optional
[str
]) – An access token required for user authentication, as returned byget_access_token()
user_agent (
Optional
[str
]) – A custom user-agent string to provide to the iNaturalist API
- Returns
If successful, no response is returned from this endpoint
- Raises
-
pyinaturalist.rest_api.
get_access_token
(username, password, app_id, app_secret, user_agent=None)[source]¶ Get an access token using the user’s iNaturalist username and password. You still need an iNaturalist app to do this.
API reference: https://www.inaturalist.org/pages/api+reference#auth
Example
>>> access_token = get_access_token('...') >>> headers = {"Authorization": f"Bearer {access_token}"}
- Parameters
username (
str
) – iNaturalist usernamepassword (
str
) – iNaturalist passwordapp_id (
str
) – iNaturalist application IDapp_secret (
str
) – iNaturalist application secretuser_agent (
Optional
[str
]) – a user-agent string that will be passed to iNaturalist.
- Return type
str
-
pyinaturalist.rest_api.
get_all_observation_fields
(**kwargs)[source]¶ Like
get_observation_fields()
, but handles pagination for you.Example
>>> get_all_observation_fields(q='number of')
- Parameters
q (str) – Search query
user_agent (str) – A custom user-agent string to provide to the iNaturalist API
search_query (str) –
- Return type
List
[Dict
[str
,Any
]]- Returns
Observation fields as a list of dicts. Response format is the same as the inner
“results” object returned by
get_observation_fields()
.
-
pyinaturalist.rest_api.
get_observation_fields
(user_agent=None, **kwargs)[source]¶ Search observation fields. Observation fields are basically typed data fields that users can attach to observation.
API reference: https://www.inaturalist.org/pages/api+reference#get-observation_fields
Example
>>> get_observation_fields(q='number of individuals') >>> # Show just observation field IDs and names >>> from pprint import pprint >>> pprint({r['id']: r['name'] for r in response})
Example Response
[ { "id": 4813, "name": "Sex (deer/turkey)", "datatype": "text", "user_id": 140831, "description": "", "created_at": "2016-05-29T16:17:08.051Z", "updated_at": "2018-01-01T01:17:56.007Z", "allowed_values": "Male|Female|Unknown", "values_count": 10, "users_count": 6 }, { "id": 5290, "name": "Turtle sex", "datatype": "text", "user_id": 235092, "description": "Male or female", "created_at": "2016-08-30T08:14:54.813Z", "updated_at": "2018-06-04T14:28:56.759Z", "allowed_values": "", "values_count": 8, "users_count": 6 }, { "id": 1380, "name": "Sex of bird", "datatype": "text", "user_id": 20349, "description": "", "created_at": "2014-07-30T17:53:06.664Z", "updated_at": "2018-09-24T00:41:50.182Z", "allowed_values": "NA|Male|Female|M+F", "values_count": 2271, "users_count": 86 }, { "id": 3000, "name": "Sex of squirrel", "datatype": "text", "user_id": 22496, "description": "What sex is it?", "created_at": "2015-07-08T21:41:18.631Z", "updated_at": "2017-01-22T02:30:43.210Z", "allowed_values": "Male|Female|Unknown", "values_count": 94, "users_count": 8 }, { "id": 6622, "name": "Long-winged sex unknown", "datatype": "numeric", "user_id": 478731, "description": "number of long-winged bugs for which the sex can not be determined", "created_at": "2017-06-07T15:04:37.899Z", "updated_at": "2017-06-07T15:04:37.899Z", "allowed_values": "", "values_count": null, "users_count": null }, { "id": 5598, "name": "SEXO DE MARIPOSA MONARCA", "datatype": "text", "user_id": 48115, "description": "SI ES MACHO EN LAS ALAS INFERIORES PRESENTA DOS CIRCULOS NEGROS EN LAS VENAS O HEMBRA LAS VENAS NEGRAS SON MUCHO MAS GRUESAS", "created_at": "2016-10-31T19:56:23.722Z", "updated_at": "2016-11-09T17:00:44.345Z", "allowed_values": "\"MACHO|HEMBRA|NO IDENTIFICADO\"", "values_count": 5, "users_count": 5 }, { "id": 3649, "name": "Sex of Otter", "datatype": "text", "user_id": 156076, "description": "Can you identify your otter as male or female", "created_at": "2015-11-25T18:56:27.678Z", "updated_at": "2016-06-20T20:00:21.585Z", "allowed_values": "", "values_count": 0, "users_count": 0 }, { "id": 1311, "name": "Sex of turtle", "datatype": "text", "user_id": 36588, "description": "Mark unknown, male, female", "created_at": "2014-07-10T22:38:37.053Z", "updated_at": "2017-12-25T20:08:54.499Z", "allowed_values": "Unknown|Male|Female", "values_count": 23, "users_count": 12 }, { "id": 6626, "name": "Short-winged sex unknown", "datatype": "numeric", "user_id": 478731, "description": "number of short-winged bugs for which the sex can not be determined", "created_at": "2017-06-07T15:06:27.962Z", "updated_at": "2017-06-07T15:28:49.059Z", "allowed_values": "", "values_count": 1, "users_count": 1 }, { "id": 3427, "name": "Sex Bird 1", "datatype": "text", "user_id": 60886, "description": "", "created_at": "2015-09-28T23:43:18.757Z", "updated_at": "2017-07-17T06:36:13.282Z", "allowed_values": "Male|Female|Unknown|N/A", "values_count": 7259, "users_count": 7 }, { "id": 3428, "name": "Sex Bird 2", "datatype": "text", "user_id": 60886, "description": "", "created_at": "2015-09-28T23:44:37.291Z", "updated_at": "2017-07-17T06:36:13.380Z", "allowed_values": "Male|Female|Unknown|N/A", "values_count": 7339, "users_count": 6 }, { "id": 4816, "name": "Turkey Sex", "datatype": "text", "user_id": 140831, "description": "", "created_at": "2016-05-29T16:31:58.791Z", "updated_at": "2017-10-11T01:00:41.621Z", "allowed_values": "Male|Female", "values_count": 4, "users_count": 4 }, { "id": 4775, "name": "Sex of Sighting", "datatype": "text", "user_id": 248160, "description": "Male (pipe-cleaner)/Female (coated wire)", "created_at": "2016-05-25T19:54:11.648Z", "updated_at": "2018-09-02T03:10:55.945Z", "allowed_values": "Male|Female|Unsure", "values_count": 88, "users_count": 28 }, { "id": 5860, "name": "Sex of Cicada", "datatype": "text", "user_id": 383120, "description": "Select one: Male or Female", "created_at": "2017-01-17T13:31:11.716Z", "updated_at": "2017-01-17T13:54:43.468Z", "allowed_values": "", "values_count": 8, "users_count": 1 }, { "id": 407, "name": "Seahorse sex", "datatype": "text", "user_id": 16172, "description": "", "created_at": "2013-06-10T20:15:59.137Z", "updated_at": "2016-06-20T19:49:35.252Z", "allowed_values": "|Male|Female|Juvenile|Unknown", "values_count": 2, "users_count": 1 }, { "id": 497, "name": "âge et sexe", "datatype": "text", "user_id": 18060, "description": "âge et/ou sexe des individus observés: ADU:adulte, MAL:mâle, FEM:femelle, SUB:subadulte, JUV:juvénile, LAR:larve/têtard, PTE:ponte, NSP:non-pécifié", "created_at": "2013-08-09T18:33:36.240Z", "updated_at": "2018-01-14T19:39:06.828Z", "allowed_values": "ADU|MAL|FEM|SUB|JUV|LAR|PTE|NSP", "values_count": 1, "users_count": 1 }, { "id": 8010, "name": "Sex of fish", "datatype": "text", "user_id": 748515, "description": "U (unknown), M (male), F (Female),", "created_at": "2018-01-23T18:42:27.733Z", "updated_at": "2018-10-04T22:07:34.685Z", "allowed_values": "U|M|F", "values_count": 37, "users_count": 3 }, { "id": 3365, "name": "Sex of species", "datatype": "text", "user_id": 31215, "description": "If known, record the sex of the species observed", "created_at": "2015-09-16T02:18:43.071Z", "updated_at": "2018-09-10T23:18:52.674Z", "allowed_values": "unrecorded|unknown|male|female|hermaphrodite", "values_count": 1703, "users_count": 13 }, { "id": 789, "name": "Sex Class", "datatype": "text", "user_id": 26756, "description": "Sex of individual if known", "created_at": "2013-12-10T03:43:57.352Z", "updated_at": "2018-09-22T20:50:46.214Z", "allowed_values": "Male|Female|Unknown", "values_count": 93, "users_count": 24 }, { "id": 4934, "name": "Sex of specimen", "datatype": "text", "user_id": 251013, "description": "Record all that apply: M (male), F (female), U (unknown)", "created_at": "2016-06-14T21:17:16.943Z", "updated_at": "2018-10-15T18:49:38.685Z", "allowed_values": "", "values_count": 1509, "users_count": 113 }, { "id": 7557, "name": "Sex of Herp(s)", "datatype": "text", "user_id": 560165, "description": "", "created_at": "2017-10-28T16:41:54.316Z", "updated_at": "2018-08-09T02:44:11.537Z", "allowed_values": "Male|Female|Unknown|Mixed", "values_count": 3, "users_count": 2 }, { "id": 667, "name": "Number of individuals observed, with sex and life stage if applicable.", "datatype": "text", "user_id": 2470, "description": "for example, 'at least 10 adult dragonflies observed', '6 clumps, each with 10 to 20 stems', 'one patch of 1.5 square meters, with 8 flowering stems.'", "created_at": "2013-10-16T18:32:01.144Z", "updated_at": "2017-07-08T02:19:16.682Z", "allowed_values": "", "values_count": 4, "users_count": 4 }, { "id": 7228, "name": "Number of long-winged adult sex unknown", "datatype": "numeric", "user_id": 567752, "description": "", "created_at": "2017-09-18T16:18:16.320Z", "updated_at": "2017-09-18T16:18:16.320Z", "allowed_values": "", "values_count": null, "users_count": null }, { "id": 8668, "name": "# Unknown Sex", "datatype": "numeric", "user_id": 794221, "description": "", "created_at": "2018-04-30T17:45:35.776Z", "updated_at": "2018-10-15T22:00:39.335Z", "allowed_values": "", "values_count": 1160, "users_count": 7 }, { "id": 4704, "name": "Sex of Animal", "datatype": "text", "user_id": 237437, "description": "Unknown, male, or female?", "created_at": "2016-05-13T22:14:08.152Z", "updated_at": "2018-10-15T19:41:27.725Z", "allowed_values": "Unknown|Male|Female", "values_count": 1031, "users_count": 57 }, { "id": 7486, "name": "Sex-age", "datatype": "text", "user_id": 383144, "description": "The age and sex of the toad", "created_at": "2017-10-18T12:31:47.256Z", "updated_at": "2018-09-10T15:01:36.844Z", "allowed_values": "unknown|male|female|amplexis pair|juvenile|toadlet (up to 15mm long)|tadpole|egg", "values_count": 217, "users_count": 10 }, { "id": 4976, "name": "Butterfly Sex", "datatype": "text", "user_id": 180480, "description": "", "created_at": "2016-06-21T18:58:27.171Z", "updated_at": "2018-10-03T21:17:40.826Z", "allowed_values": "unknown|male|female", "values_count": 532, "users_count": 42 }, { "id": 7722, "name": "Bird sex", "datatype": "text", "user_id": 567819, "description": "Was it female/male?", "created_at": "2017-11-26T23:17:44.814Z", "updated_at": "2018-10-13T02:24:53.283Z", "allowed_values": "male|female|unknown", "values_count": 351, "users_count": 9 }, { "id": 1506, "name": "Sex of box turtle", "datatype": "text", "user_id": 28430, "description": "Male box turtles have red eyes, and orange scales on the forelimbs; females have brownish-yellow eyes, and yellow scales on the forelimbs. Determining sex does not require you to handle the turtle.", "created_at": "2014-09-04T16:27:00.510Z", "updated_at": "2017-12-25T20:14:40.897Z", "allowed_values": "", "values_count": 2, "users_count": 2 }, { "id": 856, "name": "âge / sexe", "datatype": "text", "user_id": 18060, "description": "âge et/ou sexe des individus: ADU:Adulte, MAL:Mâle, FEM:Femelle, SBA:Subadulte, JUV:Juvénile, LAR:Larve ou têtard, PTE:Ponte, ACC:Amplexus, NSP:Non-spécifié", "created_at": "2014-02-02T11:25:51.349Z", "updated_at": "2018-09-28T13:09:21.730Z", "allowed_values": "ADU|MAL|FEM|SBA|JUV|LAR|PTE|ACC|NSP", "values_count": 12, "users_count": 6 } ]
- Parameters
q (str) – Search query
page (int) – Page number of results to return
user_agent (
Optional
[str
]) – A custom user-agent string to provide to the iNaturalist APIsearch_query (str) –
- Return type
List
[Dict
[str
,Any
]]- Returns
Observation fields as a list of dicts
-
pyinaturalist.rest_api.
get_observations
(user_agent=None, **kwargs)[source]¶ Get observation data, optionally in an alternative format. Also see
get_geojson_observations()
for GeoJSON format (not included here because it wraps a separate API endpoint).API reference: https://www.inaturalist.org/pages/api+reference#get-observations
Example
>>> get_observations(id=45414404, format="atom")
Example Response (atom)
<?xml version="1.0" encoding="UTF-8"?> <feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom" xmlns:georss="http://www.georss.org/georss"> <id>tag:www.inaturalist.org,2005:/observations</id> <link rel="alternate" type="text/html" href="https://www.inaturalist.org"/> <link rel="self" type="application/atom+xml" href="https://www.inaturalist.org/observations.atom?id=16227955"/> <title>iNaturalist: Observations by Everyone</title> <updated>2020-06-10T23:05:37Z</updated> <icon>/assets/favicon-cf3214988200dff386f744b79050b857.png</icon> <entry> <id>tag:www.inaturalist.org,2005:Observation/16227955</id> <published>2018-09-05T12:31:08Z</published> <updated>2018-09-22T17:19:27Z</updated> <link rel="alternate" type="text/html" href="https://www.inaturalist.org/observations/16227955"/> <title>Lixus bardanae</title> <author> <name>niconoe</name> </author> <content type="html"><p><img src="https://static.inaturalist.org/photos/24355313/medium.jpeg?1536150659" alt="Medium" /> <img src="https://static.inaturalist.org/photos/24355315/medium.jpeg?1536150664" alt="Medium" /></p><p></p></content> <georss:point>50.646894 4.360086</georss:point> </entry> </feed>
Example Response (csv)
scientific_name,datetime,description,place_guess,latitude,longitude,tag_list,common_name,url,image_url,user_login,id,species_guess,iconic_taxon_name,taxon_id,num_identification_agreements,num_identification_disagreements,observed_on_string,observed_on,time_observed_at,time_zone,positional_accuracy,private_place_guess,geoprivacy,taxon_geoprivacy,coordinates_obscured,positioning_method,positioning_device,user_id,created_at,updated_at,quality_grade,license,sound_url,oauth_application_id,captive_cultivated Lixus bardanae,2018-09-05 14:06:00 +0200,"",54 rue des Badauds,50.646894,4.360086,"",,https://www.inaturalist.org/observations/16227955,https://static.inaturalist.org/photos/24355315/medium.jpeg?1536150664,niconoe,16227955,Lixus bardanae,Insecta,493595,2,0,2018/09/05 2:06 PM CEST,2018-09-05,2018-09-05 12:06:00 UTC,Paris,23,,,,false,,,886482,2018-09-05 12:31:08 UTC,2018-09-22 17:19:27 UTC,research,CC0,,,false
Example Response (dwc)
<?xml version="1.0" encoding="UTF-8"?> <dwr:SimpleDarwinRecordSet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://rs.tdwg.org/dwc/xsd/simpledarwincore/ http://rs.tdwg.org/dwc/xsd/tdwg_dwc_simple.xsd" xmlns:ac="http://rs.tdwg.org/ac/terms/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dwc="http://rs.tdwg.org/dwc/terms/" xmlns:dwr="http://rs.tdwg.org/dwc/xsd/simpledarwincore/" xmlns:eol="http://www.eol.org/transfer/content/1.0" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://eol.org/schema/media/" xmlns:ref="http://eol.org/schema/reference/" xmlns:xap="http://ns.adobe.com/xap/1.0/"> <dwr:SimpleDarwinRecord> <dwc:occurrenceID>https://www.inaturalist.org/observations/16227955</dwc:occurrenceID> <dwc:occurrenceID>https://www.inaturalist.org/observations/16227955</dwc:occurrenceID> <dwc:basisOfRecord>HumanObservation</dwc:basisOfRecord> <dcterms:modified>2018-09-22T17:19:27Z</dcterms:modified> <dwc:institutionCode>iNaturalist</dwc:institutionCode> <dwc:collectionCode>Observations</dwc:collectionCode> <dwc:datasetName>iNaturalist research-grade observations</dwc:datasetName> <dwc:catalogNumber>16227955</dwc:catalogNumber> <dcterms:references>https://www.inaturalist.org/observations/16227955</dcterms:references> <dwc:occurrenceDetails>https://www.inaturalist.org/observations/16227955</dwc:occurrenceDetails> <dwc:recordedBy>Nicolas Noé</dwc:recordedBy> <dwc:establishmentMeans>wild</dwc:establishmentMeans> <dwc:eventDate>2018-09-05T14:06:00+02:00</dwc:eventDate> <dwc:eventTime>12:06:00Z</dwc:eventTime> <dwc:verbatimEventDate>2018/09/05 2:06 PM CEST</dwc:verbatimEventDate> <dwc:verbatimLocality>54 rue des Badauds</dwc:verbatimLocality> <dwc:decimalLatitude>50.646894</dwc:decimalLatitude> <dwc:decimalLongitude>4.360086</dwc:decimalLongitude> <dwc:coordinateUncertaintyInMeters>23</dwc:coordinateUncertaintyInMeters> <dwc:countryCode>BE</dwc:countryCode> <dwc:stateProvince>Wallonie</dwc:stateProvince> <dwc:identificationID>34896306</dwc:identificationID> <dwc:dateIdentified>2018-09-05T12:34:22Z</dwc:dateIdentified> <dwc:taxonID>493595</dwc:taxonID> <dwc:scientificName>Lixus bardanae</dwc:scientificName> <dwc:taxonRank>species</dwc:taxonRank> <dwc:kingdom>Animalia</dwc:kingdom> <dwc:phylum>Arthropoda</dwc:phylum> <dwc:class>Insecta</dwc:class> <dwc:order>Coleoptera</dwc:order> <dwc:family>Curculionidae</dwc:family> <dwc:genus>Lixus</dwc:genus> <dcterms:license>http://creativecommons.org/publicdomain/zero/1.0/</dcterms:license> <dcterms:rights>By Nicolas Noé no rights reserved</dcterms:rights> <dcterms:rightsHolder>Nicolas Noé</dcterms:rightsHolder> <dwc:inaturalistLogin>niconoe</dwc:inaturalistLogin> <eol:dataObject> <dcterms:identifier>https://www.inaturalist.org/photos/24355313</dcterms:identifier> <dcterms:type>http://purl.org/dc/dcmitype/StillImage</dcterms:type> <dcterms:format>image/jpeg</dcterms:format> <ac:accessURI>https://static.inaturalist.org/photos/24355313/original.jpeg?1536150659</ac:accessURI> <media:thumbnailURL>https://static.inaturalist.org/photos/24355313/thumb.jpeg?1536150659</media:thumbnailURL> <ac:furtherInformationURL>https://www.inaturalist.org/photos/24355313</ac:furtherInformationURL> <ac:derivedFrom>https://www.inaturalist.org/photos/24355313</ac:derivedFrom> <xap:CreateDate>2018-09-05T12:31:01Z</xap:CreateDate> <dcterms:modified>2018-09-05T12:31:01Z</dcterms:modified> <xap:UsageTerms>http://creativecommons.org/licenses/by/4.0/</xap:UsageTerms> <dcterms:rights>Copyright Nicolas Noé, licensed under a Creative Commons Attribution License license: http://creativecommons.org/licenses/by/4.0/</dcterms:rights> <xap:Owner>Nicolas Noé</xap:Owner> <dcterms:publisher>iNaturalist</dcterms:publisher> <dcterms:creator>Nicolas Noé</dcterms:creator> </eol:dataObject> <eol:dataObject> <dcterms:identifier>https://www.inaturalist.org/photos/24355315</dcterms:identifier> <dcterms:type>http://purl.org/dc/dcmitype/StillImage</dcterms:type> <dcterms:format>image/jpeg</dcterms:format> <ac:accessURI>https://static.inaturalist.org/photos/24355315/original.jpeg?1536150664</ac:accessURI> <media:thumbnailURL>https://static.inaturalist.org/photos/24355315/thumb.jpeg?1536150664</media:thumbnailURL> <ac:furtherInformationURL>https://www.inaturalist.org/photos/24355315</ac:furtherInformationURL> <ac:derivedFrom>https://www.inaturalist.org/photos/24355315</ac:derivedFrom> <xap:CreateDate>2018-09-05T12:31:05Z</xap:CreateDate> <dcterms:modified>2018-09-05T12:31:05Z</dcterms:modified> <xap:UsageTerms>http://creativecommons.org/licenses/by/4.0/</xap:UsageTerms> <dcterms:rights>Copyright Nicolas Noé, licensed under a Creative Commons Attribution License license: http://creativecommons.org/licenses/by/4.0/</dcterms:rights> <xap:Owner>Nicolas Noé</xap:Owner> <dcterms:publisher>iNaturalist</dcterms:publisher> <dcterms:creator>Nicolas Noé</dcterms:creator> </eol:dataObject> </dwr:SimpleDarwinRecord> </dwr:SimpleDarwinRecordSet>
Example Response (json)
[ { "id": 16227955, "observed_on": "2018-09-05", "description": "", "latitude": "50.646894", "longitude": "4.360086", "map_scale": 17, "timeframe": null, "species_guess": "Lixus bardanae", "user_id": 886482, "taxon_id": 493595, "created_at": "2018-09-05T12:31:08.048Z", "updated_at": "2018-09-22T17:19:27.080Z", "place_guess": "54 rue des Badauds", "id_please": false, "observed_on_string": "2018/09/05 2:06 PM CEST", "iconic_taxon_id": 47158, "num_identification_agreements": 2, "num_identification_disagreements": 0, "time_observed_at": "2018-09-05T12:06:00.000Z", "time_zone": "Paris", "location_is_exact": true, "delta": false, "positional_accuracy": 23, "private_latitude": null, "private_longitude": null, "private_positional_accuracy": null, "geoprivacy": null, "quality_grade": "research", "positioning_method": null, "positioning_device": null, "out_of_range": null, "license": "CC0", "uri": "https://www.inaturalist.org/observations/16227955", "observation_photos_count": 2, "comments_count": 2, "zic_time_zone": "Europe/Paris", "oauth_application_id": null, "observation_sounds_count": 0, "identifications_count": 3, "captive": false, "community_taxon_id": 493595, "site_id": 1, "old_uuid": null, "public_positional_accuracy": 23, "mappable": true, "cached_votes_total": 0, "last_indexed_at": "2019-10-10T20:19:39.304Z", "private_place_guess": null, "uuid": "6448d03a-7f9a-4099-86aa-ca09a7740b00", "taxon_geoprivacy": null, "short_description": "", "user_login": "niconoe", "iconic_taxon_name": "Insecta", "tag_list": [], "faves_count": 0, "created_at_utc": "2018-09-05T12:31:08.048Z", "updated_at_utc": "2018-09-22T17:19:27.080Z", "time_observed_at_utc": "2018-09-05T12:06:00.000Z", "owners_identification_from_vision": true, "taxon": { "id": 493595, "name": "Lixus bardanae", "rank": "species", "ancestry": "48460/1/47120/372739/47158/184884/47208/71130/372852/60473/48736/272543/507383/71157", "common_name": null }, "iconic_taxon": { "id": 47158, "name": "Insecta", "rank": "class", "rank_level": 50.0, "ancestry": "48460/1/47120/372739" }, "user": { "login": "niconoe", "user_icon_url": "https://static.inaturalist.org/attachments/users/icons/886482/thumb.jpg?1529671435" }, "photos": [ { "id": 24355313, "user_id": 886482, "native_photo_id": "24355313", "square_url": "https://static.inaturalist.org/photos/24355313/square.jpeg?1536150659", "thumb_url": "https://static.inaturalist.org/photos/24355313/thumb.jpeg?1536150659", "small_url": "https://static.inaturalist.org/photos/24355313/small.jpeg?1536150659", "medium_url": "https://static.inaturalist.org/photos/24355313/medium.jpeg?1536150659", "large_url": "https://static.inaturalist.org/photos/24355313/large.jpeg?1536150659", "created_at": "2018-09-05T12:31:01.946Z", "updated_at": "2018-09-05T12:31:01.946Z", "native_page_url": "https://www.inaturalist.org/photos/24355313", "native_username": "niconoe", "native_realname": "Nicolas No\u00e9", "license": 4, "subtype": null, "native_original_image_url": null, "uuid": "be0dcd96-db21-4c19-814b-bcd33c051ea6", "license_code": "CC-BY", "attribution": "(c) Nicolas No\u00e9, some rights reserved (CC BY)", "license_name": "Creative Commons Attribution License", "license_url": "http://creativecommons.org/licenses/by/4.0/", "type": "LocalPhoto" }, { "id": 24355315, "user_id": 886482, "native_photo_id": "24355315", "square_url": "https://static.inaturalist.org/photos/24355315/square.jpeg?1536150664", "thumb_url": "https://static.inaturalist.org/photos/24355315/thumb.jpeg?1536150664", "small_url": "https://static.inaturalist.org/photos/24355315/small.jpeg?1536150664", "medium_url": "https://static.inaturalist.org/photos/24355315/medium.jpeg?1536150664", "large_url": "https://static.inaturalist.org/photos/24355315/large.jpeg?1536150664", "created_at": "2018-09-05T12:31:05.862Z", "updated_at": "2018-09-05T12:31:05.862Z", "native_page_url": "https://www.inaturalist.org/photos/24355315", "native_username": "niconoe", "native_realname": "Nicolas No\u00e9", "license": 4, "subtype": null, "native_original_image_url": null, "uuid": "154b105a-3e04-448d-b8a3-8ced07af2adf", "license_code": "CC-BY", "attribution": "(c) Nicolas No\u00e9, some rights reserved (CC BY)", "license_name": "Creative Commons Attribution License", "license_url": "http://creativecommons.org/licenses/by/4.0/", "type": "LocalPhoto" } ] } ]
Example Response (kml)
<?xml version="1.0" encoding="UTF-8"?> <kml xmlns="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom"> <Document> <Placemark id="ID16227955"> <name>Lixus bardanae</name> <visibility>1</visibility> <atom:link>https://www.inaturalist.org/observations/16227955</atom:link> <TimeStamp> <when>2018-09-05T14:06:00+02:00</when> </TimeStamp> <description> <![CDATA[<table cellpadding="5" border="0"> <tr> <td valign="top" style="vertical-align: top"> <a href="https://www.inaturalist.org/observations/16227955"> <img src="https://static.inaturalist.org/photos/24355315/thumb.jpeg?1536150664" alt="Thumb" /> </a> </td> <td valign="top" style="vertical-align: top"> <div> Observed by <a href="https://www.inaturalist.org/observations/niconoe">niconoe</a> <span class="observed_on"><span class="date">2018-09-05</span></span> <span class="place_guess">54 rue des Badauds</span> <br/> <br/> </div> <div> <a class="readmore" href="https://www.inaturalist.org/observations/16227955">View Observation</a> </div> </td> </tr> </table> ]]> </description> <styleUrl>/assets/observations/google_earth-824f44474a896e5afd52c3274499151b.kml?prevent=155#Insecta</styleUrl> <Point> <coordinates>4.360086,50.646894</coordinates> </Point> </Placemark> </Document> </kml>
Example Response (widget)
try { var msg = document.getElementById('inatwidgetmsg'); if (msg) { msg.style.visibility = 'visible'; } document.write('<table data-current-page=\"1\" data-per-page=\"30\" data-total-entries=\"1\"data-total-pages=\"1\"><tr class=\"inat-observation\"><td class=\"inat-observation-image\" valign=\"top\" align=\"center\"><a href=\"https://www.inaturalist.org/observations/16227955\"><img border=\"0\" title=\"Lixus bardanae from 54 rue des Badauds on September 05, 2018 at 02:06 PM by Nicolas Noé\" src=\"https://static.inaturalist.org/photos/24355315/square.jpeg?1536150664\" alt=\"Square\" /><\/a> <\/td><td class=\"inat-observation-body\" valign=\"top\"><a href=\"https://www.inaturalist.org/observations/16227955\">Lixus bardanae<\/a><div class=\"inat-meta\"><span class=\"inat-label\">Observer: <\/span><span class=\"inat-value\"><a href=\"https://www.inaturalist.org/observations/niconoe\">niconoe<\/a><\/span><br/><span class=\"inat-label\">Date: <\/span><span class=\"inat-value\"> Sep 05 2018<\/span><br/><span class=\"inat-label\">Place: <\/span><span class=\"inat-value\">54 rue des Badauds<\/span><\/div><\/td><\/tr><\/table>') } catch (e) {}
- Parameters
q (str) – Search observation properties
d1 (Union[datetime.date, datetime.datetime, str]) – Must be observed on or after this date
d2 (Union[datetime.date, datetime.datetime, str]) – Must be observed on or before this date
day (Union[int, List[int]]) – Must be observed within this day of the month
month (Union[int, List[int]]) – Must be observed within this month
year (Union[int, List[int]]) – Must be observed within this year
license (Union[str, List[str]]) – Observation must have this license
photo_license (Union[str, List[str]]) – Must have at least one photo with this license
out_of_range (bool) – Observations whose taxa are outside their known ranges
list_id (int) – Taxon must be in the list with this ID
quality_grade (str) – Must have this quality grade
taxon_id (Union[int, List[int]]) – Only show observations of these taxa and their descendants
taxon_name (Union[str, List[str]]) – Taxon must have a scientific or common name matching this string
iconic_taxa (Union[str, List[str]]) – Taxon must by within this iconic taxon
updated_since (Union[datetime.date, datetime.datetime, str]) – Must be updated since this time
has (Union[str, List[str]]) – Catch-all for some boolean selectors. This can be used multiple times, e.g.
has=['photos', 'geo']
m1 (Union[datetime.date, datetime.datetime, str]) – First month of a month range
m2 (Union[datetime.date, datetime.datetime, str]) – Last month of a month range
h1 (Union[datetime.date, datetime.datetime, str]) – First hour of an hour range
h2 (Union[datetime.date, datetime.datetime, str]) – Last hour of an hour range
on (Union[datetime.date, datetime.datetime, str]) – Filter by date string
extra (str) – Retrieve additional information. ‘projects’ returns info about the projects the observations have been added to, ‘fields’ returns observation field values, ‘observation_photos’ returns information about the photos’ relationship with the observation, like their order.
response_format (str) – A supported response format to return
nelat (float) – NE latitude of bounding box
nelng (float) – NE longitude of bounding box
swlat (float) – SW latitude of bounding box
swlng (float) – SW longitude of bounding box
page (int) – Page number of results to return
per_page (int) – Number of results to return in a page. The maximum value is generally 200, unless otherwise noted
order (str) – Sort order
order_by (str) – Field to sort on
user_agent (
Optional
[str
]) – A custom user-agent string to provide to the iNaturalist API
- Return type
Union
[List
,str
]- Returns
Return type will be
dict
for thejson
response format, andstr
for all
others.
-
pyinaturalist.rest_api.
put_observation_field_values
(observation_id, observation_field_id, value, access_token, user_agent=None)[source]¶ Set an observation field (value) on an observation. Will fail if this observation field is already set for this observation.
To find an observation_field_id, either user
get_observation_fields()
or search on iNaturalist: https://www.inaturalist.org/observation_fieldsAPI reference: https://www.inaturalist.org/pages/api+reference#put-observation_field_values-id
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'] >>> >>> put_observation_field_values( >>> observation_id=7345179, >>> observation_field_id=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" }
- Parameters
observation_id (
int
) – ID of the observation receiving this observation field valueobservation_field_id (
int
) – ID of the observation field for this observation field valuevalue (
Any
) – Value for the observation fieldaccess_token (
str
) – access_token: The access token, as returned byget_access_token()
user_agent (
Optional
[str
]) – A user-agent string that will be passed to iNaturalist.
- Return type
Dict
[str
,Any
]- Returns
The nwely updated field value record
-
pyinaturalist.rest_api.
update_observation
(observation_id, params=None, access_token=None, user_agent=None, **kwargs)[source]¶ Update a single observation.
API reference: https://www.inaturalist.org/pages/api+reference#put-observations-id
Note
Unlike the underlying REST API endpoint, this function will not delete any existing photos from your observation if not specified in
local_photos
. If you want this to behave the same as the REST API and you do want to delete photos, call withignore_photos=False
.Example
>>> token = get_access_token('...') >>> update_observation( >>> 17932425, >>> access_token=token, >>> description="updated description!", >>> )
Example Response
[ { "id": 17932425, "observed_on": "2018-10-29", "description": "updated description v2 !", "latitude": "50.4898053873", "longitude": "5.1035889611", "map_scale": null, "timeframe": null, "species_guess": null, "user_id": 1263313, "taxon_id": 54327, "created_at": "2018-10-29T14:37:32.176+01:00", "updated_at": "2018-10-30T14:30:11.667+01:00", "place_guess": "Namur, Wallonie, BE", "id_please": false, "observed_on_string": "2018-10-28T23:00:00+00:00", "iconic_taxon_id": 47158, "num_identification_agreements": 0, "num_identification_disagreements": 0, "time_observed_at": "2018-10-29T00:00:00.000+01:00", "time_zone": "Brussels", "location_is_exact": false, "delta": false, "positional_accuracy": null, "private_latitude": null, "private_longitude": null, "private_positional_accuracy": null, "geoprivacy": null, "quality_grade": "casual", "positioning_method": null, "positioning_device": null, "out_of_range": null, "license": "CC-BY-NC", "uri": "https://www.inaturalist.org/observations/17932425", "observation_photos_count": 0, "comments_count": 0, "zic_time_zone": "Europe/Brussels", "oauth_application_id": 278, "observation_sounds_count": 0, "identifications_count": 1, "captive": false, "community_taxon_id": null, "site_id": 1, "old_uuid": null, "public_positional_accuracy": null, "mappable": true, "cached_votes_total": 0, "last_indexed_at": "2018-10-30T06:36:06.027-07:00", "private_place_guess": null, "uuid": "03d9e7a4-d96e-4de0-a9ec-d1dacc14be44", "user_login": "vespawatch", "iconic_taxon_name": "Insecta", "created_at_utc": "2018-10-29T13:37:32.176Z", "updated_at_utc": "2018-10-30T13:30:11.667Z", "time_observed_at_utc": "2018-10-28T23:00:00.000Z", "faves_count": 0, "owners_identification_from_vision": false } ]
- Parameters
observation_id (
int
) – iNaturalist observation IDparams (
Optional
[Dict
[str
,Any
]]) – [DEPRECATED] Request parameters as a dict instead of keyword argumentsaccess_token (
Optional
[str
]) – An access token required for user authentication, as returned byget_access_token()
species_guess (str) – Equivalent to the “What did you see?” field on the observation form. iNat will try to choose a single taxon based on this, but it may fail if it’s ambuguous
taxon_id (int) – ID of the taxon to associate with this observation
observed_on_string (Union[datetime.date, datetime.datetime, str]) – Date/time of the observation. Time zone will default to the user’s time zone if not specified.
time_zone (str) – Time zone the observation was made in
description (str) – Observation description
tag_list (Union[str, List[str]]) – Comma-separated list of tags
place_guess (str) – Name of the place where the observation was recorded. Note: iNat will not try to automatically look up coordinates based on this string
latitude (float) – Latitude of the observation; presumed datum is WGS84
longitude (float) – Longitude of the observation; presumed datum is WGS84
map_scale (int) – Google Maps zoom level (from 0 to 19) at which to show this observation’s map marker.
positional_accuracy (int) – Positional accuracy of the observation coordinates, in meters
geoprivacy (str) – Geoprivacy for the observation
observation_fields (Union[Dict, List[Dict]]) – Dict of observation fields in the format
{id: value}
. Alias forobservation_field_values_attributes
.flickr_photos (Union[int, List[int]]) – Flickr photo ID(s) to add as photos for this observation. User must have their Flickr and iNat accounts connected, and the user must own the photo(s) on Flickr.
picasa_photos (Union[str, List[str]]) – Picasa photo ID(s) to add as photos for this observation. User must have their Picasa and iNat accounts connected, and the user must own the photo(s) on Picasa.
facebook_photos (Union[str, List[str]]) – Facebook photo IDs to add as photos for this observation. User must have their Facebook and iNat accounts connected, and the user must own the photo on Facebook.
local_photos (Iterable[Union[BinaryIO, str]]) – Image files, file-like objects, and/or paths for local photos to upload
ignore_photos (bool) – If photos exist on the observation but are missing in the request, simply ignore them instead of deleting the missing observation photos
user_agent (
Optional
[str
]) – A custom user-agent string to provide to the iNaturalist APIobservation_field_values_attributes (Union[Dict, List[Dict]]) –
- Return type
List
[Dict
[str
,Any
]]- Returns
JSON response containing the newly updated observation(s)
- Raises
requests.HTTPError – error 410 if the observation doesn’t exists or belongs to another user.