tca-api-headless

Routing and SEO

A frontend knows URLs, TYPO3 knows uids. The path lookup turns one into the other, and the page brings its SEO fields and a ready-made meta object for the head.

Proofregions.intro[0]

Request GET /website/_api/headless_pages/2011 #/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": 2067,
  "CType": "textmedia",
  "header": "Routing and SEO",
  "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 frontend knows URLs, TYPO3 knows uids. The path lookup turns one into the other, and the page brings its SEO fields and a ready-made "
        },
        {
          "_type": "span",
          "_key": "k2",
          "marks": [
            "code"
          ],
          "text": "meta"
        },
        {
          "_type": "span",
          "_key": "k3",
          "marks": [],
          "text": " object for the head."
        }
      ]
    }
  ],
  "assets": [
    {
      "uid": 2023,
      "name": "routing.jpg",
      "extension": "jpg",
      "publicUrl": "/fileadmin/website/plates/routing.jpg",
      "mimeType": "image/jpeg",
      "fileSize": 161591,
      "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;
};
A path lookup finds the page, which carries its SEO meta. An unknown path finds nothing, and the frontend answers with its 404.

Path lookup

The path is relative to the base of the language and resolved by the site router, route enhancers included. The result is a collection of at most one page:

GET /_api/headless_pages?path=/features/routing-seo
Response 200GET /website/_api/headless_pages?path=/features/routing-seo

Request GET /website/_api/headless_pages?path=/features/routing-seo Status 200

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:Collection",
  "@id": "/_api/headless_pages",
  "hydra:totalItems": 1,
  "hydra:member": [
    {
      "@type": "HeadlessPages",
      "@id": "/_api/headless_pages/2011",
      "uid": 2011
    }
  ],
  "hydra:view": {
    "@type": "hydra:PartialCollectionView",
    "hydra:first": "/_api/headless_pages?path=%2Ffeatures%2Frouting-seo&page=1",
    "hydra:last": "/_api/headless_pages?path=%2Ffeatures%2Frouting-seo&page=1",
    "hydra:previous": null,
    "hydra:next": null
  }
}

Generated TypeScript type

type HeadlessPagesCollection = {
    "@context"?: string;
    "@type"?: string;
    "@id"?: string;
    "hydra:totalItems"?: number;
    "hydra:member"?: components["schemas"]["HeadlessPagesLookup"][];
    "hydra:view"?: {
        "@type"?: string;
        "hydra:first"?: string;
        "hydra:last"?: string;
        "hydra:previous"?: string | null;
        "hydra:next"?: string | null;
    };
    "hydra:search"?: {
        "@type"?: string;
        "hydra:template"?: string;
        "hydra:variableRepresentation"?: string;
        "hydra:mapping"?: {
            "@type"?: string;
            variable?: string;
            property?: string;
            required?: boolean;
        }[];
    };
    redirect?: components["schemas"]["HeadlessPagesRedirect"];
};

A path without a page returns an empty collection. A request without a path is answered with 400: pages are never listed.

GET /_api/headless_pages?path=/no-such-page
Response 200GET /website/_api/headless_pages?path=/no-such-page

Request GET /website/_api/headless_pages?path=/no-such-page Status 200

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:Collection",
  "@id": "/_api/headless_pages",
  "hydra:totalItems": 0,
  "hydra:member": [],
  "hydra:view": {
    "@type": "hydra:PartialCollectionView",
    "hydra:first": "/_api/headless_pages?path=%2Fno-such-page&page=1",
    "hydra:last": "/_api/headless_pages?path=%2Fno-such-page&page=0",
    "hydra:previous": null,
    "hydra:next": null
  }
}

Generated TypeScript type

type HeadlessPagesCollection = {
    "@context"?: string;
    "@type"?: string;
    "@id"?: string;
    "hydra:totalItems"?: number;
    "hydra:member"?: components["schemas"]["HeadlessPagesLookup"][];
    "hydra:view"?: {
        "@type"?: string;
        "hydra:first"?: string;
        "hydra:last"?: string;
        "hydra:previous"?: string | null;
        "hydra:next"?: string | null;
    };
    "hydra:search"?: {
        "@type"?: string;
        "hydra:template"?: string;
        "hydra:variableRepresentation"?: string;
        "hydra:mapping"?: {
            "@type"?: string;
            variable?: string;
            property?: string;
            required?: boolean;
        }[];
    };
    redirect?: components["schemas"]["HeadlessPagesRedirect"];
};
GET /_api/headless_pages
Response 400GET /website/_api/headless_pages

