This documentation provides information on how to use the URL shortener API. The API allows you to shorten URLs, generate API tokens, and retrieve analytics for your shortened links.
Shortens a URL using the API.
POST /api/shorten Headers: Authorization: {api_token} Body: { "url": "http://s1d.me/", "length": 6, "allow_numbers": true, "allow_uppercase": true, "allow_lowercase": true, "expiry_time": "2023-12-31 23:59:59" } Response: { "short_code": "abc123" }
curl -X POST https://s1d.me/api/shorten \ -H "Authorization: your_api_token" \ -H "Content-Type: application/json" \ -d '{ "url": "http://s1d.me/", "length": 6, "allow_numbers": true, "allow_uppercase": true, "allow_lowercase": true, "expiry_time": "2023-12-31 23:59:59" }'
import requests url = "https://s1d.me/api/shorten" headers = { "Authorization": "your_api_token", "Content-Type": "application/json" } data = { "url": "http://s1d.me/", "length": 6, "allow_numbers": True, "allow_uppercase": True, "allow_lowercase": True, "expiry_time": "2023-12-31 23:59:59" } response = requests.post(url, headers=headers, json=data) print(response.json())
Gets analytics for the API token.
GET /api/analytics Headers: Authorization: {api_token} Response: { "link_count": 10, "click_count": 50, "links": [ { "short_code": "abc123", "original_url": "http://s1d.me/", "click_count": 5, "expiry_time": "2023-12-31 23:59:59" }, ... ] }
curl -X GET https://s1d.me/api/analytics \ -H "Authorization: your_api_token"
import requests url = "https://s1d.me/api/analytics" headers = { "Authorization": "your_api_token" } response = requests.get(url, headers=headers) print(response.json())
Resets the API token for the authenticated user.
POST /api/reset_api_token Headers: Authorization: {api_token} Response: { "token": "new_api_token" }
curl -X POST https://s1d.me/api/reset_api_token \ -H "Authorization: your_api_token"
import requests url = "https://s1d.me/api/reset_api_token" headers = { "Authorization": "your_api_token" } response = requests.post(url, headers=headers) print(response.json())
Gets analytics for a specific shortened link.
GET /api/link_analytics/{short_code} Headers: Authorization: {api_token} Response: { "short_code": "abc123", "original_url": "http://s1d.me/", "click_count": 5, "expiry_time": "2023-12-31 23:59:59" }
curl -X GET https://s1d.me/api/link_analytics/abc123 \ -H "Authorization: your_api_token"
import requests url = "https://s1d.me/api/link_analytics/abc123" headers = { "Authorization": "your_api_token" } response = requests.get(url, headers=headers) print(response.json())
The API endpoints have rate limits to prevent abuse:
Most API endpoints require authentication. You need to include the API token in the Authorization header of your requests.
Authorization: {api_token}
The API returns standard HTTP status codes to indicate the success or failure of the request. Here are some common status codes:
curl -X POST https://s1d.me/api/shorten \ -H "Authorization: your_api_token" \ -H "Content-Type: application/json" \ -d '{ "url": "http://s1d.me/", "length": 6, "allow_numbers": true, "allow_uppercase": true, "allow_lowercase": true, "expiry_time": "2023-12-31 23:59:59" }'
import requests url = "https://s1d.me/api/shorten" headers = { "Authorization": "your_api_token", "Content-Type": "application/json" } data = { "url": "http://s1d.me/", "length": 6, "allow_numbers": True, "allow_uppercase": True, "allow_lowercase": True, "expiry_time": "2023-12-31 23:59:59" } response = requests.post(url, headers=headers, json=data) print(response.json())
curl -X GET https://s1d.me/api/analytics \ -H "Authorization: your_api_token"
import requests url = "https://s1d.me/api/analytics" headers = { "Authorization": "your_api_token" } response = requests.get(url, headers=headers) print(response.json())
curl -X POST https://s1d.me/api/reset_api_token \ -H "Authorization: your_api_token"
import requests url = "https://s1d.me/api/reset_api_token" headers = { "Authorization": "your_api_token" } response = requests.post(url, headers=headers) print(response.json())
curl -X GET https://s1d.me/api/link_analytics/abc123 \ -H "Authorization: your_api_token"
import requests
url = "https://s1d.me/api/link_analytics/abc123"
headers = {
"Authorization": "your_api_token"
}
response = requests.get(url, headers=headers)
print(response.json())
If you have any questions or need further assistance, please contact me at sarthaksidhantisopolice@gmail.com