The Fifth World

Autocomplete

This endpoint essentially provides a more specialized version of the GET /pages endpoint. It provides a maximum of five matching pages, and only lists the ID, title, and path for each, making it ideal for an autocomplete function showing several pages that a user might mean, given the string of what she has typed so far.

Request

Body Parameters
Query Parameters Value
fragment The endpoint will return any pages that use this substring in their titles.
path The endpoint will return any pages that begins with this string. This will usually match a page and its descendants, as well as any other pages that happen to share the first several characters of their string (e.g., /anim will match /animalia and all of its children, as well as /animism and all of its children).
type A page type to limit the search to. If provided, the endpoint will only return pages that also match the given type.

Examples

Example Request
POST /v1/autocomplete HTTP/1.1 Host: api.thefifthworld.com fragment=Anim

Response

The endpoint should always respond with a 200 HTTP status and a JSON object. The object has two properties: found and pages, with found being a number equal to the length of the array in pages. When the criteria provided don’t match anything, found equals zero, and pages offers an empty array.

JSON Object
Property Value Type Value
pages AbbreviatedPage[] An array of abbreviated page objects.
found number The length of the pages array returned.
Abbreviated Page Object
Property Value Type Value
id number The page’s unique ID.
path string The page’s unique path.
title string The page’s title.

Example

Example Response
{ "pages": [ { "id": 130, "path": "/animism", "title": "Animism" }, { "id": 300, "path": "/animalia", "title": "Animal" } ], "found": 2 }