layout | title | permalink |
---|---|---|
docs |
Using the API |
/docs/api/ |
Every Flarum forum exposes a publicly-accessible JSON API that can read and write forum data. It conforms to the JSON-API 1.0 specification.
The API uses token-based authentication. Some endpoints do not require authentication. You can retrieve a token from the /api/token
endpoint:
POST /api/token HTTP/1.1
{
"identification": "Toby",
"password": "pass7word"
}
HTTP/1.1 200 OK
{
"token": "YACub2KLfe8mfmHPcUKtt6t2SMJOGPXnZbqhc3nX",
"userId": "1"
}
You can then pass the token in an Authorization header in subsequent requests:
GET /api/forum HTTP/1.1
Authorization: Token YACub2KLfe8mfmHPcUKtt6t2SMJOGPXnZbqhc3nX
GET /api/forum
- get information about the forum, including groups and tagsPATCH /api/forum
- update forum config
GET /api/discussions
- get all discussions (sort is-time
by default)filter[q]
- filter by username/gambits
POST /api/discussions
- create a new discussionGET /api/discussions/:id
- get a discussion by IDPATCH /api/discussions/:id
- update a discussionDELETE /api/discussions/:id
- delete a discussion
GET /api/posts
- get all postsfilter[discussion]
- filter by discussion IDfilter[user]
- filter by user IDfilter[number]
- filter by number (position within the discussion)filter[type]
- filter by post type
POST /api/posts
- create a new postGET /api/posts/:id
- get a post by IDPATCH /api/posts/:id
- update a postDELETE /api/posts/:id
- delete a post
GET /api/users
- get all usersfilter[q]
- filter by username/gambits
POST /api/users
- register a new userGET /api/users/:idOrUsername
- get a user by ID or usernamePATCH /api/users/:id
- update a userDELETE /api/users/:id
- delete a userPOST /api/users/:id/avatar
- upload a user avatarDELETE /api/users/:id/avatar
- delete a user avatar
GET /api/groups
- get all groupsPOST /api/groups
- create a new groupPATCH /api/groups/:id
- update a groupDELETE /api/groups/:id
- delete a group
GET /api/notifications
- get all notificationsPATCH /api/notifications/:id
- mark a notification as read
GET /api/tags
- get all tagsPOST /api/tags
- create a new tagPATCH /api/tags/:id
- update a tagDELETE /api/tags/:id
- delete a tagPOST /api/tags/order
- re-order tags