Design and Deployment of TinyURL
Deep-diving into the design and deployment of the URL shortening service.
System APIs
To expose the functionality of our service, we can use REST APIs for the following features:
- Shortening a URL
- Redirecting a short URL
- Deleting a short URL
Shortening a URL
We can create new short URLs with the following definition:
shortURL(api_dev_key, original_url, custom_alias=None, expiry_date=None)
The above API call has the following parameters:
api_dev_key
(string): A registered user account’s unique identifier; it’s useful in tracking a user’s activity and allows the system to control the associated services accordingly.original_url
(string): The original URL that we need to be shortened.custom_alias
(string): Optional key that the user defines as a customer short URL.expiry_date
(string): Optional expiration date for the shortened URL.
A successful insertion returns the user the shortened URL. Otherwise, the system returns an appropriate error code to the user.
Redirecting a short URL
To redirect a short URL, the REST API’s definition will be:
redirectURL(api_dev_key, url_key)
With the following parameters:
api_dev_key
(string): A registered user account’s unique identifier.url_key
(string): The shortened URL against which we need to fetch the long URL from the database.
A successful redirection lands the user to the original URL associated with the url_key
. ...
Create a free account to access the full course.
By signing up, you agree to Educative's Terms of Service and Privacy Policy