ProjectController#

class pyinaturalist.controllers.ProjectController(client)#

Bases: pyinaturalist.controllers.base_controller.BaseController

Controller for Project requests

Methods

__call__(project_id, **kwargs)#

Get a single project by ID

Return type

Optional[Project]

__init__(client)#
add_observations(project_id, *observation_ids, **params)#

Add an observation to a project

Parameters
  • project_id (int) – ID of project to add onto

  • observation_ids (int) – One or more observation IDs to add

Return type

List[Dict[str, Any]]

add_users(project_id, *user_ids, **params)#

Add users to project observation rules

Notes

Parameters
  • project_id (Union[int, str]) – Either numeric project ID or URL slug

  • user_ids (Union[int, Iterable[int]]) – One or more user IDs to add. Only accepts numeric IDs.

Return type

Project

delete_users(project_id, *user_ids, **params)#

Remove users from project observation rules

Notes

Parameters
  • project_id (Union[int, str]) – Either numeric project ID or URL slug

  • user_ids (Union[int, Iterable[int]]) – One or more user IDs to remove. Only accepts numeric IDs.

Return type

Project

from_ids(*project_ids, **params)#

Get projects by ID

Parameters

project_ids (Union[int, str]) – One or more project IDs

Return type

Paginator[Project]

search(**params)#

Search projects

Notes

Parameters
  • q (Optional[str]) – Project name must begin with this value

  • id (Union[int, Iterable[int], None]) – Must have this ID

  • not_id (Union[int, Iterable[int], None]) – Must not have this ID

  • lat (Optional[float]) – Must be within a radius kilometer circle around this lat/lng

  • lng (Optional[float]) – Must be within a radius kilometer circle around this lat/lng

  • radius (int) – Distance from center ((lat, lng)) to search, in kilometers. Defaults to 500km.

  • featured (Optional[bool]) – Must be marked featured for the relevant site

  • noteworthy (Optional[bool]) – Must be marked noteworthy for the relevant site

  • place_id (Union[int, Iterable[int], None]) – Must be in the place with this ID

  • site_id (Optional[int]) – Site ID that applies to featured and noteworthy. Defaults to the site of the authenticated user, or to the main iNaturalist site

  • rule_details (Optional[bool]) – Return more information about project rules, for example return a full taxon object instead of simply an ID

  • type (Union[str, Iterable[str], None]) – Projects must be of this type

  • member_id (Optional[int]) – Project must have member with this user ID

  • has_params (Optional[bool]) – Must have search parameter requirements

  • has_posts (Optional[bool]) – Must have posts

  • order_by (Optional[str]) – Sort order. distance only applies if lat and lng are specified. featured only applies if featured or noteworthy are true. unless otherwise noted

  • order_by – Field to sort on

  • reverse (Optional[bool]) – Reverse the order of results; alias for order='descending'

Return type

Paginator[Project]

update(project_id, **params)#

Update a project

Notes

  • Requires authentication

  • Undocumented endpoint; may be subject to braking changes in the future

  • admin_attributes and project_observation_rules_attributes each accept a list of dicts in the formats shown below. These can be obtained from get_projects(), modified, and then passed to this function:

    {
        "admin_attributes": [
            {"id": int, "role": str, "user_id": int, "_destroy": bool},
        ],
        "project_observation_rules_attributes": [
            {"operator": str, "operand_type": str, "operand_id": int, "id": int, "_destroy": bool},
        ],
    }
    
Parameters
  • project_id (Union[int, str]) – Numeric project ID or slug (the short name shown in project URL)

  • cover (Optional[str]) – Banner image for project page; ideally 760x320 px

  • description (Optional[str]) – Description shown on project page

  • icon (Optional[str]) – Image used as project icon. Should be at least 72x72 px and will be cropped to a square.

  • preferred_banner_color (Optional[str]) – Background color for project banner, as a RGB hex value (e.g., '#74ac00')

  • prefers_banner_contain (Optional[bool]) – Fit banner image without cropping

Return type

Project