Request GET /website/_api/headless_pages 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 \"path\" is required."
}

Generated TypeScript type

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

Request GET /website/_api/headless_pages/2011 #/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": 2068,
  "CType": "text",
  "header": "Path lookup",
  "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 path is relative to the base of the language and resolved by the site router, route enhancers included. The result is a collection of at most one page:"
        }
      ]
    },
    {
      "_type": "block",
      "_key": "k2",
      "style": "normal",
      "markDefs": [],
      "children": [
        {
          "_type": "span",
          "_key": "k3",
          "marks": [
            "code"
          ],
          "text": "GET /_api/headless_pages?path=/features/routing-seo"
        }
      ]
    },
    {
      "_type": "block",
      "_key": "k4",
      "style": "normal",
      "markDefs": [],
      "children": [
        {
          "_type": "span",
          "_key": "k5",
          "marks": [],
          "text": "A path without a page returns an empty collection. A request without a path is answered with 400: pages are never listed."
        }
      ]
    },
    {
      "_type": "block",
      "_key": "k6",
      "style": "normal",
      "markDefs": [],
      "children": [
        {
          "_type": "span",
          "_key": "k7",
          "marks": [
            "code"
          ],
          "text": "GET /_api/headless_pages?path=/no-such-page"
        }
      ]
    },
    {
      "_type": "block",
      "_key": "k8",
      "style": "normal",
      "markDefs": [],
      "children": [
        {
          "_type": "span",
          "_key": "k9",
          "marks": [
            "code"
          ],
          "text": "GET /_api/headless_pages"
        }
      ]
    }
  ],
  "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;
};

Meta for the head

The page sends the EXT:seo fields in the request language and derives meta from them: robots, the canonical URL and a schema.org WebPage. The head of this page was built from it. og_image is processed with the social crop and has an absolute URL.

GET /_api/headless_pages/2011
Response 200GET /website/_api/headless_pages/2011

Request GET /website/_api/headless_pages/2011 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/2011",
  "uid": 2011,
  "title": "Routing and SEO",
  "slug": "/features/routing-seo",
  "seo_title": "",
  "description": "From a path to a page, with the SEO fields and a meta object for the head.",
  "no_index": 0,
  "no_follow": 0,
  "canonical_link": null,
  "og_title": "",
  "og_description": null,
  "og_image": [
    {
      "uid": 2023,
      "name": "routing.jpg",
      "extension": "jpg",
      "publicUrl": "https://typo3.example/fileadmin/_processed_/e/d/csm_routing_4e533e7eb9.jpg",
      "mimeType": "image/jpeg",
      "fileSize": 161591,
      "metadata": {
        "title": null,
        "alternative": "An open drawer of index cards in coloured stocks with cyan, magenta and yellow tabs, one card lifted",
        "description": null,
        "copyright": null
      },
      "width": 1536,
      "height": 806
    }
  ],
  "breadcrumbs": [
    {
      "uid": 2000,
      "title": "tca-api-headless",
      "nav_title": "",
      "url": "https://typo3.example/website/",
      "doktype": 1
    },
    {
      "uid": 2002,
      "title": "Features",
      "nav_title": "",
      "url": "https://typo3.example/website/features",
      "doktype": 1
    },
    {
      "uid": 2011,
      "title": "Routing and SEO",
      "nav_title": "",
      "url": "https://typo3.example/website/features/routing-seo",
      "doktype": 1
    }
  ],
  "languages": [
    {
      "languageId": 0,
      "locale": "en-US",
      "hreflang": "en",
      "title": "English",
      "url": "https://typo3.example/website/features/routing-seo",
      "available": true,
      "active": true
    },
    {
      "languageId": 1,
      "locale": "de-DE",
      "hreflang": "de",
      "title": "German",
      "url": "https://typo3.example/website/de/funktionen/routing-seo",
      "available": true,
      "active": false
    }
  ],
  "meta": {
    "robots": "index,follow",
    "canonical": "https://typo3.example/website/features/routing-seo",
    "schema": {
      "@context": "https://schema.org",
      "@type": "WebPage",
      "url": "https://typo3.example/website/features/routing-seo",
      "name": "Routing and SEO",
      "inLanguage": "en",
      "description": "From a path to a page, with the SEO fields and a meta object for the head."
    },
    "alternates": [
      {
        "hreflang": "en",
        "href": "https://typo3.example/website/features/routing-seo"
      },
      {
        "hreflang": "de",
        "href": "https://typo3.example/website/de/funktionen/routing-seo"
      },
      {
        "hreflang": "x-default",
        "href": "https://typo3.example/website/features/routing-seo"
      }
    ]
  },
  "regions": {
    "intro": [/* 1 element */],
    "main": [/* 2 elements */],
    "specimen": [/* 1 element */]
  }
}

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"][];
    };
    shortcut?: components["schemas"]["HeadlessPagesShortcut"] | null;
};
Proofregions.main[1]

