-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0223ce0
commit 87c34ad
Showing
3 changed files
with
142 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
## API Endpoints | ||
|
||
### `GET /api/v1/healthz` | ||
Description: The health endpoint for the API used for health checks. | ||
|
||
Response: | ||
`200 OK`: The server is healthy and ready to respond to requests. | ||
|
||
### `POST /api/v1/data/shorten` | ||
Description: Used to turn a long URL into a short URL. | ||
|
||
Request: | ||
``` | ||
{ | ||
"long_url":"https://www.google.com/my/long/path" | ||
} | ||
``` | ||
|
||
Response: | ||
``` | ||
{ | ||
"short_url":"<short url hash>" | ||
} | ||
``` | ||
|
||
Parameters: | ||
- Headers | ||
- `Authorization: Bearer <token>` | ||
|
||
### `GET /api/v1/{shortUrl}` | ||
Description: Redirects an unauthenticated client from the short URL to the long URL. | ||
|
||
Parameters: | ||
- Path | ||
- `shortUrl` a reference to a short URL in that is stored in the database. | ||
|
||
- `DELTE /api/v1/{shortUrl}` | ||
|
||
Description: An authenticated endpoint that will delete a short URL a user owns. | ||
|
||
Parameters: | ||
- Path | ||
- `shortUrl` a reference to a short URL that is stored in the database. | ||
- Headers | ||
- `Authorization: Bearer <token>` | ||
|
||
### `PUT /api/v1/{shortUrl}` | ||
Description: Allows for the updating of a long URL based on a short URL | ||
|
||
Parameters: | ||
- Path | ||
- `shortUrl` a reference to a short URL in the database | ||
- Headers | ||
- `Authorization: Bearer <token>` | ||
|
||
### `POST /api/v1/users` | ||
Description: Creates a user to be used by a client | ||
|
||
Request: | ||
``` | ||
{ | ||
"email":"<client email>", | ||
"password:"<client password>" | ||
} | ||
``` | ||
|
||
Response: | ||
``` | ||
{ | ||
"id":"<client id>", | ||
"email":"<client email>" | ||
} | ||
``` | ||
|
||
### `PUT /api/v1/users` | ||
Description: Allows a user to update their email or password | ||
|
||
Request: | ||
``` | ||
{ | ||
"email":"<client email>", | ||
"password:"<client password>" | ||
} | ||
``` | ||
|
||
Parameters: | ||
- Headers | ||
- `Authorization: Bearer <token>` | ||
|
||
Response: | ||
``` | ||
{ | ||
"id":"<client id>", | ||
"email":"<client email>" | ||
} | ||
``` | ||
|
||
### `POST /api/v1/login` | ||
Description: Allows a client to login by returning a access and refresh token | ||
|
||
Request: | ||
``` | ||
{ | ||
"email":"<client email>", | ||
"password:"<client password>" | ||
} | ||
``` | ||
|
||
Response: | ||
``` | ||
{ | ||
"id": "<client id>" | ||
"email":"<client email>" | ||
"token":"<client access token>" | ||
"refresh_token":"<client refresh token>" | ||
} | ||
``` | ||
### `POST /api/v1/refresh` | ||
Description: Uses a refresh token to refresh an access token | ||
|
||
Parameters: | ||
- Headers | ||
- `Authorization: Bearer <refresh token>` | ||
|
||
Response: | ||
``` | ||
{ | ||
"token":"<client access token>" | ||
} | ||
``` |