Skip to content

Endpoints

Victor edited this page Apr 29, 2019 · 5 revisions

Post

/post - POST

Create a new post

Returns

  • 201: Succesfully created post
  • 400: If your input was invalid in some way
  • 401: If not logged in
  • 409: If the title is already in use or the index already exists
  • 500: Server Error

/post/:hash - GET

Gets information about a post with given hash

Returns

  • 200: Success
  • 404: Hash not found

/post/:hash - PUT

Edits a post

Returns

  • 200: Success
  • 204: Nothing to change
  • 401: Not logged in
  • 404: Hash not found
  • 500: Server error

/post/:hash/content - GET

Gets a posts content

Optional headers

  • X-Post-Version: If this version matches latest you will not receive any HTML.

Returns

  • 200: Success
  • 404: Hash not found
  • 410: Post has been deleted
  • 500: Server error

/post/:hash/editcontent - GET

Gets a posts edits

Optional headers

  • X-Exclude-Last-Edit: If true server will not send you the latest edit.

Returns

  • 200: Success
  • 500: Server error

/post/:hash/squash - PUT

Squashes given edits together.

Returns

  • 204: Success
  • 400: If any user input is wrong
  • 401: Unauthorized
  • 500: Server error

/post/:hash/forcesave - PUT

Forcefully saves a given post.

Returns

  • 200: Success
  • 401: Unauthorized
  • 500: Server error

/post/:hash/:action - PUT

Where :action is one of: hide, favorite and wip. Performs the action on the given post

Returns

  • 200: Success
  • 400: If any user input is wrong
  • 401: Not logged in
  • 403: Unauthorized
  • 500: Server error

Posts

/posts/topic/:topichash - GET

Gets list of posts for specified topic

Returns

  • 200: Success
  • 400: User error
  • 500: Server error

/posts/unverified - GET

Gets all unverified posts

Returns

  • 200: Success

/posts/wip - GET

Gets all work in progress posts

Returns

  • 200: Success

Topics

/topics - GET

gets all topics

Optional headers

  • X-Topic-Version: If it matches the servers version you will receive a 304.

Returns

  • 200: Success
  • 304: If X-Topic-Version matches
  • 500: Server error

/topics - POST

Create a new topic

Returns

  • 201: Created
  • 400: User error
  • 401: Unauthorized
  • 409: topic already exists
  • 500: Server error

User endpoints

/login - POST

Logs user in.

Returns

  • 200: Logged in (or Incorrect pass)
  • 400: User error
  • 500: Server error

/createaccount - POST

Creates a user

Returns

  • 201: Created
  • 400: User error
  • 500: Server error

/verifytoken - POST

Verifies the jwt.

Returns

  • 200: Valid
  • 400: Invalid

/users/:page?rowsPerPage=n - GET

Gets all users paginated by :page and rowsPerPage

Returns

  • 200: Success
  • 403: Forbidden

/user/verifymail?hash=i&accId=j - GET

Verifies an email with secret hash i and account id j

Returns

  • 200: Success
  • 500: Server error

/user/forgotpasswordmail - POST

Sends a forgot password email to given mail.

Returns

  • 200: Success
  • 400: User error

/user/forgotpassword - POST

Resets the password and verifies with given UUID

Returns

  • 200: Success
  • 400: Invalid input

/user/changeavatar - POST

Changes a users avatar

Returns

  • 200: Success
  • 400: Invalid image
  • 401: Invalid token

/profile/:userId - GET

Gets profile picture by userid

Returns

  • 200: Success
  • 400: Userid is NaN
  • 404: User does not exist

/dashboard/:type - GET

Gets list of posts for dashboard of type myposts or favorites

Returns

  • 200: Success
  • 401: Invalid token

/search?query=query - GET

Searches for posts given a query

Returns

  • 200: Success
  • 400: Query is less than 3 chars
  • 500: Server error

Documentation Template

//TODO: add example request and response

# Category
## /endpoint - METHOD
Explanation

### Returns
* 200: Success