tca-api-headless

Navigation

One request returns a page and its subpages as a tree: titles, slugs, doktype and absolute URLs in the request language. The menu at the top of this page and the page list in the footer were built from it.

Proofregions.intro[0]

Request GET /website/_api/headless_pages/2010 #/regions/intro/0 Status 200

Recorded at build time from TYPO3 14.3. Host replaced with typo3.example; the data is unchanged. Full JSON response

JSON response

{
  "uid": 2060,
  "CType": "textmedia",
  "header": "Navigation",
  "header_layout": 0,
  "header_position": "",
  "header_link": null,
  "subheader": "",
  "bodytext": [
    {
      "_type": "block",
      "_key": "k0",
      "style": "normal",
      "markDefs": [],
      "children": [
        {
          "_type": "span",
          "_key": "k1",
          "marks": [],
          "text": "One request returns a page and its subpages as a tree: titles, slugs, doktype and absolute URLs in the request language. The menu at the top of this page and the page list in the footer were built from it."
        }
      ]
    }
  ],
  "assets": [
    {
      "uid": 2022,
      "name": "navigation.jpg",
      "extension": "jpg",
      "publicUrl": "/fileadmin/website/plates/navigation.jpg",
      "mimeType": "image/jpeg",
      "fileSize": 156840,
      "metadata": {
        "title": null,
        "description": null
      }
    }
  ],
  "layout": 0,
  "frame_class": "default",
  "space_before_class": "",
  "space_after_class": ""
}

Generated TypeScript type

type HeadlessContentTextmediaRead = {
    "@type"?: string;
    "@id"?: string;
    uid?: number;
    CType: "textmedia";
    header?: string;
    header_layout?: number;
    header_position?: string;
    header_link?: components["schemas"]["HeadlessLink"] | null;
    subheader?: string;
    bodytext?: components["schemas"]["PortableText"];
    assets?: components["schemas"]["FileObject"][];
    layout?: number;
    frame_class?: string;
    space_before_class?: string;
    space_after_class?: string;
};
The menu tree down to the default depth; the depth parameter asks for more, up to maxDepth.

Depth

Without a parameter the tree goes down navigation.depth levels, one on this request:

GET /_api/headless_navigation/2000?depth=1
Response 200GET /website/_api/headless_navigation/2000?depth=1

Request GET /website/_api/headless_navigation/2000?depth=1 Status 200

Recorded at build time from TYPO3 14.3. Host replaced with typo3.example; the data is unchanged. Full JSON response

JSON response

{
  "@type": "HeadlessNavigation",
  "@id": "/_api/headless_navigation/2000",
  "uid": 2000,
  "title": "tca-api-headless",
  "nav_title": "",
  "slug": "/",
  "doktype": 1,
  "url": "https://typo3.example/website/",
  "children": [
    {
      "@type": "HeadlessNavigation",
      "@id": "/_api/headless_navigation/2001",
      "uid": 2001,
      "title": "Quick start",
      "nav_title": "",
      "slug": "/quick-start",
      "doktype": 1,
      "url": "https://typo3.example/website/quick-start",
      "children": []
    },
    {
      "@type": "HeadlessNavigation",
      "@id": "/_api/headless_navigation/2002",
      "uid": 2002,
      "title": "Features",
      "nav_title": "",
      "slug": "/features",
      "doktype": 1,
      "url": "https://typo3.example/website/features",
      "children": []
    },
    {
      "@type": "HeadlessNavigation",
      "@id": "/_api/headless_navigation/2014",
      "uid": 2014,
      "title": "Contract",
      "nav_title": "",
      "slug": "/contract",
      "doktype": 1,
      "url": "https://typo3.example/website/contract",
      "children": []
    },
    {
      "@type": "HeadlessNavigation",
      "@id": "/_api/headless_navigation/2016",
      "uid": 2016,
      "title": "Specimen",
      "nav_title": "",
      "slug": "/specimen",
      "doktype": 1,
      "url": "https://typo3.example/website/specimen",
      "children": []
    },
    {
      "@type": "HeadlessNavigation",
      "@id": "/_api/headless_navigation/2015",
      "uid": 2015,
      "title": "Extensions",
      "nav_title": "",
      "slug": "/extensions",
      "doktype": 1,
      "url": "https://typo3.example/website/extensions",
      "children": []
    },
    {
      "@type": "HeadlessNavigation",
      "@id": "/_api/headless_navigation/2017",
      "uid": 2017,
      "title": "Sitemap",
      "nav_title": "",
      "slug": "/sitemap",
      "doktype": 1,
      "url": "https://typo3.example/website/sitemap",
      "children": []
    },
    {
      "@type": "HeadlessNavigation",
      "@id": "/_api/headless_navigation/2004",
      "uid": 2004,
      "title": "Colophon",
      "nav_title": "",
      "slug": "/colophon",
      "doktype": 1,
      "url": "https://typo3.example/website/colophon",
      "children": []
    }
  ]
}

