2023-08-15 17:43:53 +00:00
|
|
|
# API
|
|
|
|
All API endpoints are accessible with this base URL: `https://api.nerdcult.net/`.
|
|
|
|
Some API endpoints require an Authorization HTTP header.
|
|
|
|
The token for this can be aquired using the `/account/authenticate` endpoint.
|
|
|
|
|
|
|
|
## Endpoints
|
|
|
|
### `/account/register` - POST
|
|
|
|
Requests a new nerdcult account.
|
|
|
|
This sends a verification E-Mail which contains a link to the veriication frontend with an verification token as url parameter.
|
|
|
|
This verification link will time out after 10 minutes.
|
|
|
|
|
|
|
|
#### HTTP Headers
|
|
|
|
| Header | Content |
|
|
|
|
|--------------|--------------------|
|
|
|
|
| Content-Type | `application/json` |
|
|
|
|
|
|
|
|
#### Content - JSON
|
|
|
|
| Field | Description |
|
|
|
|
|----------|----------------------------------------|
|
|
|
|
| username | The accounts username / userid. |
|
|
|
|
| password | The password used for authentication. |
|
|
|
|
| email | The email address used for validation. |
|
|
|
|
|
|
|
|
#### Responses
|
|
|
|
##### 200 - Success
|
|
|
|
The verification request was sent.
|
2023-08-16 11:23:01 +00:00
|
|
|
##### 400 - Error: Bad Request
|
2023-08-15 17:43:53 +00:00
|
|
|
The request was malformed.
|
2023-08-16 11:23:01 +00:00
|
|
|
##### 403 - Error: Forbidden
|
2023-08-15 17:43:53 +00:00
|
|
|
The password is not matching the requirements.
|
2023-08-16 11:23:01 +00:00
|
|
|
##### 409 - Error: Conflict
|
2023-08-15 17:43:53 +00:00
|
|
|
The requested username or email is already taken.
|
|
|
|
|
|
|
|
__Content - JSON:__
|
|
|
|
| Field | Description |
|
|
|
|
|----------|----------------------------------------------------------------------|
|
|
|
|
| conflict | Can be `username` or `email`, depending on what caused the conflict. |
|
|
|
|
|
2023-08-16 11:23:01 +00:00
|
|
|
##### 422 - Error: Unprocessable Entity
|
2023-08-15 17:43:53 +00:00
|
|
|
Malformed email address.
|
|
|
|
|
|
|
|
### `/account/verify` - POST
|
|
|
|
Verifies a requested account.
|
|
|
|
|
|
|
|
#### HTTP Headers
|
|
|
|
| Header | Content |
|
|
|
|
|--------------|--------------------|
|
|
|
|
| Content-Type | `application/json` |
|
|
|
|
|
|
|
|
#### Content - JSON
|
|
|
|
| Field | Description |
|
|
|
|
|-------|--------------------------------------------------------------------------------|
|
|
|
|
| token | The verification token you received via an email after requesting the account. |
|
|
|
|
|
|
|
|
#### Responses
|
|
|
|
##### 200 - Success
|
|
|
|
The account was verified. You can login now.
|
2023-08-16 11:23:01 +00:00
|
|
|
##### 400 - Error: Bad Request
|
2023-08-15 17:43:53 +00:00
|
|
|
The request was malformed.
|
2023-08-16 11:23:01 +00:00
|
|
|
##### 403 - Error: Forbidden
|
2023-08-15 17:43:53 +00:00
|
|
|
The provided token is unknown.
|
|
|
|
|
|
|
|
### `/account/authenticate` - POST
|
|
|
|
Generates an authentication token for an account.
|
|
|
|
|
|
|
|
#### HTTP Headers
|
|
|
|
| Header | Content |
|
|
|
|
|--------------|--------------------|
|
|
|
|
| Content-Type | `application/json` |
|
|
|
|
|
|
|
|
#### Content - JSON
|
|
|
|
| Field | Description |
|
|
|
|
|----------|---------------------------------|
|
|
|
|
| username | The accounts username / userid. |
|
|
|
|
| password | The accounts password. |
|
|
|
|
|
|
|
|
#### Responses
|
|
|
|
##### 200 - Success
|
|
|
|
The authentication was successfull.
|
|
|
|
|
|
|
|
__Content - JSON:__
|
|
|
|
| Field | Description |
|
|
|
|
|-------|------------------------|
|
|
|
|
| token | A unique access token. |
|
|
|
|
|
2023-08-16 11:23:01 +00:00
|
|
|
##### 400 - Error: Bad Request
|
2023-08-15 17:43:53 +00:00
|
|
|
The request was malformed.
|
2023-08-16 11:23:01 +00:00
|
|
|
##### 403 - Error: Forbidden
|
2023-08-15 17:43:53 +00:00
|
|
|
The provided password was wrong.
|
2023-08-16 11:23:01 +00:00
|
|
|
##### 404 - Error: Not Found
|
2023-08-15 17:43:53 +00:00
|
|
|
The provided username was not found.
|
|
|
|
|
|
|
|
### `/account/delete` - DELETE
|
|
|
|
Deletes the account.
|
|
|
|
|
|
|
|
#### HTTP Headers
|
|
|
|
| Header | Content |
|
|
|
|
|---------------|--------------------|
|
|
|
|
| Authorization | `Bearer {token}` |
|
|
|
|
|
|
|
|
#### Responses
|
|
|
|
##### 200 - Success
|
|
|
|
The account was deleted.
|
2023-08-16 11:23:01 +00:00
|
|
|
##### 403 - Error: Forbidden
|
2023-08-15 17:43:53 +00:00
|
|
|
The provided token doesn't allow you to perform this operation.
|