Request GET /website/_api/headless_pages/2011 #/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": 2069,
  "CType": "text",
  "header": "Meta for the head",
  "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 page sends the EXT:seo fields in the request language and derives "
        },
        {
          "_type": "span",
          "_key": "k2",
          "marks": [
            "code"
          ],
          "text": "meta"
        },
        {
          "_type": "span",
          "_key": "k3",
          "marks": [],
          "text": " from them: "
        },
        {
          "_type": "span",
          "_key": "k4",
          "marks": [
            "code"
          ],
          "text": "robots"
        },
        {
          "_type": "span",
          "_key": "k5",
          "marks": [],
          "text": ", the "
        },
        {
          "_type": "span",
          "_key": "k6",
          "marks": [
            "code"
          ],
          "text": "canonical"
        },
        {
          "_type": "span",
          "_key": "k7",
          "marks": [],
          "text": " URL and a schema.org "
        },
        {
          "_type": "span",
          "_key": "k8",
          "marks": [
            "code"
          ],
          "text": "WebPage"
        },
        {
          "_type": "span",
          "_key": "k9",
          "marks": [],
          "text": ". The head of this page was built from it. "
        },
        {
          "_type": "span",
          "_key": "k10",
          "marks": [
            "code"
          ],
          "text": "og_image"
        },
        {
          "_type": "span",
          "_key": "k11",
          "marks": [],
          "text": " is processed with the social crop and has an absolute URL."
        }
      ]
    },
    {
      "_type": "block",
      "_key": "k12",
      "style": "normal",
      "markDefs": [],
      "children": [
        {
          "_type": "span",
          "_key": "k13",
          "marks": [
            "code"
          ],
          "text": "GET /_api/headless_pages/2011"
        }
      ]
    }
  ],
  "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: City

City

A green city bike with a basket in a repair stand, tools on the bench

Built to last

Steel frames, fenders, hub gears. We keep them running for decades and true their wheels while you have a coffee.

ProofGET /kettenblatt/_api/headless_pages/3004

Request GET /kettenblatt/_api/headless_pages/3004 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/3004",
  "uid": 3004,
  "title": "City",
  "slug": "/bikes/city",
  "seo_title": "",
  "description": "Steel, fenders, hub gears.",
  "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
    },
    {
      "uid": 3004,
      "title": "City",
      "nav_title": "",
      "url": "https://typo3.example/kettenblatt/bikes/city",
      "doktype": 1
    }
  ],
  "languages": [
    {
      "languageId": 0,
      "locale": "en-US",
      "hreflang": "en",
      "title": "English",
      "url": "https://typo3.example/kettenblatt/bikes/city",
      "available": true,
      "active": true
    },
    {
      "languageId": 1,
      "locale": "de-DE",
      "hreflang": "de",
      "title": "German",
      "url": "https://typo3.example/kettenblatt/de/raeder/stadt",
      "available": true,
      "active": false
    }
  ],
  "meta": {
    "robots": "index,follow",
    "canonical": "https://typo3.example/kettenblatt/bikes/city",
    "schema": {
      "@context": "https://schema.org",
      "@type": "WebPage",
      "url": "https://typo3.example/kettenblatt/bikes/city",
      "name": "City",
      "inLanguage": "en",
      "description": "Steel, fenders, hub gears."
    },
    "alternates": [
      {
        "hreflang": "en",
        "href": "https://typo3.example/kettenblatt/bikes/city"
      },
      {
        "hreflang": "de",
        "href": "https://typo3.example/kettenblatt/de/raeder/stadt"
      },
      {
        "hreflang": "x-default",
        "href": "https://typo3.example/kettenblatt/bikes/city"
      }
    ]
  },
  "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/2011 #/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": 2070,
  "CType": "header",
  "header": "Kettenblatt: City",
  "header_layout": 0,
  "header_position": "",
  "header_link": {
    "href": "https://typo3.example/kettenblatt/bikes/city",
    "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;
};