Skip to content

Creating and editing a category

Théandre Bourry edited this page Jun 24, 2023 · 1 revision

Categories are a new way to sort and filter pages in the API. These categories can be made through the interface, via this route:

POST - api/createcategory/{categoryName}

Concretely, this will create a file named {categoryName}.category with a json content on the server. If one already exists, it will be overwriten, which is why you may want to retrieve one's content before overwriting it (see Getting a category and its informations).

Route infos

Authorizations

This route requires the user to send a key to the API. This key is 256 characters long and generated completely randomly. It is changed every six months to ensure it isn't cracked.

Parameters

Mandatory

Parameter Data type Description Example
{categoryName} string The name of the category to create or edit. If it contains spaces, they should be replaced with underscores beforehand. Category_Name1

Optional

There are no optional parameters to give for this route.

Resquest body

This is what the request body will look like:

{
    "validationString": "<authentication key>",
    "category": {
        "links": "",
        "pages": []
    }
}
  • validationString: This will be compared with the key stored locally on the server (after encryption) to see if the user is allowed to send modifications.
  • category: The json object representing the actual category.
    • links: This is the markdown content to add automatically to every page when a category is selected for them. Its primary purpose is to add links, but there may actually be much more. If a page is added several categories, these strings are meant to be concatenated (which may lead to links appearing twice though).
    • pages: The list of pages this category has, identified by their names (that is to say, the markdown file name they correspond to). Once again, space should be replaced with underscores.

Response

When successful, this route returns a 204 HTTP code. If the authentication fails, it will return a 401 (Unauthorized) code. In any case, it won't return a body.