### Local Development Setup Source: https://context7.com/imputnet/cobalt/llms.txt Instructions for setting up Cobalt for local development. This includes cloning the repository, installing dependencies, and starting the API server. ```bash # Prerequisites: Node.js >= 18, pnpm, git git clone https://github.com/imputnet/cobalt cd cobalt/api pnpm install # Create .env file — API_URL is the only required variable cat > .env < [!IMPORTANT] > you must include correct `Accept` and `Content-Type` headers with every `POST /` request. ``` Accept: application/json Content-Type: application/json ``` ### Request Body body type: `application/json` #### Parameters | key | type | description/value | default | |:------------------|:----------|:----------------------------------------------------------------|:-----------| | `url` | `string` | source URL | *required* | | `audioBitrate` | `string` | `320 / 256 / 128 / 96 / 64 / 8` (kbps) | `128` | | `audioFormat` | `string` | `best / mp3 / ogg / wav / opus` | `mp3` | | `downloadMode` | `string` | `auto / audio / mute` | `auto` | | `filenameStyle` | `string` | `classic / pretty / basic / nerdy` | `basic` | | `videoQuality` | `string` | `max / 4320 / 2160 / 1440 / 1080 / 720 / 480 / 360 / 240 / 144` | `1080` | | `disableMetadata` | `boolean` | title, artist, and other info will not be added to the file | `false` | | `alwaysProxy` | `boolean` | always tunnel all files, even when not necessary | `false` | | `localProcessing` | `string` | `disabled / preferred / forced` | `disabled` | | `subtitleLang` | `string` | any valid ISO 639-1 language code | *none* | ``` -------------------------------- ### Docker Compose Deployment Configuration Source: https://context7.com/imputnet/cobalt/llms.txt Configuration for deploying Cobalt using Docker Compose. This setup includes auto-updates via Watchtower and port mapping for reverse proxy access. ```yaml # docker-compose.yml services: cobalt: image: ghcr.io/imputnet/cobalt:11 init: true read_only: true restart: unless-stopped container_name: cobalt ports: - 127.0.0.1:9000:9000 # use with a reverse proxy environment: API_URL: "https://api.your-domain.com/" # Optional: cookie auth for Instagram, Reddit, Twitter, YouTube, Vimeo # COOKIE_PATH: "/cookies.json" # Optional: bot protection # TURNSTILE_SITEKEY: "1x00000000000000000000BB" # TURNSTILE_SECRET: "1x0000000000000000000000000000000AA" # JWT_SECRET: "your-random-64-char-secret-here" # Optional: API key auth # API_KEY_URL: "file:///keys.json" # API_AUTH_REQUIRED: "1" # Optional: Redis for multi-instance / shared rate limiting # API_REDIS_URL: "redis://redis:6379" # API_INSTANCE_COUNT: "4" # Optional: limits # DURATION_LIMIT: "10800" # max video duration in seconds (default: 3h) # RATELIMIT_WINDOW: "60" # rate limit window in seconds # RATELIMIT_MAX: "20" # max requests per window # volumes: # - ./cookies.json:/cookies.json:ro # - ./keys.json:/keys.json:ro labels: - com.centurylinklabs.watchtower.scope=cobalt watchtower: image: ghcr.io/containrrr/watchtower restart: unless-stopped command: --cleanup --scope cobalt --interval 900 --include-restarting volumes: - /var/run/docker.sock:/var/run/docker.sock ``` -------------------------------- ### POST / - Main API Endpoint Source: https://context7.com/imputnet/cobalt/llms.txt Initiates a download or conversion process. Accepts either an API key or a Bearer JWT token for authentication. The response typically contains a URL for the file stream. ```APIDOC ## POST / ### Description Initiates a download or conversion task for a given URL. ### Method POST ### Endpoint / ### Parameters #### Request Body - **url** (string) - Required - The URL of the media to process. - **downloadMode** (string) - Optional - Specifies the download mode (e.g., "audio"). ### Authentication Requires either an `Authorization: Api-Key ` header or an `Authorization: Bearer ` header. ### Request Example (API Key) ```bash curl -s -X POST https://your.cobalt.instance/ \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -H "Authorization: Api-Key b5c7160a-b655-4c7a-b500-de839f094550" \ -d '{"url": "https://vimeo.com/123456789", "downloadMode": "audio"}' | jq . ``` ### Request Example (Bearer JWT) ```bash curl -s -X POST https://your.cobalt.instance/ \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \ -d '{"url": "https://www.reddit.com/r/aww/comments/xyz/"}' | jq . ``` ### Response #### Success Response (200) - The response structure may vary, but typically includes information to access the processed file, potentially including a tunnel URL. #### Response Example (Illustrative) ```json { "url": "https://your.cobalt.instance/tunnel?id=...&exp=...&sig=...&sec=...&iv=..." } ``` ```