In this tutorial, you will learn about some of the APIs that are available when using Episerver as a headless CMS via the content delivery API. Traditionally, when working with Episerver you to render pages and blocks on a website you would use out-of-the-box C# razor helpers to render. In the new world, all pages and blocks are rendered by reading data returned from a JSON API.

To enabled content API, install the Nuget package Episerver.ContentDeliveryApi:

After installing the plug-in, you will need to give the ContentApiRead role read-access to the homepage and all of its children (assuming the whole site is available to the API). Within the Episerver admin area, under 'Set Access Rights', ensure the ContentApiRead role has 'read' and 'Apply settings for all subitems' are both enabled.

Next, you will either need to create or modify the WebAPi config, like so:

Which will need to be registered within global.ascx:

Next, you will need to configure the API. This can be done within a C# initlisatoin module, like so:

The code above makes the API public so anyone can query it. It also enables a special site definition API. This is useful for debugging at the start. Enabling it will allow you to test that the content API is working. To check the site definition API you can access it like this:

This will return a bunch of data, including siteSettings, language selectors, currencies etc.. If you want to query the API for a specific page or block, you can query it using the content API:

If the content exists, the API will return some corresponding JSON, like so: