Get all pages

Updated on

Overview

Stubby provides simple APIs to fetch data into your Next.js app. You can send a GET request to the following URL:

Type Value
Method GET
URL https://stubby.io/api/v1/sites/{site_id}/collections

Parameters

Property Value Comment
apiKey string API key for your site

Sample code

const STUBBY_CMS_API_KEY = "<API_KEY>"; 
const siteId = "<YOUR_SITE_ID>";

const url = new URL(`https://stubby.io/api/v1/sites/${siteId}/collections`);
url.searchParams.append("apiKey", STUBBY_CMS_API_KEY);

const res = await fetch(url.href);

const data = await res.json(); // data contains a list of all pages

Response

The response is returned as a tree structure representing the folder organization you have created in Stubby CMS. You can use this data to populate components such as side navigation, blog post landing pages, and more.