Skip to content

Instantly share code, notes, and snippets.

@Gaeta
Last active October 3, 2021 20:03
Show Gist options
  • Save Gaeta/787f34904c919394bca1b88f4ca25fae to your computer and use it in GitHub Desktop.
Save Gaeta/787f34904c919394bca1b88f4ca25fae to your computer and use it in GitHub Desktop.
How v3 API request responces work for grace. As of10-03-2021

How v3 API request responses work.

This will show you what each error code means and how we setup the syntax for responses.

x normally means that it might have extra text on it.

10XX : Main App Errors

'1000' (unknown_error): 'App Server Error, please contact the admin' # Global Error
'1001' (headers_missing): 'Missing Headers'
'1002' (params_missing): 'Missing Parameters'
'1003' (): 'Invalid offset or limit'
'1004' (): 'Invalid Locale'
'1005' (rate_limit_hit): 'You exceeded the limit of requests per minute, Please try again after sometime.'
'1006' (unstable_call): 'The API Path is unstable (beta/testing)' # The API path being called is currently in beta/testing and is unreliable, watch what you do!

11XX : Http Errors

'1101' (no_auth): 'Unauthorized'
'1102' (auth_not_allowed): 'Not authorized to access'
'1103' (): 'Unprocessable Entity'
'1104' (auth_failed): 'Authentication Failed'
'1105' (not_found): 'Not Found' # Normally 404 errors for unknown paths
'1106' (not_valid_client): 'Invalid Client' # Requires you to be the website etc. If client keeps doing this we will ban the ip/client.

12XX : Auth Errors

Most of these errors will redirect to login w/ Discord

'1201' (session_expired): 'Your session is expired, please login again' # Token expired
'1202' (discord_session_invalid): 'Your session is invalid' # Discord token verification error
'1203' (session_invalid_decode): 'Your session is invalid' # Error encountered while decoding
'1204' (session_invalid_token): 'Your sessions token is invalid' # Invalid token
'1205' (session_unauth): 'You are Unauthorized, Please login' # You are Unauthorized, Please login.
'1206' (session_auth_issue): 'Authentication Error, User Not found' # Authentication Error, User Not found

13XX Session Errors

'1301' (): 'Invalid Credentials'
'1302' (user_banned): 'User Banned' # The staff at Grace have banned your discord account from Grace.

data_found : 'Data found'

no_data_found:          'No data found'
not_found:              'Not found'
x_not_found:            '%{name} not found!'
update_successfully:    'Updated successfully'
x_update_successfully:  '%{name} updated successfully'
created_successfully:   'Created successfully'
x_created_successfully: '%{name} created successfully'
deleted_successfully:   'Deleted successfully'
x_deleted_successfully: '%{name} deleted successfully'
request_submitted:      'Order %{code} Code has been Submitted successfully'
orders_not_found:       'No orders yet'

Syntax for responses sent back

The main response structure have 4 keys which are

1) error_code code to indicate if there was an error
2) Success always returning true or false if the response is success will returning true otherwise will get false
3) Message it’s better to return the response message from back-end
4) error_find to let the client/user understand the error code if they dont have a doc with error_code meanings. 
4) data which is the main key and will have the data that should be displayed. Errors may use this to output some info if needed.

Syntax Examples

How we format syntaxes that are sent back to the client.

Success : True

The action was successful.

  {
    "success": true,
    "message": "User logged in successfully",
    "data": {/*...*/}
  }

Success : False (w/ Error Code to relate to.)

The action was not successful and an error code was given.

{
    "success": false,
    "message": "Missing Parameters",
    "error_code": 1002,
    "error_find": null,
    "data": {}
}

Success : False (w/o Error Code)

Normally means a big issue happened and contact staff.

{
    "success": false,
    "message": "...",
    "error_code": null,
    "error_find": null,
    "data": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment