Welcome, Developers.
Welcome to Project OSUS, an open-source URL shortener built using Flask, Python, and MongoDB. This project is part of Hacktoberfest 2024, encouraging contributions from developers and non-developers alike. The goal is to provide a simple, easy-to-use URL shortening service while fostering collaboration in the open-source community.
Postman Collection
To get started with Project OSUS, use the following Postman collection to test and understand the API:
- Visit the Project OSUS Postman Collection to access all API endpoints.
- Test the API endpoints.
- Contribute to the collection by forking and making changes.
Note: Forking in Postman creates a new instance of an element that you can modify without changing the original. You can fork collections, environments, and flows to make contributions even without Editor access.
Endpoints
| Endpoint | Description |
|---|---|
/shorten |
Shortens a long URL by providing a custom keyword, expiration date, and time. |
/analytics |
Retrieves analytics data for shortened URLs, including click statistics and referrer information. |
This endpoint allows you to shorten a long URL by providing a custom keyword, expiration date, and time.
Endpoint Details
| Endpoint | /shorten |
| Method | POST |
| URL | https://project-osus.vercel.app/shorten |
Request Body
- longUrl (string): The long URL to be shortened.
- keyword (string, optional): Custom keyword for the short URL.
- expirationDate (string, optional): Date for the short URL expiration.
- expirationTime (string, optional): Time for the short URL expiration.
- expirationPeriod (string, optional): Period (AM/PM) for the expiration time.
- timezone (string, optional): Timezone for the expiration date and time.
Sample Request
{
"longUrl": "https://www.google.com/",
"keyword": "your-key-word",
"expirationDate": "YYYY-MM-DD",
"expirationTime": "HH:MM",
"expirationPeriod": "PM",
"timezone": "UTC"
}
Response
Status Code: 200
JSON:
{
"shortUrl": "https://project-osus.vercel.app/your-key-word"
}
Status Code: 400
If the keyword already exists:
JSON:
{
"error": "The keyword already exists. Please choose a different one."
}
This endpoint allows you to submit analytics data.
Endpoint Details
| Endpoint | /analytics |
| Method | POST |
| URL | https://project-osus.vercel.app/analytics |
Request Body
- keyword (text, required): The keyword for which the analytics data is being submitted.
Example Request
{
"keyword": "LarryPage"
}
Response
Status Code: 200
If the keyword is present:
JSON:
{
"clicks": 0,
"expiration": "2050-07-05T23:59:00"
}
Status Code: 404
If the keyword is not present:
{
"error": "Keyword not found."
}