This document outlines the design and usage guidelines for the API, including the list of endpoints, request and response formats, error handling, etc.
Project information
- Data format : JSON
- Authorization : Session based
{
"msg": Return msg list,
"ok": Boolean,
"data": Object(Main part of result)
}
ReturnMsgOK = "ok"
ReturnMsgSuccess = "success"
ReturnMsgError = "error"
ErrorInvalid = "post data invalid"
ErrorMissing = "post data missing"
ErrorTypeError = "post data type error"
ErrorPermissionDenied = "permission denied"
ErrorNotFound = "not found"
ErrorNoUser = "user not found"
ErrorSessionInvalid = "user session invalid"
ErrorPassword = "password error"
- URL: '/user/create'
- Method: POST
- LoginRequired: No
"username"
string
"nickname"
string
"email"
string
"phonenum"
int
"headerfield"
string
"password"
string
"msg"
string
"ok"
bool
"data"
object
"data.userid"
int
{
"username": "example",
"nickname": "John",
"email": "[email protected]",
"phonenum": 1234567890,
"headerfield": "some value",
"password": "password123"
}
{
"msg": "success",
"ok": true,
"data": {
"userid": 12345
}
}
- URL: '/user/login/email'
- Method: POST
- LoginRequired: No
"email"
string
"password"
string
"msg"
string
"ok"
bool
"data"
object
"data.Session"
string
Header
Set-session
string
{
"email": "[email protected]",
"password": "password123"
}
{
"msg": "success",
"ok": true,
"data": {
"Session": "some random session"
}
}
- URL: '/user/login/phone'
- Method: POST
- LoginRequired: No
"phone"
string
"password"
string
"msg"
string
"ok"
bool
"data"
object
"data.Session"
string
Header
Set-session
string
{
"phone": "123 0000 0000",
"password": "password123"
}
{
"msg": "success",
"ok": true,
"data": {
"Session": "some random session"
}
}
- URL: '/user/login/uname'
- Method: POST
- LoginRequired: No
"username"
string
"password"
string
"msg"
string
"ok"
bool
"data"
object
"data.Session"
string
Header
Set-session
string
{
"username": "123",
"password": "password123"
}
{
"msg": "success",
"ok": true,
"data": {
"Session": "some random session"
}
}
- URL: '/user/login/check'
- Method: POST
- LoginRequired: No
WARN: Direct post session is not safe in some case. Don't let session accessible in font-end js.
"session"
string
"msg"
string
"ok"
bool
"data"
object
"data.userid"
int
{
"session": "some random session"
}
{
"msg": "success",
"ok": true,
"data": {
"userid": 1234
}
}
- URL: '/user/self'
- Method: POST
- LoginRequired: Yes
Nothing
"msg"
string
"ok"
bool
"data"
object
"data.id"
int
"data.username"
string
"data.nickname"
string
"data.email"
string
"data.adminflag"
bool
"data.lastlogin"
timestamp(second)
"data.phonenum"
int
"data.headerfield"
string
{
}
{
"msg": "success",
"ok": true,
"data": {
"id": 12345,
"username": "example",
"nickname": "John",
"email": "[email protected]",
"adminflag": true,
"lastlogin": 1647312000,
"phonenum": 1234567890,
"headerfield": "some value"
}
}
- URL: '/user/self/full'
- Method: POST
- LoginRequired: Yes
Nothing
"msg"
string
"ok"
bool
"data"
object
"data.articlenumber"
int
"data.articlelist"
list
"data.collectionnumber"
int
"data.followingnumber"
int
"data.followernumber"
int
"data.userinfo"
object
"data.userinfo.username"
string
"data.userinfo.nickname"
string
"data.userinfo.email"
string
"data.userinfo.adminflag"
bool
"data.userinfo.lastlogin"
timestamp(second)
"data.userinfo.phonenum"
int
"data.userinfo.headerfield"
string
{
}
{
"msg": "success",
"ok": true,
"data": {
"articlenumber": 10,
"articlelist": [...],
"collectionnumber": 5,
"followingnumber": 20,
"followernumber": 15,
"userinfo": {
"username": "example",
"nickname": "John",
"email": "[email protected]",
"adminflag": true,
"lastlogin": 1647312000,
"phonenum": 1234567890,
"headerfield": "some value"
}
}
}
- URL: '/user/logout'
- Method: POST
- LoginRequired: Yes
Nothing
"msg"
string
"ok"
bool
"data"
object
Header
Set-session
""
{
}
{
"msg": "success",
"ok": true,
"data": {
}
}
- URL: '/user/update/name'
- Method: POST
- LoginRequired: Yes
"name"
string
"msg"
string
"ok"
bool
"data"
object
"data.name"
string
{
"name": ""
}
{
"msg": "success",
"ok": true,
"data": {
"name": "name"
}
}
- URL: '/user/update/email'
- Method: POST
- LoginRequired: Yes
"email"
string
"msg"
string
"ok"
bool
"data"
object
"data.email"
string
{
"email": ""
}
{
"msg": "success",
"ok": true,
"data": {
"email": "[email protected]"
}
}
- URL: '/user/update/nickname'
- Method: POST
- LoginRequired: Yes
"nickname"
string
"msg"
string
"ok"
bool
"data"
object
"data.nickname"
string
{
"nickname": "nickname123"
}
{
"msg": "success",
"ok": true,
"data": {
"nickname": "nickname123"
}
}
- URL: '/user/update/phone'
- Method: POST
- LoginRequired: Yes
"phonenum"
string
"msg"
string
"ok"
bool
"data"
object
"data.phone"
string
{
"phonenum": "123 0000 0000"
}
{
"msg": "success",
"ok": true,
"data": {
"phone": "123 0000 0000"
}
}
- URL: '/user/update/headerfield'
- Method: POST
- LoginRequired: Yes
"headerfield"
string
"msg"
string
"ok"
bool
"data"
object
"data.headerfield"
string
{
"headerfield": "url address"
}
{
"msg": "success",
"ok": true,
"data": {
"headerfield": "url address"
}
}
- URL: '/user/update'
- Method: POST
- LoginRequired: Yes
"headerfield"
string
"email"
string
"nickname"
string
"headerfield
string
"phonenum"
string
"msg"
string
"ok"
bool
"data"
object
"data.email"
string
"data.name"
string
"data.nickname"
string
"data.headerfield"
string
"data.phonenum"
string
{
"email": "[email protected]",
"name": "John Doe",
"nickname": "Johnny",
"headerfield": "url address",
"phonenum": "1234567890"
}
{
"msg": "success",
"ok": true,
"data": {
"email": "[email protected]",
"name": "John Doe",
"nickname": "Johnny",
"headerfield": "url address",
"phonenum": "1234567890"
}
}