API document - Lost-MSth/Arcaea-server GitHub Wiki

Brief introduction

Since v2.4, API interface has been added. You can use it to get or change data in the database.
At present the prefix is /api/v1.

It is still in building.

Standard

Now some standards will be given.

Request

For instance:

GET /api/v1/users/2000001/best HTTP/1.1
Token: 123
Content-Type: application/json
Content-Length: 128
 
{"limit": 2, "offset": 0, "query": {}, "fuzzy_query": {}, "sort": [{"column": "song_id"}, {"column": "score", "order": "DESC"}]}

Query

In some requests, you can give some query parameters.

  • limit
  • offset
  • query
  • fuzzy_query
  • sort

They will help you to get better data.

For example:

{"limit": 2, "offset": 0, "query": {}, "fuzzy_query": {}, "sort": [{"column": "song_id"}, {"column": "score", "order": "DESC"}]}

If sending a request with data is hard, you can also use URL param query. A base64 string of data is accepted.

For example:

?query=eydsaW1pdCc6Mn0=

limit

An integer.
It is obviously a limit of data from the server.

offset

An integer.
It must be together with limit. It can make the data show from an offset.
For example, if offset=5 and limit=3, the data from 5 to 7 will be returned.

query

A JSON object.
It can help you search something. Key should be one of a searchable parameter and value should be the exact value or value list of the searchable parameter.
For example, if you give {"song_id": "dement"} , it means searching data with song_id = "dement". If you give {"song_id": ["dement", "ifi"]}, it means searching data with song_id in ("dement", "ifi").

fuzzy_query

A JSON object.
Just like query, only value not value list can be accepted, however the search will be song_id like "%dement%".

sort

A JSON array. In each array, it should be a JSON object.
The order in the array determines the sort priority. Every JSON object should give a sortable parameter named column and a sort order (ASC or DESC). The default sort order is ASC.

Response

JSON format: {"code": 0, "data": ..., "msg": ""}
For instance:

HTTP/1.1 200 OK
Content-Length: 549
Content-Type: application/json
Date: Thu, 10 Nov 2022 12:23:56 GMT
Server: waitress
 
{"code":0,"data":{"data":[{"best_clear_type":0,"clear_type":0,"difficulty":2,"health":1,"miss_count":96,"modifier":0,"near_count":108,"perfect_count":1364,"rating":9.581693333333334,"score":9044508,"shiny_perfect_count":1141,"song_id":"aegleseeker","time_played":1622180001},{"best_clear_type":1,"clear_type":1,"difficulty":2,"health":100,"miss_count":2,"modifier":0,"near_count":24,"perfect_count":963,"rating":10.696250000000001,"score":9859250,"shiny_perfect_count":808,"song_id":"aiueoon","time_played":1615784156}],"user_id":2000001},"msg":""}

Error Code

Code Explanation
0 Success
-1 See status code
-2 No data
-3 No data or user
-4 Data exist
-100 Invalid post data
-101 Invalid data type
-102 Invalid query parameter
-103 Invalid sort parameter
-104 Invalid sort order parameter
-105 Invalid URL parameter
-110 Invalid user_id
-120 Invalid item type
-121 No such item
-122 Item already exists
-123 The collection already has this item
-124 The collection does not have this item
-130 No such character
-131 Invalid skill ID
-200 No permission
-201 Wrong username or password
-202 User is banned
-203 Too many login attempts
-210 Username exists
-211 Email address exists
-212 User code exists
-999 Unknown error

Power Management

Superpower

It means API interface full control permission. The token of this superpower can be set in config.py. The superpower equals to system power and it doesn't represent any user.

Role

The default role is user.

Power

⚠️ **GitHub.com Fallback** ⚠️