{"id":28801381,"url":"https://github.com/tegaraditya/youtube-api-proxy-rust","last_synced_at":"2026-04-28T17:03:50.008Z","repository":{"id":298710616,"uuid":"1000832376","full_name":"TegarAditya/youtube-api-proxy-rust","owner":"TegarAditya","description":"YouTube API Cache Proxy built on Rust","archived":false,"fork":false,"pushed_at":"2025-06-12T13:38:22.000Z","size":27,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-12T13:43:35.531Z","etag":null,"topics":["axum","rust","sqlite","youtube-api","youtube-api-v3"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/TegarAditya.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}},"created_at":"2025-06-12T11:45:48.000Z","updated_at":"2025-06-12T13:38:25.000Z","dependencies_parsed_at":"2025-06-12T13:44:30.979Z","dependency_job_id":"dc7b1b8e-0951-4190-9222-2eb44f749985","html_url":"https://github.com/TegarAditya/youtube-api-proxy-rust","commit_stats":null,"previous_names":["tegaraditya/youtube-api-proxy-rust"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/TegarAditya/youtube-api-proxy-rust","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TegarAditya%2Fyoutube-api-proxy-rust","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TegarAditya%2Fyoutube-api-proxy-rust/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TegarAditya%2Fyoutube-api-proxy-rust/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TegarAditya%2Fyoutube-api-proxy-rust/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TegarAditya","download_url":"https://codeload.github.com/TegarAditya/youtube-api-proxy-rust/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TegarAditya%2Fyoutube-api-proxy-rust/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260507132,"owners_count":23019464,"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","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":["axum","rust","sqlite","youtube-api","youtube-api-v3"],"created_at":"2025-06-18T07:09:19.973Z","updated_at":"2026-04-28T17:03:49.995Z","avatar_url":"https://github.com/TegarAditya.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rust YouTube Content Cache Server\n\nThis project is a high-performance backend server built with Rust and the Axum web framework. It fetches YouTube video data, caches it in a local SQLite database to reduce API calls, and exposes a simple REST API.\n\nThis project is a rewrite and translation from an original TypeScript/Bun backend [youtube-api-proxy](https://github.com/TegarAditya/youtube-api-proxy), demonstrating a transition to Rust for improved performance and safety.\n\n## Features\n\n- **Caching Layer**: Uses SQLite (`rusqlite`) to cache responses from the YouTube API, with a configurable time-to-live (TTL).\n- **External API Integration**: Fetches data from the YouTube Data API v3 using `reqwest`.\n- **Asynchronous**: Built on Tokio and Axum for non-blocking, concurrent request handling.\n- **Configuration Management**: Uses a `.env` file for secure management of API keys and settings.\n- **Health Checks**: Includes a `/healthz` endpoint to monitor service and database status.\n\n## Getting Started\n\n### Prerequisites\n\n- [Rust](https://www.rust-lang.org/tools/install) (latest stable version)\n- A YouTube Data API v3 key from the [Google Cloud Console](https://console.cloud.google.com/).\n\n### Installation \u0026 Setup\n\n1.  **Clone the repository:**\n\n    ```bash\n    git clone https://github.com/TegarAditya/youtube-api-proxy-rust\n    cd youtube-api-proxy-rust\n    ```\n\n2.  **Create a `.env` file:**\n    Create a file named `.env` in the root of the project and add your configuration variables.\n\n    ```env\n    # .env\n    YOUTUBE_API_KEY=\"YOUR_API_KEY_HERE\"\n    SECRET_KEY=\"your-super-secret-key-for-clearing-cache\"\n    CACHE_TTL_SECONDS=86400 # Cache duration in seconds (default: 24 hours)\n    PORT=3000 # Define port\n    ENABLE_FUNCTION_TIMER=true # Set to false if you want to disable function timer\n    SQL_STUDIO_BIND_IP=0.0.0.0 # IP address to bind SQL Studio\n    SQL_STUDIO_BIND_PORT=3030  # Port for SQL Studio\n    ```\n\n3.  **Run the application:**\n    Use `cargo run` to compile and start the server. The first build will take a moment to compile dependencies.\n\n    ```bash\n    cargo run\n    ```\n\n    The server will start on `http://127.0.0.1:3000`.\n\n## API Endpoints\n\n### 1. Get Content by ID\n\nFetches YouTube video data. It will first check the cache. If a valid cache entry is found, it's returned immediately. Otherwise, it fetches from the YouTube API and caches the new result.\n\n- **Endpoint**: `GET /api/video/{id}`\n- **`{id}`**: The YouTube video ID (e.g., `dQw4w9WgXcQ`).\n- **Success Response (200 OK)**:\n  ```json\n    {\n        \"etag\": \"o4b5ZGzkKNVLEI60AlNbD7tvbPg\",\n        \"items\": [\n            {\n                \"etag\": \"I6s3gc8P1aaOjn1nXKmxD-Z6Pn8\",\n                \"id\": \"dQw4w9WgXcQ\",\n                \"kind\": \"youtube#video\",\n                \"snippet\": {\n                    \"categoryId\": \"10\",\n                    \"channelId\": \"UCuAXFkgsw1L7xaCfnd5JJOw\",\n                    \"channelTitle\": \"Rick Astley\",\n                    \"description\": \"The official video for “Never Gonna Give You Up” by Rick Astley...\",\n                    \"liveBroadcastContent\": \"none\",\n                    \"localized\": {\n                        \"description\": \"The official video for “Never Gonna Give You Up” by Rick Astley...\"\n                    },\n                    \"publishedAt\": \"2009-10-25T06:57:33Z\",\n                    \"thumbnails\": {\n                        \"default\": {\n                            \"height\": 90,\n                            \"url\": \"https://i.ytimg.com/vi/dQw4w9WgXcQ/default.jpg\",\n                            \"width\": 120\n                        },\n                        \"high\": {\n                            \"height\": 360,\n                            \"url\": \"https://i.ytimg.com/vi/dQw4w9WgXcQ/hqdefault.jpg\",\n                            \"width\": 480\n                        },\n                        \"maxres\": {\n                            \"height\": 720,\n                            \"url\": \"https://i.ytimg.com/vi/dQw4w9WgXcQ/maxresdefault.jpg\",\n                            \"width\": 1280\n                        },\n                        \"medium\": {\n                            \"height\": 180,\n                            \"url\": \"https://i.ytimg.com/vi/dQw4w9WgXcQ/mqdefault.jpg\",\n                            \"width\": 320\n                        },\n                        \"standard\": {\n                            \"height\": 480,\n                            \"url\": \"https://i.ytimg.com/vi/dQw4w9WgXcQ/sddefault.jpg\",\n                            \"width\": 640\n                        }\n                    },\n                    \"title\": \"Rick Astley - Never Gonna Give You Up (Official Video) (4K Remaster)\"\n                }\n            }\n        ],\n        \"kind\": \"youtube#videoListResponse\",\n        \"pageInfo\": {\n            \"resultsPerPage\": 1,\n            \"totalResults\": 1\n        }\n    }\n    ```\n  Example using curl:\n\n```bash\ncurl http://localhost:3000/api/video/dQw4w9WgXcQ\n```\n\n### 2. Clear Cache\n\nDeletes all entries from the cache database. This is a protected endpoint that requires the SECRET_KEY from your .env file.\n\nEndpoint: `DELETE /api/video/clear`\n\nQuery Parameter: `key=\u003cyour_secret_key\u003e`\n\nSuccess Response (200 OK):\n\n```\nCache cleared successfully\n```\n\nExample using curl:\n\n```bash\ncurl -X DELETE \"http://localhost:3000/api/video/clear?key=your-super-secret-key-for-clearing-cache\"\n```\n\n### 3. Health Check\n\nChecks the status of the service, primarily its ability to connect to the database.\n\nEndpoint: `GET /healthz`\n\nSuccess Response (200 OK):\n\n```\nOK\n```\n\nExample using curl:\n\n```bash\ncurl http://localhost:3000/healthz\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftegaraditya%2Fyoutube-api-proxy-rust","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftegaraditya%2Fyoutube-api-proxy-rust","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftegaraditya%2Fyoutube-api-proxy-rust/lists"}