Generated TypeScript type

type HeadlessNavigationRead = {
    "@type"?: string;
    "@id"?: string;
    uid: number;
    title?: string;
    nav_title?: string;
    slug?: string | null;
    doktype?: 1 | 3 | 4;
    url: string;
    children: components["schemas"]["HeadlessNavigationRead"][];
};

A higher depth is capped to navigation.maxDepth, four on this site. This request asks for nine:

GET /_api/headless_navigation/2002?depth=9
Response 200GET /website/_api/headless_navigation/2002?depth=9

Request GET /website/_api/headless_navigation/2002?depth=9 Status 200

Recorded at build time from TYPO3 14.3. Host replaced with typo3.example; the data is unchanged. Full JSON response

JSON response

{
  "@type": "HeadlessNavigation",
  "@id": "/_api/headless_navigation/2002",
  "uid": 2002,
  "title": "Features",
  "nav_title": "",
  "slug": "/features",
  "doktype": 1,
  "url": "https://typo3.example/website/features",
  "children": [
    {
      "@type": "HeadlessNavigation",
      "@id": "/_api/headless_navigation/2003",
      "uid": 2003,
      "title": "Pages and regions",
      "nav_title": "",
      "slug": "/features/regions",
      "doktype": 1,
      "url": "https://typo3.example/website/features/regions",
      "children": []
    },
    {
      "@type": "HeadlessNavigation",
      "@id": "/_api/headless_navigation/2009",
      "uid": 2009,
      "title": "Content and rich text",
      "nav_title": "",
      "slug": "/features/content",
      "doktype": 1,
      "url": "https://typo3.example/website/features/content",
      "children": []
    },
    {
      "@type": "HeadlessNavigation",
      "@id": "/_api/headless_navigation/2010",
      "uid": 2010,
      "title": "Navigation",
      "nav_title": "",
      "slug": "/features/navigation",
      "doktype": 1,
      "url": "https://typo3.example/website/features/navigation",
      "children": []
    },
    {
      "@type": "HeadlessNavigation",
      "@id": "/_api/headless_navigation/2011",
      "uid": 2011,
      "title": "Routing and SEO",
      "nav_title": "",
      "slug": "/features/routing-seo",
      "doktype": 1,
      "url": "https://typo3.example/website/features/routing-seo",
      "children": []
    },
    {
      "@type": "HeadlessNavigation",
      "@id": "/_api/headless_navigation/2012",
      "uid": 2012,
      "title": "Translations",
      "nav_title": "",
      "slug": "/features/translations",
      "doktype": 1,
      "url": "https://typo3.example/website/features/translations",
      "children": []
    },
    {
      "@type": "HeadlessNavigation",
      "@id": "/_api/headless_navigation/2013",
      "uid": 2013,
      "title": "Links",
      "nav_title": "",
      "slug": "/features/links",
      "doktype": 1,
      "url": "https://typo3.example/website/features/links",
      "children": []
    }
  ]
}

Generated TypeScript type

type HeadlessNavigationRead = {
    "@type"?: string;
    "@id"?: string;
    uid: number;
    title?: string;
    nav_title?: string;
    slug?: string | null;
    doktype?: 1 | 3 | 4;
    url: string;
    children: components["schemas"]["HeadlessNavigationRead"][];
};
Proofregions.main[0]

Request GET /website/_api/headless_pages/2010 #/regions/main/0 Status 200

