Difference between revisions of "AAGRINDER REST api"

From AAGRINDER wiki
Jump to navigationJump to search
imported>Maze
(Created page with "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/aag...")
 
imported>Maze
(aagrinder.xyz)
 
Line 2: Line 2:
  
 
This page describes all the REST api endpoints. Not to be confused with [[AAGRINDER socket.io api|socket.io api endpoints]].
 
This page describes all the REST api endpoints. Not to be confused with [[AAGRINDER socket.io api|socket.io api endpoints]].
 
The examples assume you have a local AAGRINDER server running on port 8080 (default port). See [[Setting up a server|how to set up a server]].
 
  
 
== Check name ==
 
== Check name ==
Line 26: Line 24:
 
=== Sample call ===
 
=== Sample call ===
 
<pre>
 
<pre>
curl localhost:8080/api/users/checkname --data "name=original"
+
curl https://aagrinder.xyz/api/users/checkname --data "name=original"
 
</pre>
 
</pre>
  
Line 53: Line 51:
 
=== Sample call ===
 
=== Sample call ===
 
<pre>
 
<pre>
curl localhost:8080/api/users/checkpass --data "name=original" --data "password=hihi"
+
curl https://aagrinder.xyz/api/users/checkpass --data "name=original" --data "password=hihi"
 
</pre>
 
</pre>
  
Line 81: Line 79:
 
=== Sample call ===
 
=== Sample call ===
 
<pre>
 
<pre>
curl localhost:8080/api/users/changepass --data "name=original" --data "oldpassword=hihi" --data "newpassword=hehe"
+
curl https://aagrinder.xyz/api/users/changepass --data "name=original" --data "oldpassword=hihi" --data "newpassword=hehe"
 
</pre>
 
</pre>
  
Line 113: Line 111:
 
=== Sample call ===
 
=== Sample call ===
 
<pre>
 
<pre>
curl localhost:8080/api/users/register --data "name=original" --data "password=hihi" --data "color=fdbcb4"
+
curl https://aagrinder.xyz/api/users/register --data "name=original" --data "password=hihi" --data "color=fdbcb4"
 
</pre>
 
</pre>

Latest revision as of 21:36, 31 October 2019

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"