Learn how to extract page content and details using the Pages API.
Pages are perfect for static content that has lasting relevance or needs only occasional updates.
In this article, you'll learn how to use the Pages API to extract content and details from Pages in your Staffbase platform.
This is particularly useful in the following scenarios:
-
Indexing for AI Use Cases
If your business wants to extract content for indexing purposes. It's particularly useful if you have AI chatbots that need to search and retrieve information from this content more effectively.
This article does not cover how to implement indexing for chatbots or other AI-driven applications. You will need to develop those implementations based on your requirements. -
Content Creation Across Multiple Sources
If you need to generate content that appears in more than one place, such as documenting HR guidelines on both your intranet and HR system.
- You have created an API token via the Staffbase Studio. Learn more.
- You have administrative access to the pages or spaces from which you want to extract content.
-
Make a
GET
request to the endpoint/pages
.Example request:
curl --location 'https://exampleapp.staffbase.rocks/api/pages' \--header 'Authorization: Basic {Token}' \--data '' -
Filter the response to extract page contents.
-
Repeat steps 1 and 2 until you have retrieved all pages from your platform.
-
Store the page details and content in your database.
-
Make a
GET
request to/pages/sync?includeDelete=true
to get the latest changes in pages within the last 60 days. -
Repeat the request until you get to the last cursor.
Example request:
curl --location 'https://exampleapp.staffbase.com/api/pages/sync?includeDelete=true%3Fcursor%3DZ29vZCB0byBrbm93_NWI2MmMzNDVlYTJkMTVkN2E3YmRhMmFm' \--header 'Authorization: Basic {Token}' -
Store the last cursor value to use in subsequent requests.
-
Configure automation to make a
GET
request to/pages/sync?includeDelete=true?cursor={value}
using the stored cursor value to receive only the changes since the last request. The cursor value ensures that you receive only the changes since the previous sync.You can schedule this automation to run weekly or adjust it according to your business needs. However, to avoid potential disruptions, be aware of the rate limits and avoid excessive requests in a short period. For more information, refer to the article on rate limits. -
Compare the records in your database from Step 4 with the latest changes retrieved in Step 5.
This way, you can effectively extract and maintain page content from your Staffbase platform, keeping it ready for indexing, synchronization, or other business needs.