Recorded at build time from TYPO3 14.3. Host replaced with typo3.example; the data is unchanged. Full JSON response

JSON response

{
  "uid": 2061,
  "CType": "text",
  "header": "Depth",
  "header_layout": 0,
  "header_position": "",
  "header_link": null,
  "subheader": "",
  "bodytext": [
    {
      "_type": "block",
      "_key": "k0",
      "style": "normal",
      "markDefs": [],
      "children": [
        {
          "_type": "span",
          "_key": "k1",
          "marks": [],
          "text": "Without a parameter the tree goes down "
        },
        {
          "_type": "span",
          "_key": "k2",
          "marks": [
            "code"
          ],
          "text": "navigation.depth"
        },
        {
          "_type": "span",
          "_key": "k3",
          "marks": [],
          "text": " levels, one on this request:"
        }
      ]
    },
    {
      "_type": "block",
      "_key": "k4",
      "style": "normal",
      "markDefs": [],
      "children": [
        {
          "_type": "span",
          "_key": "k5",
          "marks": [
            "code"
          ],
          "text": "GET /_api/headless_navigation/2000?depth=1"
        }
      ]
    },
    {
      "_type": "block",
      "_key": "k6",
      "style": "normal",
      "markDefs": [],
      "children": [
        {
          "_type": "span",
          "_key": "k7",
          "marks": [],
          "text": "A higher "
        },
        {
          "_type": "span",
          "_key": "k8",
          "marks": [
            "code"
          ],
          "text": "depth"
        },
        {
          "_type": "span",
          "_key": "k9",
          "marks": [],
          "text": " is capped to "
        },
        {
          "_type": "span",
          "_key": "k10",
          "marks": [
            "code"
          ],
          "text": "navigation.maxDepth"
        },
        {
          "_type": "span",
          "_key": "k11",
          "marks": [],
          "text": ", four on this site. This request asks for nine:"
        }
      ]
    },
    {
      "_type": "block",
      "_key": "k12",
      "style": "normal",
      "markDefs": [],
      "children": [
        {
          "_type": "span",
          "_key": "k13",
          "marks": [
            "code"
          ],
          "text": "GET /_api/headless_navigation/2002?depth=9"
        }
      ]
    }
  ],
  "layout": 0,
  "frame_class": "default",
  "space_before_class": "",
  "space_after_class": ""
}

Generated TypeScript type

type HeadlessContentTextRead = {
    "@type"?: string;
    "@id"?: string;
    uid?: number;
    CType: "text";
    header?: string;
    header_layout?: number;
    header_position?: string;
    header_link?: components["schemas"]["HeadlessLink"] | null;
    subheader?: string;
    bodytext?: components["schemas"]["PortableText"];
    layout?: number;
    frame_class?: string;
    space_before_class?: string;
    space_after_class?: string;
};

An invalid depth

A depth that is not a positive integer is a client error:

GET /_api/headless_navigation/2000?depth=all
Response 400GET /website/_api/headless_navigation/2000?depth=all

Request GET /website/_api/headless_navigation/2000?depth=all Status 400

Recorded at build time from TYPO3 14.3. Host replaced with typo3.example; the data is unchanged. Full JSON response

JSON response

{
  "@context": "http://www.w3.org/ns/hydra/context.jsonld",
  "@type": "hydra:Error",
  "hydra:title": "Bad Request",
  "hydra:description": "The query parameter \"depth\" must be a positive integer."
}

Generated TypeScript type

type HydraError = {
    "@context"?: string;
    "@type": string;
    "hydra:title": string;
    "hydra:description": string;
};
Proofregions.main[1]

Request GET /website/_api/headless_pages/2010 #/regions/main/1 Status 200

Recorded at build time from TYPO3 14.3. Host replaced with typo3.example; the data is unchanged. Full JSON response

JSON response

