-
Notifications
You must be signed in to change notification settings - Fork 4
BlogNow API References
机智的小鱼君 edited this page Oct 11, 2021
·
2 revisions
API endpoint:
/api
Table of Contents toc
The endpoints marked ❗ require login.
The endpoints marked
‼️ may need auth level higher than1
.
Get the personal token from /user/auth/sign-in
API.
Request with header Authorization: {token}
or cookie BLOG_NOW_TOKEN={token}
The token will expire 7 days after the last valid request.
type: application/json
name | type | example | description |
---|---|---|---|
code | number |
200 |
HTTP status |
message | string |
"ok" |
- |
body | any |
{ "post": {...} } |
Response body |
error | any? |
{ "mongoError": {...} } |
Error info |
errors
-
401 Unauthorized
Login required -
403 Forbidden
Permision denied
Endpoint: /user/:CONTROLLER/:SCOPE
POST /user/auth/register
name | type | required | description |
---|---|---|---|
username | string |
✔️ | More than 5 characters |
password | string |
✔️ | More than 5 characters |
Nothing special
-
400 Bad Request
Username or password is too short -
409 Conflict
Requested username is already in use
POST /user/auth/sign-in
Alias: /user/auth/login
name | type | required | description |
---|---|---|---|
username | string |
✔️ | More than 5 characters |
password | string |
✔️ | More than 5 characters |
name | type | example | description |
---|---|---|---|
token | string |
- | Personal token |
profile | UserProfile |
{ "uuid": "...", ... } |
Personal profile data |
GET /user/auth/profile
-
name | type | example | description |
---|---|---|---|
profile | UserProfile |
{ "uuid": "...", ... } |
Personal profile data |
profile.authority | number |
1 |
Number between 0-4 |
profile.avatar | string |
- | Avatar URL |
profile.created_at | string |
- | Date string |
profile.email | string |
- | Personal email |
profile.gender | "male" | "female" | "other" |
- | Gender |
profile.nickname | string |
- | - |
profile.slogan | string |
- | - |
profile.title | string |
- | Special title |
profile.uid | number |
12345 |
Number more than 10000 |
profile.username | string |
- | User name |
profile.uuid | string |
- | UUID |
GET /post/:CONTROLLER/:SCOPE
name | type | required | description |
---|---|---|---|
:CONTROLLER | "uuid" | "pid" | "slug" |
✔️ | Filter controller |
:SCOPE | string |
✔️ | Filter scope |
name | type | example | description |
---|---|---|---|
post | PostData |
- | Post data |
post.author_uuid | string |
- | User UUID |
post.content | string |
"Hello, world. This is my post!" |
Post raw content |
post.created_at | string |
"2021-10-09T13:37:51.220Z" |
Date string |
post.edited_at | string? |
- | Date string |
post.editor_uuid | string? |
- | Mdifier user UUID |
post.pid | posInt |
"123" |
Number more than 1 |
post.slug | string? |
"hello-world" |
Slug |
post.title | string |
"Hello, world" |
Post title |
post.uuid | string |
"f6b72355-9864-4115-95c0-7b75a" |
Post UUID |
GET /post/list/recent
name | type | required | description |
---|---|---|---|
limit | number |
➖ | Number between 1-25 |
offset | number |
➖ | Number more than 0 |
name | type | example | description |
---|---|---|---|
posts | PostData[] |
- | List of post data |
POST /post/new
Alias: /post/create
name | type | required | description |
---|---|---|---|
title | string |
✔️ | Post display title |
content | string |
➖ | Post raw content (markdown) |
slug | string |
➖ | Post slug |
name | type | example | description |
---|---|---|---|
uuid | string |
- | Post UUID |
-
409 Conflict
Slug conflict
PATCH /post/:CONTROLLER/:SCOPE
name | type | required | description |
---|---|---|---|
:CONTROLLER | "uuid" | "pid" | "slug" |
✔️ | Filter controller |
:SCOPE | string |
✔️ | Filter scope |
title | string |
➖ | Post display title |
content | string |
➖ | Post raw content (markdown) |
slug | string |
➖ | Post slug |
Nothing special
-
404 Not Found
The specified post was not found -
409 Conflict
Slug conflict