The Fifth World

Edit a page

This endpoint allows you to edit an existing page. To create a new page, see POST /pages.

Request

HTTP Headers
HTTP Header Value
Authorization A valid JSON Web Token, of the form Bearer ENCODEDHEADER.ENCODEDPAYLOAD.ENCODEDSIGNATURE.
Path Parameters
Path Parameter Value
path The page you would like to edit. This parameter does not work like most path parameters, in that you can use / characters as part of it. For example, /v1/pages/animalia/chordata/mammalia will request the page with the path /animalia/chordata/mammalia.
Body Parameters
Request Body Data Value Type Value
title string The title of the page.
description string A description of the page. This should not exceed 280 characters.
slug string A string suitable for use in a URL. If not provided, this endpoint generates one autoamtically based on the title (e.g., North America becomes north-america).
parent string The unique path of another, existing page. If provided, this endpoint creates a child of the given page. If not provided, then the new page has no parent, making it a root page.
path string A unique path for the page. If not provided, the endpoint generates one automatically by taking the parent’s path and appending / and the page’s slug. If this does not result in a unique path, or if you provide a path that some other page already has, the endpoint returns a 400 HTTP error.
body string The content of the page.
type string The page’s type. If not supplied, the endpoint looks for a substring of the form [[Type:X]] within the body and makes X the type. If you do not supply any type using this parameter, and the body does not specify any type, then the new page will not have any type. Note that any value supplied through this parameter will take precedence over any type specified in the body.
files object This object must have a file property. If that provides an image file, you may also include a thumbnail property. Both provide File objects (see below). If you do not supply any object for this parameter, any existing files associated with the page remain in place.
permissions number The permissions to set on the new page. This three-digit code uses the same conventions as Unix permissions, with the owner understood as the person who created the page, the group understood as authenticated members of the Fifth World, and the world understood as the general public. Pages default to 774, meaning that any authenticated member of the Fifth World can edit them, and anyone in the world can read them. A hidden page has a value of 700, allowing its owner to see and edit it, but no one else. A locked page has a value of 444, allowing anyone to see it, but only administrators to edit it.
msg string A commit message, describing what changes you made.
File Object
Property Value Type Value
name string The file’s name (e.g., example.txt).
data Buffer A Buffer containing the actual binary data of the file.
size number The file’s size in bytes.
encoding string A string that specifies the file’s encoding.
mimetype string The file’s MIME type (e.g., text/plain).
md5 string An MD5 hash of the file.

Examples

Example Request
POST /v1/pages/animalia/chordata/mammalia HTTP/1.1 Host: api.thefifthworld.com Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c { "title": "Mammal", "path": "/animalia/chordata/mammalia", "parent": "/animalia/chordata", "description": "Mammals give birth to live young and produce milk to nurse them. As mammals ourselves, we humans often conflate our class with the animal kingdom itself, even though we compromise only a fairly small class among vertebrates.", "body": "{{Stub}} **Mammals** give birth to live young and produce milk to nurse them. As mammals ourselves, we [[Homo sapiens | humans]] often conflate our class with the [[Animal | animal kingdom]] itself, even though we compromise only a fairly small class among [[Vertebrate | vertebrates]], who themselves make up only a small part of the kingdom. ## Orders {{Children Type=\"Order (biological taxonomy)\"}} ## External links * [Wikipedia entry](https://en.wikipedia.org/wiki/Mammalia) [[Type:Class (biological taxonomy)]]", "msg": "Example for POST /pages/{path}" }

Response

If you provide a path that is already in use by a different page, the endpoint responds with a 400 HTTP status. If you haven’t authenticated, or if you try to edit a page that you do not have write permissions to, the endpoint responds with a 401 HTTP status. If the path given in the URL does not match any existing page, the endpoint responds with a 404 HTTP status. Otherwise, the API should make the changes provided and return a 200 HTTP status and a JSON object representing the page, reflecting the new changes.

