Client

Summary

Classes

iNatClient(creds, default_params, dry_run, ...)

API client class that provides an object-oriented interface to the iNaturalist API.

Functions

Module Contents

class pyinaturalist.client.client.iNatClient(creds, default_params, dry_run, loop, session, **kwargs)

Bases: object

API client class that provides an object-oriented interface to the iNaturalist API.

See:

Controllers (for separate API resource types):

Parameters:
  • creds (dict[str, Any] | None) – Optional arguments for get_access_token() or get_access_token_via_auth_code(), used to get and refresh access tokens as needed. Use auth_flow='authorization_code' to select authorization code flow; otherwise password flow is used.

  • default_params (dict[str, Any] | None) – Default request parameters to pass to any applicable API requests

  • dry_run (bool) – Just log all requests instead of sending real requests

  • loop (AbstractEventLoop | None) – An event loop to run any executors used for async iteration

  • session (ClientSession | None) – Session object to use instead of creating a new one

  • kwargs – Keyword arguments for ClientSession

add_defaults(request_function, kwargs, auth) dict[str, Any]

Add any applicable client settings to request parameters before sending a request. Explicit keyword arguments will override any client settings.

Return type:

dict[str, Any]

annotations

Interface for annotation requests

identifications

Interface for identification requests

observation_fields

Interface for observation field requests

observations

Interface for observation requests

paginate(request_function, model, auth, cls, **kwargs) Paginator[T]

Create a paginator for a request, with client settings applied

Parameters:
  • request_function (Callable) – The API request function to call

  • model (type[TypeVar(T, bound= BaseModel)]) – Model class used for the response

  • auth (bool) – Indicates that the request requires authentication

  • cls (type[Paginator]) – Alternative Paginator class to use

  • params – Original request parameters

Return type:

Paginator[TypeVar(T, bound= BaseModel)]

places

Interface for place requests

projects

Interface for project requests

request(request_function, *args, auth, **kwargs)

Send a request, with client settings applied.

Parameters:
  • request_function (Callable) – The API request function to call

  • auth (bool) – Indicates that the request requires authentication

  • params – Original request parameters

Returns:

Results of request_function()

search

Unified text search

taxa

Interface for taxon requests

users

Interface for user requests