0.1.0 Split repos, Add API docs, new env vars

This commit is contained in:
Daniel Mason 2021-12-25 15:38:42 +13:00
parent cf4498e8bc
commit 306bab997b
55 changed files with 19278 additions and 11 deletions

View file

@ -0,0 +1,126 @@
# Authentication
## v1/login
> To obtain a JWT token (Replace default credentials):
```shell
curl "https://goscrobble.com/api/v1/login" \
-H "Content-Type: application/json" \
--data '{"username":"abc","password":"def"}'
```
> Response:
```json
{
"token": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhZG1pbiI6ZmFsc2UsImVtYWlsIjoidGVzdEB0ZXN0LmNvbSIsImV4cCI6MTY0MTAwMjUxOSwiaWF0IjoxNjQwMzk3NzE5LCJtb2QiOnRydWUsInJlZnJlc2hfZXhwIjoxNjQxMDAyNTE5LCJyZWZyZXNoX3Rva2VuIjoiYWJjZGVmZ2hqaWtsbW5vcHF3ZXJ0dXZ3eHl6Iiwic3ViIjoiNDE4ZmRkZmItOGIxYi01MWFiLTliZHMtNGZnMDhjYTYzY2ZmIiwidXNlcm5hbWUiOiJ0ZXN0In0.fuPXjQ7IzNyttgIKpdS4-KBQ-QeHTl-BfgYkSnMCmpVrBunzMrSwr1RzxI7Xg2WWF-FHtW3Bnv9RpSqLDN4F2g"
}
```
This endpoint is used to authenticate and retrieve a JWT token.
### HTTP Request
`POST https://goscrobble.com/api/v1/login`
### Query Parameters
Parameter | Required | Description
--------- | ------- | -----------
username | true | Account username
password | true | Account password
## v1/register
> Create a new account (Replace default credentials):
```shell
curl "https://goscrobble.com/api/v1/register" \
-H "Content-Type: application/json" \
--data '{"email": "test@test.com", "username":"abc","password":"def"}'
```
> Response:
```json
{
"message": "User created succesfully. You may now login"
}
```
If the server has REGISTRATION_ENABLED=true set, this endpoint will allow you to create a new account. Password must be at least 8 characters long.
### HTTP Request
`POST https://goscrobble.com/api/v1/register`
### Query Parameters
Parameter | Required | Description
--------- | ------- | -----------
email | true | Account email
username | true | Account username
password | true | Account password
## v1/sendreset
> Trigger a password reset email:
```shell
curl "https://goscrobble.com/api/v1/sendreset" \
-H "Content-Type: application/json" \
--data '{"email":"test@test.com"}'
```
> Response:
```json
{
"message": "Password reset email sent"
}
```
This endpoint triggers a password reset email to be sent to the email on an account.
### HTTP Request
`POST https://goscrobble.com/api/v1/sendreset`
### Query Parameters
Parameter | Required | Description
--------- | ------- | -----------
email | true | Account username
## v1/resetpassword
> Trigger a password reset email:
```shell
curl "https://goscrobble.com/api/v1/resetpassword" \
-H "Content-Type: application/json" \
--data '{"token":"abcdefghijklmnopqrstuvwxyz", "password": "Hunter1"}'
```
> Response:
```json
{
"message": "Password updated successfully!"
}
```
This endpoint confirms a password reset with a valid hash from the reset email. You must call v1/sendreset first and obtain the hash.
### HTTP Request
`POST https://goscrobble.com/api/v1/resetpassword`
### Query Parameters
Parameter | Required | Description
--------- | ------- | -----------
token | true | Reset token from the password reset email
password | true | New account password

View file

@ -0,0 +1,22 @@
# Errors
<aside class="notice">
This error section is stored in a separate file in <code>includes/_errors.md</code>. Slate allows you to optionally separate out your docs into many files...just save them to the <code>includes</code> folder and add them to the top of your <code>index.md</code>'s frontmatter. Files are included in the order listed.
</aside>
The Kittn API uses the following error codes:
Error Code | Meaning
---------- | -------
400 | Bad Request -- Your request is invalid.
401 | Unauthorized -- Your API key is wrong.
403 | Forbidden -- The kitten requested is hidden for administrators only.
404 | Not Found -- The specified kitten could not be found.
405 | Method Not Allowed -- You tried to access a kitten with an invalid method.
406 | Not Acceptable -- You requested a format that isn't json.
410 | Gone -- The kitten requested has been removed from our servers.
418 | I'm a teapot.
429 | Too Many Requests -- You're requesting too many kittens! Slow down!
500 | Internal Server Error -- We had a problem with our server. Try again later.
503 | Service Unavailable -- We're temporarily offline for maintenance. Please try again later.

View file

@ -0,0 +1,5 @@
# Introduction
Welcome to the GoScrobble API documentation.
The majority of these API endpoints are public with reasonable rate limits.

View file

@ -0,0 +1,22 @@
# Server Info
## v1/serverinfo
> Check server version and registration status:
```shell
curl "https://goscrobble.com/api/v1/serverinfo"
```
> Response:
```json
{
"version":"0.1.1",
"registration_enabled":"1"
}
```
This endpoint is used to get server API version and registration status.
### HTTP Request
`GET https://goscrobble.com/api/v1/serverstatus`