{
  "uid": 2062,
  "CType": "text",
  "header": "An invalid depth",
  "header_layout": 0,
  "header_position": "",
  "header_link": null,
  "subheader": "",
  "bodytext": [
    {
      "_type": "block",
      "_key": "k0",
      "style": "normal",
      "markDefs": [],
      "children": [
        {
          "_type": "span",
          "_key": "k1",
          "marks": [],
          "text": "A depth that is not a positive integer is a client error:"
        }
      ]
    },
    {
      "_type": "block",
      "_key": "k2",
      "style": "normal",
      "markDefs": [],
      "children": [
        {
          "_type": "span",
          "_key": "k3",
          "marks": [
            "code"
          ],
          "text": "GET /_api/headless_navigation/2000?depth=all"
        }
      ]
    }
  ],
  "layout": 0,
  "frame_class": "default",
  "space_before_class": "",
  "space_after_class": ""
}

Generated TypeScript type

type HeadlessContentTextRead = {
    "@type"?: string;
    "@id"?: string;
    uid?: number;
    CType: "text";
    header?: string;
    header_layout?: number;
    header_position?: string;
    header_link?: components["schemas"]["HeadlessLink"] | null;
    subheader?: string;
    bodytext?: components["schemas"]["PortableText"];
    layout?: number;
    frame_class?: string;
    space_before_class?: string;
    space_after_class?: string;
};

What a menu leaves out

The tree follows the rules of a frontend menu. Pages hidden in menus, pages not available in the language and the pages of other sites are left out, and a left-out page hides its subpages. This site's Meta page is hidden in menus, so the footer finds the imprint by a path lookup. The Colophon has no German translation, so the German menu doesn't list it.

Standard pages, links and shortcuts (doktype 1, 3 and 4) are listed and delivered; doktype tells them apart, and url is always the page's own URL. Other doktypes answer like a missing page.

Proofregions.main[2]

Request GET /website/_api/headless_pages/2010 #/regions/main/2 Status 200

Recorded at build time from TYPO3 14.3. Host replaced with typo3.example; the data is unchanged. Full JSON response

JSON response

{
  "uid": 2063,
  "CType": "text",
  "header": "What a menu leaves out",
  "header_layout": 0,
  "header_position": "",
  "header_link": null,
  "subheader": "",
  "bodytext": [
    {
      "_type": "block",
      "_key": "k0",
      "style": "normal",
      "markDefs": [],
      "children": [
        {
          "_type": "span",
          "_key": "k1",
          "marks": [],
          "text": "The tree follows the rules of a frontend menu. Pages hidden in menus, pages not available in the language and the pages of other sites are left out, and a left-out page hides its subpages. This site's Meta page is hidden in menus, so the footer finds the imprint by a path lookup. The Colophon has no German translation, so the German menu doesn't list it."
        }
      ]
    },
    {
      "_type": "block",
      "_key": "k2",
      "style": "normal",
      "markDefs": [],
      "children": [
        {
          "_type": "span",
          "_key": "k3",
          "marks": [],
          "text": "Standard pages, links and shortcuts (doktype 1, 3 and 4) are listed and delivered; "
        },
        {
          "_type": "span",
          "_key": "k4",
          "marks": [
            "code"
          ],
          "text": "doktype"
        },
        {
          "_type": "span",
          "_key": "k5",
          "marks": [],
          "text": " tells them apart, and "
        },
        {
          "_type": "span",
          "_key": "k6",
          "marks": [
            "code"
          ],
          "text": "url"
        },
        {
          "_type": "span",
          "_key": "k7",
          "marks": [],
          "text": " is always the page's own URL. Other doktypes answer like a missing page."
        }
      ]
    }
  ],
  "layout": 0,
  "frame_class": "default",
  "space_before_class": "",
  "space_after_class": ""
}

Generated TypeScript type

type HeadlessContentTextRead = {
    "@type"?: string;
    "@id"?: string;
    uid?: number;
    CType: "text";
    header?: string;
    header_layout?: number;
    header_position?: string;
    header_link?: components["schemas"]["HeadlessLink"] | null;
    subheader?: string;
    bodytext?: components["schemas"]["PortableText"];
    layout?: number;
    frame_class?: string;
    space_before_class?: string;
    space_after_class?: string;
};

Same API, another frontend

Fictional specimen site, rendered by the same API.

Kettenblatt: Bikes

Bikes

Three kinds of bikes leave our stands most weeks. We work on steel, aluminium and anything with a chain.

Where it all turns

Close-up of a steel chainring and chain
ProofGET /kettenblatt/_api/headless_pages/3003