Response JSON
Property Value Type Value
page object This property provides the Page object (see below) for the page requested.
markup string This property provides the rendered HTML for the current body of the page.
Page Object
Property Value Type Value
id number The page’s unique numerical ID.
title string The title of the page.
description string The page’s description. It appears in the page’s header provided to search engines, social media, and other such bots and spiders.
slug string A string used to create the page’s unique path.
path string The unique path of this page on the Fifth World website. If you add https://thefifthworld.com to the front of this string, you’ll have its URL. By default, we create this string by taking the path of the page’s parent and appending a / and the page’s own slug to it.
parent number The unique numerical ID of this page’s parent page. If equal to 0, that means that this page does not have a parent.
data object Any structured data associated with the current version fo the page.
depth number How “deep” the page appears in the overall page hierarchy. A page that has no parent has a depth of 0. Such a page’s child would have a depth of 1, and if that page has a child, its depth will equal 2. If you wanted to trace the lineage of a page back to a “root” page that has no parents, this number tells you how many pages you will need to trace to get there.
permissions object This object has three properties: read (a boolean that indicates if you have read permission for this page, which should alwways equal true), write (a boolean that indicates if you have write permission for this page), and code. This last three-digit code uses the same conventions as Unix permissions, with the owner understood as the person who created the page, the group understood as authenticated members of the Fifth World, and the world understood as the general public. Pages default to 774, meaning that any authenticated member of the Fifth World can edit them, and anyone in the world can read them. A hidden page has a value of 700, allowing its owner to see and edit it, but no one else. A locked page has a value of 444, allowing anyone to see it, but only administrators to edit it.
type string The page’s type.
tags object An object that provides the key/value pairs of the page’s tags.
location object or boolean If a page has a location associated with it (as pages of type Place should), this property provides an object, which itself provides two properties, both numbers: lat (which provides the location’s latitude) and lon (which provides the location’s longitude). If a page does not have any location associated with it, this property equals false.
likes array This property provides an array of the unique member ID’s of everyone who has liked this page.
files array This property provides an array of File objects (see below).
owner object The page’s owner (the person who first created it). This object includes properties id (the member’s unique numerical ID) and name (the string that this member has provided for hens name).
history array This property provides an array of Change objects (see below), providing the history of changes made to this page.
lineage array This property includes an array of this page’s “ancestors,” so if this page has a parent, a Page object for that page will appear in this array, and if that page has a parent, a Page object for its parent will also appear in the array. The “root” page (the one that has no parent of its own) appears first, and the page’s direct parent comes last. If the page has no parent, then you will find an empty array here.
File Object
Property Value Type Value
name string The unique key used to find the file on the CDN.
thumbnail string The unique key used to find the file’s thumbnail on the CDN. Only images have thumbnails.
mime string The MIME type of this file.
size number The file’s size in bytes.
readableSize string The file’s size, parsed into a human-readable string (e.g., if size equals 104,864, then readableSize will equal 104.9 kB).
page number The unique numerical ID of the page this file belongs to.
timestamp number When the uploader uploaded this file, presented as a Unix Epoch timestamp (the number of seconds since midnight on 1 January 1970 UTC).
uploader number The unique numerical ID of the member who uploaded this file.
urls object An object with two properties: full (providing the URL from which you can access the full file on the CDN) and thumbnail (providing the URL from which you can access the thumbnail on the CDN). Only images have thumbnails.
Change Object
Property Value Type Value
id number A unique numerical ID for this change.
timestamp string The time when this change happened.
msg string The commit message that the editor provided to explain the change and why hen made it.
content object An object providing the content of the changes made. Many of these properties map to those in the Page object, but they usually include the body property as well. This property includes the unparsed wikitext of the page. When you view the page, the content displayed comes from the body property of the most recent change made, parsed into HTML.
editor object An object with two properties: id (the unique numerical ID of the member who made this change) and name (the name that the member who made this change provided for henself).

Example

Example Response
{ "page": { "id": 333, "title": "Mammal", "description": "Mammals give birth to live young and produce milk to nurse them. As mammals ourselves, we humans often conflate our class with the animal kingdom itself, even though we compromise only a fairly small class among vertebrates.", "slug": "mammalia", "path": "/animalia/chordata/mammalia", "parent": 301, "depth": 2, "permissions": { "read": true, "write": true, "code": 774 }, "type": "Class (biological taxonomy)", "tags": {}, "location": false, "likes": [], "files": [], "owner": { "id": 1048, "name": "Fifth World Bot" }, "history": [ { "id": 119807, "timestamp": "2020-01-09T01:53:33.000Z", "msg": "Initial text", "content": { "title": "Mammalia", "path": "/animalia/chordata/mammalia", "parent": "/animalia/chordata", "body": "{{Stub}}\n\nThe class ***Mammalia*** belongs to the phylum [[/animalia/chordata | Chordata]].\n\n## Orders\n\n{{Children Type=\"Order (biological taxonomy)\"}}\n\n## External links\n\n* [Wikipedia entry](https://en.wikipedia.org/wiki/Mammalia)\n\n[[Type:Class (biological taxonomy)]]", "description": "The class Mammalia belongs to the phylum Chordata." }, "editor": { "name": "Fifth World Bot", "id": 1048 } } ], "lineage": [ { "id": 300, "title": "Animal", "description": "Animals form one of the kingdoms of life.", "slug": "animalia", "path": "/animalia", "parent": 0, "depth": 0, "permissions": 774, "type": "Kingdom (biological taxonomy)", "tags": {}, "location": false, "likes": [], "files": [], "owner": { "id": 1048, "name": "Fifth World Bot" }, "history": [...] }, { "id": 301, "title": "Vertebrate", "description": "Vertebrates include humans and other mammals, as well as fish, birds, and most of the other complex living things that we normally think of when we think of animals (even though insects outnumber us all by a wide margin).", "slug": "chordata", "path": "/animalia/chordata", "parent": 300, "depth": 1, "permissions": 774, "type": "Phylum (biological taxonomy)", "tags": {}, "location": false, "likes": [], "files": [], "owner": { "id": 1048, "name": "Fifth World Bot" }, "history": [...] } ] }, "markup": "<aside>We only have a <strong>stub</strong> for this article right now. Help us out by fleshing it out further.</aside>\n<p><strong>Mammals</strong> give birth to live young and produce milk to nurse them. As mammals ourselves, we <a href=\"/new?title=Homo%20sapiens\" class=\"isNew\">humans</a> often conflate our class with the <a href=\"/animalia\" title=\"Animal\">animal kingdom</a> itself, even though we compromise only a fairly small class among <a href=\"/animalia/chordata\" title=\"Vertebrate\">vertebrates</a>, who themselves make up only a small part of the kingdom.</p>\n" }