pyinaturalist.api_requests module

Some common functions for HTTP requests used by both the Node and REST API modules

pyinaturalist.api_requests.delete(url: str, **kwargs)requests.models.Response[source]

Wrapper around requests.delete() that supports dry-run mode

pyinaturalist.api_requests.env_to_bool(environment_variable: str)bool[source]

Translate an environment variable to a boolean value, accounting for minor variations (case, None vs. False, etc.)

pyinaturalist.api_requests.get(url: str, **kwargs)requests.models.Response[source]

Wrapper around requests.get() that supports dry-run mode

pyinaturalist.api_requests.is_dry_run_enabled(method: str)bool[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.

pyinaturalist.api_requests.log_request(*args, **kwargs)[source]

Log all relevant information about an HTTP request

pyinaturalist.api_requests.post(url: str, **kwargs)requests.models.Response[source]

Wrapper around requests.post() that supports dry-run mode

pyinaturalist.api_requests.put(url: str, **kwargs)requests.models.Response[source]

Wrapper around requests.put() that supports dry-run mode

pyinaturalist.api_requests.request(method: str, url: str, access_token: Optional[str] = None, user_agent: Optional[str] = None, params: Optional[Dict] = None, headers: Optional[Dict] = None, **kwargs)requests.models.Response[source]

Wrapper around requests.request() that supports dry-run mode and adds appropriate headers.

Parameters
  • method – HTTP method

  • url – Request URL

  • access_token – access_token: the access token, as returned by get_access_token()

  • user_agent – a user-agent string that will be passed to iNaturalist