{"id":24203458,"url":"https://github.com/desk888/url-shortener-fastapi","last_synced_at":"2025-07-23T09:07:16.472Z","repository":{"id":250069441,"uuid":"833383684","full_name":"Desk888/url-shortener-fastapi","owner":"Desk888","description":"URLs Shortener API built with Python using the FastAPI framework and Postgres database for URLs storage. ","archived":false,"fork":false,"pushed_at":"2024-08-10T12:50:33.000Z","size":15032,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-03T11:44:31.368Z","etag":null,"topics":["fastapi","python","urlshortener"],"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/Desk888.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}},"created_at":"2024-07-25T00:08:20.000Z","updated_at":"2024-12-12T12:17:48.000Z","dependencies_parsed_at":"2025-01-13T22:49:24.186Z","dependency_job_id":null,"html_url":"https://github.com/Desk888/url-shortener-fastapi","commit_stats":null,"previous_names":["desk888/url-shortener-api","desk888/url-shortener-fastapi"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Desk888/url-shortener-fastapi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Desk888%2Furl-shortener-fastapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Desk888%2Furl-shortener-fastapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Desk888%2Furl-shortener-fastapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Desk888%2Furl-shortener-fastapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Desk888","download_url":"https://codeload.github.com/Desk888/url-shortener-fastapi/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Desk888%2Furl-shortener-fastapi/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266649176,"owners_count":23962181,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"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":["fastapi","python","urlshortener"],"created_at":"2025-01-13T22:35:22.535Z","updated_at":"2025-07-23T09:07:16.452Z","avatar_url":"https://github.com/Desk888.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# URL Shortener API\n\nWelcome to the URL Shortener API. This API allows you to shorten URLs, redirect to the original URLs, manage shortened URLs, and delete them.\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [API Endpoints](#api-endpoints)\n  - [Create a Short URL](#create-a-short-url)\n  - [Redirect to Original URL](#redirect-to-original-url)\n  - [Get URL Info](#get-url-info)\n  - [Delete Short URL](#delete-short-url)\n- [Database](#database)\n- [Configuration](#configuration)\n- [License](#license)\n\n## Installation\n\n1. Clone the repository:\n    ```sh\n    git clone https://github.com/yourusername/url-shortener-api.git\n    cd url-shortener-api\n    ```\n\n2. Create a virtual environment and activate it:\n    ```sh\n    python -m venv env\n    source env/bin/activate  # On Windows use `env\\Scripts\\activate`\n    ```\n\n3. Install the dependencies:\n    ```sh\n    pip install -r requirements.txt\n    ```\n\n4. Set up a PostgreSQL database name \"url-shortener\"\n\n## Usage\n\nTo run the application, use the following command:\n```sh\nuvicorn main:app --reload\n```\n\nThis will start the FastAPI server on `http://127.0.0.1:8000`.\n\n## API Endpoints\n\n### Create a Short URL\n\n- **Endpoint:** `/url`\n- **Method:** `POST`\n- **Request Body:**\n    ```json\n    {\n        \"target_url\": \"https://example.com\"\n    }\n    ```\n- **Response:**\n    ```json\n    {\n        \"url\": \"http://127.0.0.1:8000/\u003cshort_url_key\u003e\",\n        \"admin_url\": \"http://127.0.0.1:8000/admin/\u003csecret_key\u003e\"\n    }\n    ```\n- **Description:** Creates a shortened URL and returns the shortened URL and an admin URL for managing the short URL.\n\n### Redirect to Original URL\n\n- **Endpoint:** `/{url_key}`\n- **Method:** `GET`\n- **Response:** Redirects to the original URL.\n- **Description:** Redirects to the original URL using the shortened URL key.\n\n### Get URL Info\n\n- **Endpoint:** `/admin/{secret_key}`\n- **Method:** `GET`\n- **Response:**\n    ```json\n    {\n        \"target_url\": \"https://example.com\",\n        \"clicks\": 10\n    }\n    ```\n- **Description:** Retrieves information about the shortened URL, including the original URL and the number of clicks.\n\n### Delete Short URL\n\n- **Endpoint:** `/admin/{secret_key}`\n- **Method:** `DELETE`\n- **Response:**\n    ```json\n    {\n        \"detail\": \"URL deleted successfully\"\n    }\n    ```\n- **Description:** Deletes the shortened URL using the admin secret key.\n\n## Database\n\nThe database is set up using SQLAlchemy. The database URL should be configured in the `config.py` file and `.env` (You need to create this one). Here's a quick overview of the database setup:\n\n1. **Database Configuration:**\n    - Configure your database URL in the `config.py` file.\n    - Configure your database URL in the `.env` file.\n\n2. **Models:**\n    - The database model is already defined in the `models.py` file.\n\n3. **CRUD Operations:**\n    - Implement the necessary CRUD operations in the `crud.py` file.\n  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdesk888%2Furl-shortener-fastapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdesk888%2Furl-shortener-fastapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdesk888%2Furl-shortener-fastapi/lists"}