{"id":14483144,"url":"https://github.com/CERN/captcha-api","last_synced_at":"2025-08-30T03:33:03.804Z","repository":{"id":38315486,"uuid":"294117835","full_name":"CERN/captcha-api","owner":"CERN","description":"Open Source Captcha API","archived":false,"fork":false,"pushed_at":"2024-06-24T07:43:24.000Z","size":35,"stargazers_count":47,"open_issues_count":0,"forks_count":14,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-06-27T20:39:56.975Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CERN.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2020-09-09T13:14:25.000Z","updated_at":"2025-02-01T16:33:20.000Z","dependencies_parsed_at":"2024-12-27T07:00:23.799Z","dependency_job_id":null,"html_url":"https://github.com/CERN/captcha-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/CERN/captcha-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CERN%2Fcaptcha-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CERN%2Fcaptcha-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CERN%2Fcaptcha-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CERN%2Fcaptcha-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CERN","download_url":"https://codeload.github.com/CERN/captcha-api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CERN%2Fcaptcha-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272800743,"owners_count":24995138,"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-08-30T02:00:09.474Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","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":[],"created_at":"2024-09-03T00:01:33.093Z","updated_at":"2025-08-30T03:33:03.459Z","avatar_url":"https://github.com/CERN.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# Captcha API\n\nThis project contains a simple Captcha API that returns an encoded image containing\nletters a-Z and numbers 1-9 via a GET endpoint. The POST endpoint can be used to validate the\ncaptcha.\n\nA Dockerfile is provided for containerization.\n\n## Running with Docker\n\nBuild the Docker image\n\n```\ndocker build . -t captcha-api\n```\n\nRun the Docker image\n\n```\ndocker run -d --name captcha -p 8080:8080 -e CAPTCHA_API_CONFIG=captcha.cfg captcha-api\n```\n\nNavigate to `http://localhost:8080/swagger-ui`\n\n## Running locally\n\nThis guide is written for users of Debian-based systems, the package names might differ on other operating systems such as CentOS.\n\nFor usage on Windows, please use the WSL2 distribution in order to build and run the application.\n\n### Installing the required libraries\n\nUnfortunately we need some binary dependencies, since PIL and the audio CAPTCHA generation require them. Run the following command:\n\n```bash\nsudo apt-get install libtiff5-dev libopenjp2-7-dev zlib1g-dev \\\n    libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python3-tk \\\n    libharfbuzz-dev libfribidi-dev libxcb1-dev ffmpeg espeak python3-dev\n```\n\n### Installing and running the application\n\nRun\n\n```bash\npip install -e '.[dev]'\n```\n\nin order to install all the required dependencies for development.\n\nTo start the server locally, you need to create a `captcha.cfg` file. Just `cp captcha_api/captcha.cfg.example captcha_api/captcha.cfg` to get started.\n\nRunning the server is done by running:\n\n```\nflask run\n```\n\nor\n\n```\ngunicorn --bind 0.0.0.0:5000 wsgi:app\n```\n\n## Audio CAPTCHA\n\nFor accessibility reasons, one might one to listen to the CAPTCHA message. In order to do that, you can point to the following endpoint:\n\n```\n/api/v1.0/captcha/audio/$CAPTCHA_ID\n```\n\nThe file returned is in the `mp3` format and can be easily loaded into an HTML form as such:\n\n```html\n\u003cdiv\u003e\n  \u003caudio controls=\"controls\" className=\"audio-element\"\u003e\n    \u003csource src=\"http://localhost:8080/api/v1.0/captcha/audio/$CAPTCHA_ID\" } /\u003e\n  \u003c/audio\u003e\n\u003c/div\u003e\n```\n\n\n## Running migrations\n\nMake sure you installed the dependencies using `pip install -e .`.\n\nAfterwards, run `flask db upgrade` to bring your DB to the latest level. By default it will use a `test.db` SQLite file in the `captcha_api` folder.\n\n\n## Embedded captcha.js\n\nThe Captcha API includes a static Javascript file to help with simple web form integrations. To use or test this script:\n\n1. Configure the `captchaApiUrl` variable in `captcha_api/static/captcha.js`.\n2. Run the Captcha API.\n3. Include the script in your page, and the HTML element `\u003cdiv id=\"cern-captcha\"\u003e\u003c/div\u003e` in your form (see the example in `captcha_api/static/demo.html`).\n4. When processing your form, validate `captchaAnswer` and `captchaId` with the `POST` endpoint of the Captcha API.\n\nExample for the production Captcha API:\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n    \u003cscript type=\"module\" src=\"https://captcha.web.cern.ch/static/captcha.js\"\u003e\u003c/script\u003e\n\u003cbody\u003e\n    \u003cform\u003e\n        \u003cdiv id=\"cern-captcha\"\u003e\u003c/div\u003e\n        \u003cinput type=\"submit\" value=\"Submit\"\u003e\n    \u003c/form\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCERN%2Fcaptcha-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FCERN%2Fcaptcha-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCERN%2Fcaptcha-api/lists"}