SDL Tridion sites 9 Public Content API With GraphQL - Part 1
Updated: Sep 16, 2019
SDL Tridion sites 9 has couple of new features, but most promising feature is Public Content API (PCA). This API is the new endpoint for content delivery for Sites and Docs. This empowers customers by providing more dynamic and cleaner solutions for their channels.
Content API uses GraphQL, which provides a complete and understandable description of the data in your API, gives clients the power to ask for exactly what they need and nothing more.
Main Advantages of GraphQL are –
Elegant Data Retrieval: Single endpoint and versioning not required.
Efficient Querying: Specify the information you need and get data in one single-trip request.
Back-end Stability: No need to change client while modifying data.
Documentation: Simple & understandable Graph schema with self-documented feature.
Large Community: Larger community and larger number of client tools.
So today I am going to share some useful query which will help you if you are using Public Content API with Sites 9 to build and manage your application.
Note*: While installing the Content API, the default endpoint will be something like https://<server-name>:<port-no>/cd/api.
Here I am using GraphiQL client (Default in Chrome Browser) for demo purpose.
All you need to do is open your chrome browser and hit the below url https://<server-name>:<port-no>/cd/api/graphiql. Additionally, you can check this if you want to understand how to access Tridion public content API while OAuth is enabled.
Let’s start with a simple query –
In the below example, we request 3 properties of a published page by page id -
For the DOCS customer you can decorate the query like below where page id refers to the topic id –
Most frequently used query is to retrieve the raw content of a published page –
Here is the query for that:
Similarly you can retrieve the content from component presentation as well -
Another interesting query to retrieve the sitemap or navigation for your site is below -
You check this blog for complex queries like filtering by items/keywords,sorting, etc.
Hope you like this article! Please add your comments below if you need any additional information.