[buddypress-trac] [BuddyPress Trac] #8697: BP REST API Messages endpoint - total messages per thread
buddypress-trac
noreply at wordpress.org
Sun May 22 17:05:25 UTC 2022
#8697: BP REST API Messages endpoint - total messages per thread
-------------------------+----------------------------------
Reporter: niftythree | Owner: (none)
Type: enhancement | Status: new
Priority: low | Milestone: Under Consideration
Component: REST API | Version:
Severity: minor | Resolution:
Keywords: |
-------------------------+----------------------------------
Changes (by espellcaste):
* priority: normal => low
* severity: normal => minor
* milestone: Awaiting Review => Under Consideration
Comment:
@niftythree I'd like to clarify the request.
If I understood the request correctly, you would like to get the total
number of messages in a request/thread.
So if your app requests a thread which has 30 messages, and you make a
request to show 10 messages per page/screen, you would like the 10 items
but also wanna know the total amount of messages are available in this
thread.
If that's the case, you can get this information not in the response of
the request but in its header. See https://developer.wordpress.org/rest-
api/using-the-rest-api/pagination/#pagination-parameters
> To determine how many pages of data are available, the API returns two
header fields with every paginated response:
> X-WP-Total: the total number of records in the collection
> X-WP-TotalPages: the total number of pages encompassing all available
records
That means you can:
- get the total number of thread messages using the `X-WP-Total` header.
- get the total number of screens/pages using the `X-WP-TotalPages` header
- And the total amount of messages per screen `recipients_per_page`, which
is a parameter you can set as well.
See https://developer.buddypress.org/bp-rest-api/reference/private-
messaging/#list-messages-threads for a list of pagination parameters which
are specific to this endpoint.
--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/8697#comment:1>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac
More information about the buddypress-trac
mailing list