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[edit]

Checks whether an account name is available for registration

URL[edit]

/api/users/checkname

Method[edit]

POST

URL Params[edit]

None

Data Params[edit]

name=[string]

Possible responses[edit]

  • { 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[edit]

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

Check password[edit]

Checks whether a password for an account is correct

URL[edit]

/api/users/checkpass

Method[edit]

POST

URL Params[edit]

None

Data Params[edit]

name=[string]
password=[string]

Possible responses[edit]

  • { 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[edit]

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

Change password[edit]

Changes an account password

URL[edit]

/api/users/changepass

Method[edit]

POST

URL Params[edit]

None

Data Params[edit]

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

Possible responses[edit]

  • { 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[edit]

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

Register an account[edit]

Create a new account on the AAGRINDER server

URL[edit]

/api/users/register

Method[edit]

POST

URL Params[edit]

None

Data Params[edit]

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

Possible responses[edit]

  • { 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[edit]

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