REST API¶
Quick reference¶
| Resource | Operation | Description |
|---|---|---|
| GET /static/bootstrap/(path:filename) | ||
| ShortUrl | POST /v1/generate_short_url | Generate short url. |
| GET /v1/list_urls | Get info about user`s short urls. | |
| GET /v1/url_info/(slug) | Get info about short url. | |
| GET /(slug) | Get original url. |
API Details¶
-
POST/v1/generate_short_url¶ Generate short url for original url given by user using custom slug if specified.
Request Headers: - Accept – application/json
Request JSON Object: - original_url (string) – url of website to be shorten
- slug (string) – (optional) slug to use in shortened url
Response Headers: - Content-Type – application/json
Response JSON Object: - short_url (string) – short url which redirects to original url
Status Codes: - 201 Created – ShortUrl created
- 500 Internal Server Error – slug already exists in db
-
GET/v1/list_urls¶ Return details about short urls generated by current user.
Response Headers: - Content-Type – application/json
Response JSON Object: - URLs (list[url_info]) – list of dicts with details about short url
Status Codes: - 200 OK – query to database succeeded
-
GET/static/bootstrap/(path: filename)¶ Function used internally to send static files from the static folder to the browser.
New in version 0.5.
-
GET/v1/url_info/(slug)¶ Return details about short url by slug.
Parameters: - slug – short string which was created during generation short url
Response Headers: - Content-Type – application/json
Response JSON Object: - original_url (string) – url for which short url was created
- created (date) – time when short url was generated.
- access_counter (int) – number of times short url has been accessed
Status Codes: - 200 OK – ShortUrl for given slug found
- 404 Not Found – ShortUrl for given slug not found
- 500 Internal Server Error – multiple ShortUrls for given slug found
-
GET/(slug)¶ Redirect to original url for given slug.
Parameters: - slug – short string which was created during generation short url
Status Codes: - 302 Found – ShortUrl for given slug found and redirect is performed
- 404 Not Found – ShortUrl for given slug not found
- 500 Internal Server Error – multiple ShortUrls for given slug found