TIP
Read Schema first if you haven't read it.
Endpoints
POST /api/account/login
Authenticates user.
Accepts: application/json
Request body:
type LoginRequest = {
username: string,
password: string
}
Response:
type LoginResponse = Self;
Status codes & response types:
200 OK
if login succeeds. Will return aUser
as response.401 Unauthorized
if credential is invalid. Will return astring
as response.
Example
Request:
POST https://longhub.top/api/account/login
Content-Type: application/json
{
"username": "wcnm",
"password": "<PASSWORD>"
}
Response when succeeds:
HTTP/1.1 200 OK
Content-Type: application/json
set-cookie: nmsl_cookie=<omitted>; Path=/; Expires=Fri, 05 Jul 2024 08:22:01 GMT; Max-Age=5183940; Secure; HttpOnly; SameSite=lax
{
"id": 1,
"name": "MoveToEx",
"email": null,
"accessKey": "..."
}
Response when fails:
HTTP/1.1 401 Unauthorized
Content-Type: application/json
"invalid email/password"
GET /api/account
Gets account information.
No parameters.
Requires authentication.
Response type:
type AccountResponse = Self;
Example
Request:
POST https://longhub.top/api/account/
Cookie: <omitted>
Response:
HTTP/1.1 200 OK
Content-Type: application/json
{
"id": 1,
"email": null,
"name": "MoveToEx",
"permission": 65310,
"accessKey": "<omitted>",
"createdAt": "2024-02-05T05:31:19.000Z"
}
GET /api/account/reset-key
Resets access key of current account.
No parameters.
Requires authentication.
Response:
type ResetResponse = {
accessKey: string;
}
Example
Request:
GET https://longhub.top/api/account/reset-key
X-Access-Key: <omitted>
Response:
HTTP/1.1 200 OK
Content-Type: application/json
{
"accessKey": "<omitted>"
}