Request GET /kettenblatt/_api/headless_pages/3003 Status 200

Recorded at build time from TYPO3 14.3. Host replaced with typo3.example; the data is unchanged. Full JSON response

JSON response

{
  "@type": "HeadlessPages",
  "@id": "/_api/headless_pages/3003",
  "uid": 3003,
  "title": "Bikes",
  "slug": "/bikes",
  "seo_title": "",
  "description": "The bikes we see most.",
  "no_index": 0,
  "no_follow": 0,
  "canonical_link": null,
  "og_title": "",
  "og_description": null,
  "og_image": [],
  "breadcrumbs": [
    {
      "uid": 3000,
      "title": "Kettenblatt",
      "nav_title": "",
      "url": "https://typo3.example/kettenblatt/",
      "doktype": 1
    },
    {
      "uid": 3003,
      "title": "Bikes",
      "nav_title": "",
      "url": "https://typo3.example/kettenblatt/bikes",
      "doktype": 1
    }
  ],
  "languages": [
    {
      "languageId": 0,
      "locale": "en-US",
      "hreflang": "en",
      "title": "English",
      "url": "https://typo3.example/kettenblatt/bikes",
      "available": true,
      "active": true
    },
    {
      "languageId": 1,
      "locale": "de-DE",
      "hreflang": "de",
      "title": "German",
      "url": "https://typo3.example/kettenblatt/de/raeder",
      "available": true,
      "active": false
    }
  ],
  "meta": {
    "robots": "index,follow",
    "canonical": "https://typo3.example/kettenblatt/bikes",
    "schema": {
      "@context": "https://schema.org",
      "@type": "WebPage",
      "url": "https://typo3.example/kettenblatt/bikes",
      "name": "Bikes",
      "inLanguage": "en",
      "description": "The bikes we see most."
    },
    "alternates": [
      {
        "hreflang": "en",
        "href": "https://typo3.example/kettenblatt/bikes"
      },
      {
        "hreflang": "de",
        "href": "https://typo3.example/kettenblatt/de/raeder"
      },
      {
        "hreflang": "x-default",
        "href": "https://typo3.example/kettenblatt/bikes"
      }
    ]
  },
  "regions": {
    "main": [/* 2 elements */]
  }
}

Generated TypeScript type

type HeadlessPagesRead = {
    "@type"?: string;
    "@id"?: string;
    uid?: number;
    title?: string;
    slug?: string | null;
    seo_title?: string;
    description?: string | null;
    no_index?: number;
    no_follow?: number;
    canonical_link?: components["schemas"]["HeadlessLink"] | null;
    og_title?: string;
    og_description?: string | null;
    og_image?: components["schemas"]["FileObject"][];
    breadcrumbs: components["schemas"]["HeadlessPagesBreadcrumb"][];
    languages: components["schemas"]["HeadlessPagesLanguage"][];
    meta: components["schemas"]["HeadlessPagesMeta"];
    regions: {
        [key: string]: (components["schemas"]["HeadlessContentRead"] | components["schemas"]["HeadlessContentFallbackRead"])[];
    };
    shortcut?: components["schemas"]["HeadlessPagesShortcut"] | null;
};
Proofregions.specimen[0]

Request GET /website/_api/headless_pages/2010 #/regions/specimen/0 Status 200

Recorded at build time from TYPO3 14.3. Host replaced with typo3.example; the data is unchanged. Full JSON response

JSON response

{
  "uid": 2064,
  "CType": "header",
  "header": "Kettenblatt: Bikes",
  "header_layout": 0,
  "header_position": "",
  "header_link": {
    "href": "https://typo3.example/kettenblatt/bikes",
    "target": null,
    "title": null
  },
  "subheader": "",
  "layout": 0,
  "frame_class": "default",
  "space_before_class": "",
  "space_after_class": ""
}

Generated TypeScript type

type HeadlessContentHeaderRead = {
    "@type"?: string;
    "@id"?: string;
    uid?: number;
    CType: "header";
    header?: string;
    header_layout?: number;
    header_position?: string;
    header_link?: components["schemas"]["HeadlessLink"] | null;
    subheader?: string;
    layout?: number;
    frame_class?: string;
    space_before_class?: string;
    space_after_class?: string;
};