Messages¶
Summary¶
Classes
Functions
|
Get a message by ID |
|
Get messages from the user's inbox |
|
Get the number of unread messages in the user's inbox |
Module Contents¶
- pyinaturalist.v1.messages.get_message_by_id(message_id, **params)¶
Get a message by ID
Notes
API reference: GET /messages/{id}
- Parameters:
message_id (
int
) – Get the message with this ID. Multiple IDs are allowed.access_token (
Optional
[str
]) – An access token for user authentication, as returned byget_access_token()
dry_run (
Optional
[bool
]) – Just log the request instead of sending a real requestsession (
Optional
[Session
]) – An existing Session object to use instead of creating a new one
Example
>>> response = get_messages(123456) >>> pprint(response)
{ "page": 1, "per_page": 30, "total_results": 1, "results": [ { "id": 12345, "user_id": 12345, "thread_id": 12345, "subject": "Re: Test Message", "body": "This is a message body", "read_at": "2019-09-02T19:03:07.109-05:00", "created_at": "2019-09-02T18:50:24.651-05:00", "updated_at": "2019-09-02T18:50:24.651-05:00", "from_user": { "id": 12345, "login": "test_user", "spam": false, "suspended": false, "created_at": "2017-09-29T18:29:20+00:00", "login_autocomplete": "test_user", "login_exact": "test_user", "name": "Test User", "name_autocomplete": "Test User", "orcid": null, "icon": "https://static.inaturalist.org/attachments/users/icons/2115051/thumb.jpeg?1591", "observations_count": 1, "identifications_count": 0, "journal_posts_count": 0, "activity_count": 1, "species_count": 1, "universal_search_rank": 3169, "roles": [], "site_id": 1, "icon_url": "https://static.inaturalist.org/attachments/users/icons/2115051/medium.jpeg" }, "to_user": { "id": 2115051, "login": "jkcook", "spam": false, "suspended": false, "created_at": "2019-08-10T17:52:01+00:00", "login_autocomplete": "jkcook", "login_exact": "jkcook", "name": "Jordan Cook", "name_autocomplete": "Jordan Cook", "orcid": null, "icon": "https://static.inaturalist.org/attachments/users/icons/2115051/thumb.jpeg?1591994381", "observations_count": 754, "identifications_count": 555, "journal_posts_count": 0, "activity_count": 1309, "species_count": 387, "universal_search_rank": 754, "roles": [], "site_id": 1, "icon_url": "https://static.inaturalist.org/attachments/users/icons/2115051/medium.jpeg?1591994381" } } ] }
- pyinaturalist.v1.messages.get_messages(**params)¶
Get messages from the user’s inbox
Notes
API reference: GET /messages
- Parameters:
q (
Optional
[str
]) – Search string for message subject and bodythreads (
bool
) – Group results bythread_id
, and only get the latest message per thread. Incompatible withq
param.access_token (
Optional
[str
]) – An access token for user authentication, as returned byget_access_token()
dry_run (
Optional
[bool
]) – Just log the request instead of sending a real requestAn existing Session object to use instead of creating a new one
Example
>>> response = get_messages() >>> pprint(response)
{ "page": 1, "per_page": 30, "total_results": 1, "results": [ { "id": 12345, "user_id": 12345, "thread_id": 12345, "subject": "Re: Test Message", "body": "This is a message body", "read_at": "2019-09-02T19:03:07.109-05:00", "created_at": "2019-09-02T18:50:24.651-05:00", "updated_at": "2019-09-02T18:50:24.651-05:00", "from_user": { "id": 12345, "login": "test_user", "spam": false, "suspended": false, "created_at": "2017-09-29T18:29:20+00:00", "login_autocomplete": "test_user", "login_exact": "test_user", "name": "Test User", "name_autocomplete": "Test User", "orcid": null, "icon": "https://static.inaturalist.org/attachments/users/icons/2115051/thumb.jpeg?1591", "observations_count": 1, "identifications_count": 0, "journal_posts_count": 0, "activity_count": 1, "species_count": 1, "universal_search_rank": 3169, "roles": [], "site_id": 1, "icon_url": "https://static.inaturalist.org/attachments/users/icons/2115051/medium.jpeg" }, "to_user": { "id": 2115051, "login": "jkcook", "spam": false, "suspended": false, "created_at": "2019-08-10T17:52:01+00:00", "login_autocomplete": "jkcook", "login_exact": "jkcook", "name": "Jordan Cook", "name_autocomplete": "Jordan Cook", "orcid": null, "icon": "https://static.inaturalist.org/attachments/users/icons/2115051/thumb.jpeg?1591994381", "observations_count": 754, "identifications_count": 555, "journal_posts_count": 0, "activity_count": 1309, "species_count": 387, "universal_search_rank": 754, "roles": [], "site_id": 1, "icon_url": "https://static.inaturalist.org/attachments/users/icons/2115051/medium.jpeg?1591994381" } } ] }
- pyinaturalist.v1.messages.get_unread_message_count(**params)¶
Get the number of unread messages in the user’s inbox
Notes
API reference: GET /messages/unread
Example
>>> get_unread_message_count() 12
- Return type:
- Returns:
Unread message count