{"id":15641343,"url":"https://github.com/robvanderleek/capture-website-api","last_synced_at":"2025-04-05T14:04:14.764Z","repository":{"id":36789664,"uuid":"225168696","full_name":"robvanderleek/capture-website-api","owner":"robvanderleek","description":"Capture screenshots of websites as a (host it yourself) API 📸","archived":false,"fork":false,"pushed_at":"2025-03-27T12:53:47.000Z","size":1879,"stargazers_count":86,"open_issues_count":9,"forks_count":41,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-29T13:05:11.007Z","etag":null,"topics":["docker","heroku","rest-api","screenshot","website-screenshot-capturer"],"latest_commit_sha":null,"homepage":"https://capture-website-api.vercel.app","language":"JavaScript","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/robvanderleek.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},"funding":{"github":"robvanderleek"}},"created_at":"2019-12-01T13:46:55.000Z","updated_at":"2025-03-07T12:16:10.000Z","dependencies_parsed_at":"2023-01-17T05:01:04.200Z","dependency_job_id":"07b10e96-75ea-4393-a995-79b2b83767ee","html_url":"https://github.com/robvanderleek/capture-website-api","commit_stats":{"total_commits":203,"total_committers":8,"mean_commits":25.375,"dds":0.6748768472906403,"last_synced_commit":"c4cd9ce80902b6b0704d307ee78d34b62252596a"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robvanderleek%2Fcapture-website-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robvanderleek%2Fcapture-website-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robvanderleek%2Fcapture-website-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robvanderleek%2Fcapture-website-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robvanderleek","download_url":"https://codeload.github.com/robvanderleek/capture-website-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247345850,"owners_count":20924102,"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":["docker","heroku","rest-api","screenshot","website-screenshot-capturer"],"created_at":"2024-10-03T11:42:15.598Z","updated_at":"2025-04-05T14:04:14.758Z","avatar_url":"https://github.com/robvanderleek.png","language":"JavaScript","readme":"# Capture website API\n\n\u003cdiv align=\"center\"\u003e\n\n[![Logo](static/logo_256x256.png)](https://www.freepik.com/icon/capture_6276243)\n\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n![Screenshot](static/screenshot.png)\n\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[![Build Status](https://github.com/robvanderleek/capture-website-api/workflows/main/badge.svg)](https://github.com/robvanderleek/capture-website-api/actions)\n[![CodeLimit](https://github.com/robvanderleek/capture-website-api/blob/_codelimit_reports/add-codelimit/badge.svg)](https://github.com/robvanderleek/capture-website-api/blob/_codelimit_reports/add-codelimit/codelimit.md)\n[![Dependabot](https://badgen.net/badge/Dependabot/enabled/green?icon=dependabot)](https://dependabot.com/)\n[![DockerHub image pulls](https://img.shields.io/docker/pulls/robvanderleek/capture-website-api)](https://hub.docker.com/r/robvanderleek/capture-website-api/)\n![Vercel](https://vercelbadge.vercel.app/api/robvanderleek/capture-website-api)\n\n\u003c/div\u003e\n\nCapture screenshots of websites as a (host it yourself) API. This project is a\nwrapper around this library: https://github.com/sindresorhus/capture-website\n\n# Installation\n\n## Docker\n\n### Run pre-built container from Docker Hub\n\n1. Pull the image:\n```\ndocker pull robvanderleek/capture-website-api\n```\n\n2. Start the container:\n```\ndocker run -it -p 8080:8080 robvanderleek/capture-website-api\n```\n\n3. Make screenshot test request:\n```\ncurl 'localhost:8080/capture?url=https://news.ycombinator.com/' -o screenshot.png\n``` \n\n### Build the docker image and run it\n\n1. Clone the repo:\n```shell\ngit clone git@github.com:robvanderleek/capture-website-api.git\n```\n\n2. Go to the `standalone` directory:\n```shell\ncd capture-website-api/standalone\n```\n\n3. Build the image:\n```shell\ndocker build -t cwa .\n```\n\n4. Start the container: \n```shell\ndocker run -it -p 8080:8080 cwa\n```\n\n5. Do screenshot test request:\n```shell\ncurl 'localhost:8080/capture?url=https://www.youtube.com' -o screenshot.png\n```\n\n## Yarn\n\nRun in a terminal:\n\n1. Clone the repo:\n```shell\ngit clone git@github.com:robvanderleek/capture-website-api.git\n```\n\n2. Go to the `standalone` directory:\n```shell\ncd capture-website-api/standalone\n```\n\n3. Install dependencies:\n```shell\nyarn\n```\n\n4. Start the server:\n```shell\nyarn start\n```\n\n5. Do screenshot test request:\n```shell\ncurl 'localhost:8080/capture?url=https://www.reddit.com' -o screenshot.png\n```\n\n## Vercel\n\nDeploy and run on Vercel:\n\n1. Clone the repo:\n```\ngit clone git@github.com:robvanderleek/capture-website-api.git \u0026\u0026 cd capture-website-api/serverless\n```\n\n2. Deploy to Vercel:\n```shell\nvercel deploy\n```\n\n3. Get site URL:\n```shell\nvercel ls \n```\n\n7. Make screenshot test request:\n```\ncurl \"${SITE_URL}/api/capture?url=https://www.linkedin.com\" -o screenshot.png\n```\n\n# Usage\n\nCall the `/capture` endpoint and pass the site URL using the query parameters `url`:\n```shell\ncurl 'https://capture-website-api.vercel.app/api/capture?url=http://gmail.com' -o screenshot.png\n```\nSimple as that.\n\n# Configuration\n\n## Application options\n\nApplication configuration options can be set as environment veriables or in \na `.env` file in the root folder. There's an example `.env` file in the codebase: [`.env.example`](https://github.com/robvanderleek/capture-website-api/blob/main/.env.example)\n\nSupported options are:\n\n| Name | Descrition | Default |\n|---|---|---|\n| TIMEOUT | Timeout in seconds for loading a web page | 20 |\n| CONCURRENCY | Number of captures that run in parallel, more memory allows more captures to run in parallel | 2 |\n| MAX_QUEUE_LENGTH | Requests that can't be handled directly are queued until the queue is full | 6 |\n| SHOW_RESULTS | Enable web endpoint to show latest capture | false |\n| SECRET | Secret string to prevent undesired usage on public endpoints | \"\" |\n\n## Capturing options\n\nMost of the configuration options from the wrapped `capture-website` library are supported using query parameters. \nFor example, to capture a site with a 650x350 viewport, no default background and animations disabled use:\n```\ncurl 'https://capture-website-api.vercel.app/api/capture?url=http://amazon.com\u0026width=650\u0026height=350\u0026scaleFactor=1\u0026defaultBackground=false\u0026disableAnimations=true\u0026wait_before_screenshot_ms=300' -o screenshot.png\n```\n\nSee https://github.com/sindresorhus/capture-website for a full list of options.\n\n### Capture Delay\n\nYou may require to wait for async requests or animations to finish before capturing the screenshot. There are two ways of doing this, both specified in the query parameters:\n\n1. `wait_before_screenshot_ms` (in ms, defaults to `300`) will wait before capturing a screenshot.\n2. For standalone: `capture-website` library's [`delay`](https://github.com/sindresorhus/capture-website#delay) (in seconds)\n\n## Use plain Puppeteer \n\nSometimes the `capture-website` library has problems capturing sites. You can\ntry to capture these sites with plain Puppeteer by supplying the query\nparameter `plainPuppeteer=true`\n\n## Environment variables\n\nThis app looks at two environment variables:\n\n* `SHOW_RESULTS`: if `true` the latest capture result can be viewed in the\n  browser by browsing the base url  \n* `SECRET`: when set all capture requests need to contain a query parameter\n  `secret` whose value matches the value of this environment variable\n\n# Development\n\nTo run the serverless version locally, execute `vercel dev` in the root folder\nof the repository.\n\n# Contributing\n\nIf you have suggestions for improvements, or want to report a bug, [open an\nissue](https://github.com/robvanderleek/capture-website-api/issues)!\n\n# License\n\n[ISC](LICENSE) © 2019 Rob van der Leek \u003crobvanderleek@gmail.com\u003e\n(https://twitter.com/robvanderleek)\n","funding_links":["https://github.com/sponsors/robvanderleek"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobvanderleek%2Fcapture-website-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobvanderleek%2Fcapture-website-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobvanderleek%2Fcapture-website-api/lists"}