Creating a Customizable JSON Endpoint For Content's custom API JSON endpoints will save your app developers a lot of time by making requesting dynamic data on your frontend quick and easy. Learn more about the headless CMS offering here.

Implementing Custom Endpoints

Before jumping into the steps below we recommend installing a JSON viewer extension for Chrome for effortless viewing and simple debugging JSON.

  1. Navigate to the Web IDE section, locate the blue "create file" button at the top of the left-hand navigation, and click it.

  2. Select Custom File Type from the dropdown.

  3. Name your file. The name of this file will be used to reference your custom endpoint. For example if the file is named /test-data the endpoint is referenced at preview URL can also be used in place of your live domain. Note: always consume the production URL when accessing endpoints. URLs not only show unpublished data but also are not cached.

  4. Copy this code example below, and paste it into your new file

Note: Don't forget to add the leading slash in your file name as the file name gets concatenated to your instance's url.

5. Replace content references in the copied code above with actual content models in your instance. You have full access to Parsley code in this view.

6. Edit content references as necessary to form proper JSON. We provide .escapeForJS() for WYSIWYG content. To create comma separated lists in an each loop implement calls like {{if {tag._length} != {tab._num} }},{{end-if}}.

7. Setup optional get parameters like start and limit to make custom pagination calls

Last updated