]> git.lizzy.rs Git - cheatdb.git/blob - app/flatpages/help/api.md
Fix API auth crash and add more error messages
[cheatdb.git] / app / flatpages / help / api.md
1 title: API
2
3 ## Authentication
4
5 Not all endpoints require authentication.
6 Authentication is done using Bearer tokens:
7
8         Authorization: Bearer YOURTOKEN
9
10 You can use the `/api/whoami` to check authentication.
11
12 Tokens can be attained by visiting "API Tokens" on your profile page.
13
14 ## Endpoints
15
16 ### Misc
17
18 * GET `/api/whoami/` - Json dictionary with the following keys:
19         * `is_authenticated` - True on successful API authentication
20         * `username` - Username of the user authenticated as, null otherwise.
21         * 4xx status codes will be thrown on unsupported authentication type, invalid access token, or other errors.
22
23 ### Packages
24
25 * GET `/api/packages/` - See [Package Queries](#package-queries)
26 * GET `/api/scores/` - See [Package Queries](#package-queries)
27 * GET `/api/packages/<username>/<name>/`
28
29 ### Releases
30
31 * GET `/api/packages/<username>/<name>/releases/`
32 * POST `/api/packages/<username>/<name>/releases/new/`
33         * Requires authentication.
34         * `title`: human-readable name of the release.
35         * `method`: Release-creation method, only `git` is supported.
36         * `min_protocol`: (Optional) minimum Minetest protocol version. See [Minetest](#minetest).
37         * `min_protocol`: (Optional) maximum Minetest protocol version. See [Minetest](#minetest).
38         * If `git` release-creation method:
39                 * `ref` - git reference, eg: `master`.
40
41
42 ### Topics
43
44 * GET `/api/topics/` - Supports [Package Queries](#package-queries), and the following two options:
45     * `show_added` - Show topics which exist as packages, default true.
46         * `show_discarded` - Show topics which have been marked as outdated, default false.
47
48 ### Minetest
49
50 * GET `/api/minetest_versions/`
51
52
53 ## Package Queries
54
55 Example:
56
57         /api/packages/?type=mod&type=game&q=mobs+fun&hide=nonfree&hide=gore
58
59 Supported query parameters:
60
61 * `type` - Package types (`mod`, `game`, `txp`).
62 * `q` - Query string
63 * `random` - When present, enable random ordering and ignore `sort`.
64 * `hide` - Hide content based on [Content Flags](content_flags).
65 * `sort` - Sort by (`name`, `views`, `date`, `score`).
66 * `order` - Sort ascending (`Asc`) or descending (`desc`).
67 * `protocol_version` - Only show packages supported by this Minetest protocol version.