{"id":48668241,"url":"https://github.com/evteevakb/url-shortener","last_synced_at":"2026-04-10T11:34:40.827Z","repository":{"id":204448711,"uuid":"692102083","full_name":"evteevakb/url-shortener","owner":"evteevakb","description":"URL shortener API","archived":false,"fork":false,"pushed_at":"2026-02-07T15:36:53.000Z","size":81,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-08T00:10:25.571Z","etag":null,"topics":["alembic","docker","fastapi","postgresql","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/evteevakb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-09-15T15:03:31.000Z","updated_at":"2026-02-07T15:36:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"89564684-cb48-4d21-9a2e-5e40e5befd8e","html_url":"https://github.com/evteevakb/url-shortener","commit_stats":null,"previous_names":["evteevakb/async-python-sprint-4","evteevakb/url-shortener"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/evteevakb/url-shortener","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evteevakb%2Furl-shortener","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evteevakb%2Furl-shortener/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evteevakb%2Furl-shortener/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evteevakb%2Furl-shortener/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/evteevakb","download_url":"https://codeload.github.com/evteevakb/url-shortener/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evteevakb%2Furl-shortener/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31641372,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-10T07:40:12.752Z","status":"ssl_error","status_checked_at":"2026-04-10T07:40:11.664Z","response_time":98,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alembic","docker","fastapi","postgresql","python"],"created_at":"2026-04-10T11:34:40.058Z","updated_at":"2026-04-10T11:34:40.819Z","avatar_url":"https://github.com/evteevakb.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# URL Shortener\n\nThis service provides functionality to create shortened versions of requested URLs and offers analysis on the activity of their use. Additionally, the service includes middleware that blocks access from prohibited subnets. The server is hosted at http://localhost:8000, and the PgAdmin for the database can be accessed at http://localhost:80.\n\n\n## Installation\n\n    cp .env.example .env\n    cp .env.app.example .env.app\n    docker-compose build\n    docker-compose up -d\n\n\n## Endpoints\n\n### 1. Ping Database\n\n- **Endpoint:** `GET /ping`\n- **Description:** Pings the database to check the connection status.\n- **Raises:**\n  - `HTTPException`: If the connection to the database cannot be established.\n- **Response:**\n  - `200 OK`:\n    ```json\n    {\n      \"ping_time\": 0.123\n    }\n    ```\n    - `ping_time`: Ping time in seconds.\n\n### 2. Create Shortened URL\n\n- **Endpoint:** `POST /`\n- **Description:** Creates a short URL for the given original URL.\n- **Parameters:**\n  - `entity_in` (required): Original URL to be shortened.\n- **Raises:**\n  - `HTTPException (410)`: If the requested URL is already in the database but marked as deleted.\n- **Response:**\n  - `201 Created`:\n    ```json\n    {\n      \"id\": 123,\n      \"original_url\": \"http://example.com/original\",\n      \"shortened_url\": \"http://tinyurl.com/abc123\"\n    }\n    ```\n\n### 3. Get Original URL\n\n- **Endpoint:** `GET /{url_id}`\n- **Description:** Returns the original URL corresponding to the given `url_id`.\n- **Parameters:**\n  - `url_id` (required): Unique identifier of the requested URL.\n- **Raises:**\n  - `HTTPException (404)`: If a URL with the requested `url_id` does not exist.\n  - `HTTPException (410)`: If a URL has been marked as deleted.\n- **Response:**\n  - `307 Temporary Redirect`:\n    ```json\n    {\n      \"original_url\": \"http://example.com/original\"\n    }\n    ```\n\n### 4. Get Usage Status\n\n- **Endpoint:** `GET /{url_id}/status`\n- **Description:** Returns the usage status of the requested URL.\n- **Parameters:**\n  - `url_id` (required): Unique identifier of the requested URL.\n  - `full_info` (optional): False for obtaining the total number of requests, True for additional detailed information about each request (Default: False).\n  - `pagination_parameters` (optional): Dictionary with pagination parameters (`max_result` for the number of rows returned, `offset` for skipping rows) (Default: `{ \"max_result\": 10, \"offset\": 0 }`).\n- **Raises:**\n  - `HTTPException (404)`: If a URL with the requested `url_id` does not exist.\n- **Response:**\n  - `200 OK`:\n    - Total number of requests (if `full_info` is False):\n     ```json\n    {\n      3\n    }\n    ```\n    - List of request details (if `full_info` is True):\n    ```json\n        [\n    {\n        \"url_id\": 10,\n        \"usage_datetime\": \"2023-10-28T14:14:39.967234\",\n        \"client_host\": \"172.19.0.1\",\n        \"client_port\": 58410\n    },\n    {\n        \"url_id\": 10,\n        \"usage_datetime\": \"2023-10-28T15:01:29.835141\",\n        \"client_host\": \"172.19.0.1\",\n        \"client_port\": 58628\n    },\n    {\n        \"url_id\": 10,\n        \"usage_datetime\": \"2023-10-28T15:22:12.491003\",\n        \"client_host\": \"172.19.0.1\",\n        \"client_port\": 58726\n    }\n    ]\n    ```\n\n\n### 5. Delete Short URL\n\n- **Endpoint:** `DELETE /{url_id}`\n- **Description:** Removes a short URL by its ID. The entry in the database remains but is marked as 'deleted'.\n- **Parameters:**\n  - `url_id` (required): Unique identifier of the requested URL.\n- **Raises:**\n  - `HTTPException (404)`: If a URL with the requested `url_id` does not exist.\n  - `HTTPException (410)`: If a URL has been already marked as deleted.\n- **Response:**\n  - `200 OK`: Short URL successfully marked as deleted.\n\n\n## Tests\n\n    docker-compose exec webserver pytest\n\n\n## Migrations\n\n    docker-compose exec webserver alembic upgrade head\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevteevakb%2Furl-shortener","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevteevakb%2Furl-shortener","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevteevakb%2Furl-shortener/lists"}