Skip to content

Understanding the API

codie edited this page May 25, 2021 · 9 revisions

Platforms

The four platforms currently supported by the content repo are Web, Whatsapp, Viber and Messenger. The API only returns results for one platform at a time depending on which platform is requested.

Requesting content for different platforms

In order to retrieve content for a platform, the following endpoints are accepted

/api/v2/pages/<page-id>/?whatsapp=True

/api/v2/pages/<page-id>/?viber=True

/api/v2/pages/<page-id>/?messenger=True

If no platform is provided int he query string, the API will return the web content.

If a platform has been requested but has not been enabled on the CMS, the API will return web content

Content Body Pagination

For Whatsapp, Viber and Messenger, each text block in the CMS counts as 1 message. If no message index is sent in the query string, the API will return the first message. Below are examples for how to request specific messages.

/api/v2/pages/<page-id>/?whatsapp=True&message=1

/api/v2/pages/<page-id>/?viber=True&message=4

/api/v2/pages/<page-id>/?messenger=True&message=2

The content body that is returned will return the indexes of the previous and next messages as well, and None if no previous or next message.

Content Pages Pagination

You can paginate content pages by adding a limit and and offset. The limit is the page size, and the offset is the amount to start from. For example:

/api/v2/pages/?offset=2&limit=2 will give the second page with 2 results

/api/v2/pages/?offset=4&limit=2 will give the third page with 2 results

Content Pages Filtering

/api/v2/pages/?tag=relationships will give all the articles that have been tagged for relationships

Clone this wiki locally