2019-11-22 15:33:22 +01:00
|
|
|
title: API
|
|
|
|
|
|
|
|
## Authentication
|
|
|
|
|
|
|
|
Not all endpoints require authentication.
|
|
|
|
Authentication is done using Bearer tokens:
|
|
|
|
|
2021-02-02 18:09:19 +01:00
|
|
|
```bash
|
|
|
|
curl -H "Authorization: Bearer YOURTOKEN" https://content.minetest.net/api/whoami/
|
|
|
|
```
|
2019-11-22 15:33:22 +01:00
|
|
|
|
2021-02-02 18:09:19 +01:00
|
|
|
Tokens can be attained by visiting [Settings > API Tokens](/user/tokens/).
|
2020-05-19 18:24:57 +02:00
|
|
|
|
2019-11-22 15:33:22 +01:00
|
|
|
## Endpoints
|
|
|
|
|
|
|
|
### Misc
|
|
|
|
|
|
|
|
* GET `/api/whoami/` - Json dictionary with the following keys:
|
2021-02-02 18:09:25 +01:00
|
|
|
* `is_authenticated` - True on successful API authentication
|
|
|
|
* `username` - Username of the user authenticated as, null otherwise.
|
|
|
|
* 4xx status codes will be thrown on unsupported authentication type, invalid access token, or other errors.
|
2019-11-22 15:33:22 +01:00
|
|
|
|
|
|
|
### Packages
|
|
|
|
|
|
|
|
* GET `/api/packages/` - See [Package Queries](#package-queries)
|
2020-04-21 19:15:13 +02:00
|
|
|
* GET `/api/scores/` - See [Package Queries](#package-queries)
|
2019-11-22 15:33:22 +01:00
|
|
|
* GET `/api/packages/<username>/<name>/`
|
2020-06-05 05:48:53 +02:00
|
|
|
* GET `/api/packages/<username>/<name>/dependencies/`
|
2021-02-02 18:09:25 +01:00
|
|
|
* If query argument `only_hard` is present, only hard deps will be returned.
|
2021-01-16 01:34:09 +01:00
|
|
|
* GET `/api/tags/` - List of:
|
2021-02-02 18:09:25 +01:00
|
|
|
* `name` - technical name
|
|
|
|
* `title` - human-readable title
|
|
|
|
* `description` - tag description or null
|
2021-01-16 01:34:09 +01:00
|
|
|
* GET `/api/homepage/`
|
2021-02-02 18:09:25 +01:00
|
|
|
* `count` - number of packages
|
|
|
|
* `downloads` - get number of downloads
|
|
|
|
* `new` - new packages
|
|
|
|
* `updated` - recently updated packages
|
|
|
|
* `pop_mod` - popular mods
|
|
|
|
* `pop_txp` - popular textures
|
|
|
|
* `pop_game` - popular games
|
|
|
|
* `high_reviewed` - highest reviewed
|
2019-11-22 15:33:22 +01:00
|
|
|
|
2020-01-24 21:21:40 +01:00
|
|
|
### Releases
|
|
|
|
|
2021-02-02 18:09:19 +01:00
|
|
|
* GET `/api/packages/<username>/<name>/releases/` (List)
|
|
|
|
* POST `/api/packages/<username>/<name>/releases/new/` (Create)
|
2021-02-02 18:09:25 +01:00
|
|
|
* Requires authentication.
|
|
|
|
* Body is multipart form if zip upload, JSON otherwise.
|
|
|
|
* `title`: human-readable name of the release.
|
|
|
|
* For Git release creation:
|
|
|
|
* `method`: must be `git`.
|
|
|
|
* `ref`: (Optional) git reference, eg: `master`.
|
|
|
|
* For zip upload release creation:
|
|
|
|
* `file`: multipart file to upload, like `<input type=file>`.
|
|
|
|
* You can set min and max Minetest Versions [using the content's .conf file](/help/package_config/).
|
2020-01-24 21:21:40 +01:00
|
|
|
|
2021-02-02 18:09:19 +01:00
|
|
|
Examples:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
# Create release from Git
|
|
|
|
curl -X POST https://content.minetest.net/api/packages/username/name/releases/new/ \
|
2021-02-02 18:09:25 +01:00
|
|
|
-H "Authorization: Bearer YOURTOKEN" -H "Content-Type: application/json" \
|
|
|
|
-d "{\"method\": \"git\", \"title\": \"My Release\", \"ref\": \"master\" }"
|
2021-02-02 18:09:19 +01:00
|
|
|
|
|
|
|
# Create release from zip upload
|
|
|
|
curl https://content.minetest.net/api/packages/username/name/releases/new/ \
|
2021-02-02 18:09:25 +01:00
|
|
|
-H "Authorization: Bearer YOURTOKEN" \
|
|
|
|
-F title="My Release" -F file=@path/to/file.zip
|
2021-02-02 18:09:19 +01:00
|
|
|
```
|
2020-01-24 21:21:40 +01:00
|
|
|
|
2021-02-02 18:09:23 +01:00
|
|
|
### Screenshots
|
|
|
|
|
2021-02-02 18:09:25 +01:00
|
|
|
* GET `/api/packages/<username>/<name>/screenshots/` (List)
|
|
|
|
* Returns array of screenshot dictionaries with keys:
|
|
|
|
* `id`: screenshot ID
|
|
|
|
* `approved`: true if approved and visible.
|
|
|
|
* `title`: human-readable name for the screenshot, shown as a caption and alt text.
|
|
|
|
* `url`: absolute URL to screenshot.
|
|
|
|
* `order`: Number used in ordering.
|
|
|
|
* GET `/api/packages/<username>/<name>/screenshots/<id>/` (Read)
|
|
|
|
* Returns screenshot dictionary like above.
|
2021-02-02 18:09:23 +01:00
|
|
|
* POST `/api/packages/<username>/<name>/screenshots/new/` (Create)
|
2021-02-02 18:09:25 +01:00
|
|
|
* Requires authentication.
|
|
|
|
* Body is multipart form data.
|
|
|
|
* `title`: human-readable name for the screenshot, shown as a caption and alt text.
|
|
|
|
* `file`: multipart file to upload, like `<input type=file>`.
|
|
|
|
* DELETE `/api/packages/<username>/<name>/screenshots/<id>/` (Delete)
|
|
|
|
* Requires authentication.
|
|
|
|
* Deletes screenshot.
|
|
|
|
* POST `/api/packages/<username>/<name>/screenshots/order/`
|
|
|
|
* Requires authentication.
|
|
|
|
* Body is a JSON array containing the screenshot IDs in their order.
|
2021-02-02 18:09:23 +01:00
|
|
|
|
2021-02-02 18:09:25 +01:00
|
|
|
Examples:
|
2021-02-02 18:09:23 +01:00
|
|
|
|
|
|
|
```bash
|
2021-02-02 18:09:25 +01:00
|
|
|
# Create screenshots
|
2021-02-02 18:09:23 +01:00
|
|
|
curl https://content.minetest.net/api/packages/username/name/screenshots/new/ \
|
2021-02-02 18:09:25 +01:00
|
|
|
-H "Authorization: Bearer YOURTOKEN" \
|
|
|
|
-F title="My Release" -F file=@path/to/screnshot.png
|
|
|
|
|
|
|
|
# Delete screenshot
|
|
|
|
curl -X DELETE https://content.minetest.net/api/packages/username/name/screenshots/3/ \
|
|
|
|
-H "Authorization: Bearer YOURTOKEN"
|
|
|
|
|
|
|
|
# Reorder screenshots
|
|
|
|
curl -X POST https://content.minetest.net/api/packages/username/name/screenshots/order/ \
|
|
|
|
-H "Authorization: Bearer YOURTOKEN" -H "Content-Type: application/json" \
|
|
|
|
-d "[13, 2, 5, 7]"
|
2021-02-02 18:09:23 +01:00
|
|
|
```
|
|
|
|
|
2019-11-22 15:33:22 +01:00
|
|
|
### Topics
|
|
|
|
|
|
|
|
* GET `/api/topics/` - Supports [Package Queries](#package-queries), and the following two options:
|
2021-02-02 18:09:25 +01:00
|
|
|
* `show_added` - Show topics which exist as packages, default true.
|
|
|
|
* `show_discarded` - Show topics which have been marked as outdated, default false.
|
2019-11-22 15:33:22 +01:00
|
|
|
|
|
|
|
### Minetest
|
|
|
|
|
|
|
|
* GET `/api/minetest_versions/`
|
|
|
|
|
|
|
|
|
|
|
|
## Package Queries
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
2021-02-02 18:09:25 +01:00
|
|
|
/api/packages/?type=mod&type=game&q=mobs+fun&hide=nonfree&hide=gore
|
2019-11-22 15:33:22 +01:00
|
|
|
|
|
|
|
Supported query parameters:
|
|
|
|
|
|
|
|
* `type` - Package types (`mod`, `game`, `txp`).
|
2020-07-10 23:32:52 +02:00
|
|
|
* `q` - Query string.
|
|
|
|
* `author` - Filter by author.
|
|
|
|
* `tag` - Filter by tags.
|
2019-11-22 15:33:22 +01:00
|
|
|
* `random` - When present, enable random ordering and ignore `sort`.
|
2020-07-10 23:32:52 +02:00
|
|
|
* `limit` - Return at most `limit` packages.
|
2020-05-31 22:29:55 +02:00
|
|
|
* `hide` - Hide content based on [Content Flags](/help/content_flags/).
|
2020-12-14 12:48:07 +01:00
|
|
|
* `sort` - Sort by (`name`, `title`, `score`, `reviews`, `downloads`, `created_at`, `approved_at`, `last_release`).
|
2020-07-10 23:32:52 +02:00
|
|
|
* `order` - Sort ascending (`asc`) or descending (`desc`).
|
2019-11-22 15:33:22 +01:00
|
|
|
* `protocol_version` - Only show packages supported by this Minetest protocol version.
|
2020-07-10 23:32:52 +02:00
|
|
|
* `engine_version` - Only show packages supported by this Minetest engine version, eg: `5.3.0`.
|
2021-01-16 01:34:09 +01:00
|
|
|
* `fmt` - How the response is formated.
|
2021-02-02 18:09:25 +01:00
|
|
|
* `keys` - author/name only.
|
|
|
|
* `short` - stuff needed for the Minetest client.
|
2020-07-10 23:32:52 +02:00
|
|
|
|
|
|
|
|
|
|
|
## Topic Queries
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
2021-02-02 18:09:25 +01:00
|
|
|
/api/topics/?q=mobs
|
2020-07-10 23:32:52 +02:00
|
|
|
|
|
|
|
Supported query parameters:
|
|
|
|
|
|
|
|
* `q` - Query string.
|
|
|
|
* `sort` - Sort by (`name`, `views`, `date`).
|
|
|
|
* `order` - Sort ascending (`asc`) or descending (`desc`).
|
|
|
|
* `show_added` - Show topics that have an existing package.
|
|
|
|
* `show_discarded` - Show topics marked as discarded.
|
|
|
|
* `limit` - Return at most `limit` topics.
|