pyinaturalist.api_requests module¶
Some common functions for HTTP requests used by both the Node and REST API modules
-
pyinaturalist.api_requests.
delete
(url, **kwargs)[source]¶ Wrapper around
requests.delete()
that supports dry-run mode- Return type
- Parameters
url (str) –
-
pyinaturalist.api_requests.
env_to_bool
(environment_variable)[source]¶ Translate an environment variable to a boolean value, accounting for minor variations (case, None vs. False, etc.)
- Return type
bool
- Parameters
environment_variable (str) –
-
pyinaturalist.api_requests.
get
(url, **kwargs)[source]¶ Wrapper around
requests.get()
that supports dry-run mode- Return type
- Parameters
url (str) –
-
pyinaturalist.api_requests.
is_dry_run_enabled
(method)[source]¶ A wrapper to determine if dry-run (aka test mode) has been enabled via either a constant or an environment variable. Dry-run mode may be enabled for either write requests, or all requests.
- Return type
bool
- Parameters
method (str) –
-
pyinaturalist.api_requests.
log_request
(*args, **kwargs)[source]¶ Log all relevant information about an HTTP request
-
pyinaturalist.api_requests.
post
(url, **kwargs)[source]¶ Wrapper around
requests.post()
that supports dry-run mode- Return type
- Parameters
url (str) –
-
pyinaturalist.api_requests.
put
(url, **kwargs)[source]¶ Wrapper around
requests.put()
that supports dry-run mode- Return type
- Parameters
url (str) –
-
pyinaturalist.api_requests.
request
(method, url, access_token=None, user_agent=None, ids=None, params=None, headers=None, **kwargs)[source]¶ Wrapper around
requests.request()
that supports dry-run mode and adds appropriate headers.- Parameters
method (
str
) – HTTP methodurl (
str
) – Request URLaccess_token (
Optional
[str
]) – access_token: the access token, as returned byget_access_token()
user_agent (
Optional
[str
]) – a user-agent string that will be passed to iNaturalistids (
Union
[str
,List
,None
]) – One or more integer IDs used as REST resource(s) to requestparams (
Optional
[Dict
]) – Requests parametersheaders (
Optional
[Dict
]) – Request headers
- Return type
- Returns
API response