AAGRINDER REST api

From AAGRINDER wiki
Jump to navigationJump to search

The AAGRINDER server exposes a simple REST api which is used for account operations. The code for this api can be found at https://gitlab.com/MRAAGH/aagrinder/blob/master/server/api/User.js

This page describes all the REST api endpoints. Not to be confused with socket.io api endpoints.

Check name

Checks whether an account name is available for registration

URL

/api/users/checkname

Method

POST

URL Params

None

Data Params

name=[string]

Possible responses

  • { message: 'Registration is not possible on this server. You should try to log in directly.', success: false, insecure: true }
  • { message: 'Missing form data', success: false}
  • { message: 'Username invalid ^[A-Za-z]([A-Za-z0-9 ]{0,10}[A-Za-z0-9])?$', success: false }
  • { message: 'Server error', success: false }
  • { message: 'Username taken', success: false, color: existingUser[0].color }
  • { message: 'OK', success: true }

Sample call

curl https://aagrinder.xyz/api/users/checkname --data "name=original"

Check password

Checks whether a password for an account is correct

URL

/api/users/checkpass

Method

POST

URL Params

None

Data Params

name=[string]
password=[string]

Possible responses

  • { message: 'This server does not use passwords.', success: false, insecure: true }
  • { message: 'Missing form data', success: false}
  • { message: 'Username invalid ^[A-Za-z]([A-Za-z0-9 ]{0,10}[A-Za-z0-9])?$', success: false }
  • { message: 'Password invalid ^.+$', success: false }
  • { message: 'Server error', success: false }
  • { message: 'Wrong password', success: false }
  • { message: 'User does not exist', success: false }
  • { message: 'OK', success: true }

Sample call

curl https://aagrinder.xyz/api/users/checkpass --data "name=original" --data "password=hihi"

Change password

Changes an account password

URL

/api/users/changepass

Method

POST

URL Params

None

Data Params

name=[string]
oldpassword=[string]
newpassword=[string]

Possible responses

  • { message: 'This server does not use passwords.', success: false, insecure: true }
  • { message: 'Missing form data', success: false}
  • { message: 'Username invalid ^[A-Za-z]([A-Za-z0-9 ]{0,10}[A-Za-z0-9])?$', success: false }
  • { message: 'Password invalid ^.+$', success: false }
  • { message: 'Server error', success: false }
  • { message: 'Wrong password', success: false }
  • { message: 'User does not exist', success: false }
  • { message: 'Password changed.', success: true }

Sample call

curl https://aagrinder.xyz/api/users/changepass --data "name=original" --data "oldpassword=hihi" --data "newpassword=hehe"

Register an account

Create a new account on the AAGRINDER server

URL

/api/users/register

Method

POST

URL Params

None

Data Params

name=[string]
password=[string]
color=[string]

Possible responses

  • { message: 'Missing form data', success: false }
  • { message: 'Username invalid ^[A-Za-z]([A-Za-z0-9 ]{0,10}[A-Za-z0-9])?$', success: false }
  • { message: 'Password invalid ^.+$', success: false }
  • { message: 'Color invalid ^[0-9a-f]{6}$', success: false }
  • { message: 'Color too dark', success: false }
  • { message: 'Server error', success: false }
  • { message: 'Username taken', success: false }
  • { message: 'Server error', success: false }
  • { message: 'Server error', success: false }
  • { message: 'Server error', success: false }
  • { message: 'User created', success: true }
  • { message: 'User created. Hi there, soru O.O', success: true }

Sample call

curl https://aagrinder.xyz/api/users/register --data "name=original" --data "password=hihi" --data "color=fdbcb4"