{"id":35828224,"url":"https://github.com/daniel-e/rust-captcha","last_synced_at":"2026-01-07T21:04:22.446Z","repository":{"id":42230312,"uuid":"51270760","full_name":"daniel-e/rust-captcha","owner":"daniel-e","description":"RESTful CAPTCHA service written in Rust.","archived":false,"fork":false,"pushed_at":"2022-04-09T20:10:11.000Z","size":7610,"stargazers_count":39,"open_issues_count":0,"forks_count":8,"subscribers_count":7,"default_branch":"master","last_synced_at":"2023-10-29T18:43:16.375Z","etag":null,"topics":["captcha","rest-api","restful","restful-api","rust","service","webservice"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/daniel-e.png","metadata":{"files":{"readme":"README.md","changelog":"Changelog","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-07T23:03:26.000Z","updated_at":"2023-10-11T08:38:41.000Z","dependencies_parsed_at":"2022-09-19T04:11:30.272Z","dependency_job_id":null,"html_url":"https://github.com/daniel-e/rust-captcha","commit_stats":null,"previous_names":[],"tags_count":1,"template":null,"template_full_name":null,"purl":"pkg:github/daniel-e/rust-captcha","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daniel-e%2Frust-captcha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daniel-e%2Frust-captcha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daniel-e%2Frust-captcha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daniel-e%2Frust-captcha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/daniel-e","download_url":"https://codeload.github.com/daniel-e/rust-captcha/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daniel-e%2Frust-captcha/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28237780,"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":"2026-01-07T02:00:05.975Z","response_time":58,"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":["captcha","rest-api","restful","restful-api","rust","service","webservice"],"created_at":"2026-01-07T21:02:36.632Z","updated_at":"2026-01-07T21:04:22.438Z","avatar_url":"https://github.com/daniel-e.png","language":"Rust","readme":"[![Build Status](https://travis-ci.org/daniel-e/rust-captcha.svg?branch=master)](https://travis-ci.org/daniel-e/rust-captcha)\n\n# Rust CAPTCHA Service\n\nHere you find a CAPTCHA service written in Rust. The service generates CAPTCHAs\nwhich can be embedded into web pages to protect them from being\naccessed by bots. The difficulty of the CAPTCHAs, the expiration time and\nthe maximum number of attempts to solve a CAPTCHA can be easily\nconfigured for each created CAPTCHA.\n\nThe CAPTCHAs look similar to the following ones:\n\n![captcha](doc/captcha3.png) \u0026nbsp; ![captcha](doc/captcha2.png) \u0026nbsp; ![captcha](doc/captcha_mila_medium.png)\n\n**The CAPTCHA service uses Rocket in version 0.4.5 which is a web framework to create fast and secure web applications. As Rocket requires Rust nightly, you also need Rust nightly to compile the CAPTCHA service.**\n\n## Running\n\nThere are two ways how you can run the service.\n\n### In Docker\n\n```bash\ncd docker\nmake rebuild   # build image; needs to be executed for the first time only\nmake run\n```\n\n### From sources\n\n**Requirements**\n\nTo build from sources, you require [Rust](https://www.rust-lang.org) nightly and a running [Redis](https://redis.io/) instance.\n\n* If you're using rustup, you can switch to Rust nightly by running `rustup default nightly`. Then, compile and run the CAPTCHA service as follows:\n* If you don't have Redis already running, execute `make redis`. This command will compile and execute Redis in the `target` directory. \n\n**Build**\n\n```bash\nexport RUST_LOG=rust_captcha=info\nexport REDIS_HOST=localhost\n\ngit clone https://github.com/daniel-e/rust-captcha.git\ncd rust-captcha\ncargo run --release\n```\n\nThe service is listening on port 8080 for incoming requests.\n\n\n\n# Usage\n\nThe service provides an API to create new CAPTCHAs and to check the solution of a CAPTCHA.\n\n## Create new CAPTCHA without persisting the CAPTCHA\n\n```bash\ncurl -s -i http://localhost:8000/new/\u003cdifficulty\u003e\n```\n\n* `\u003cdifficulty\u003e`: The difficulty. Valid values are `easy`, `medium`, `hard`.\n* Optionally, you can provide a `X-Client-ID` header. This header can be used to separate different clients using the same service instance when analyzing the service's logfile.\n\n**Response**\n\nExample of a successful request:\n\n```\n{\n  \"code\": 0,\n  \"msg\": \"processed\",\n  \"result\": {\n    \"id\": \"04f498ec-ad36-42f1-a56f-3cf5b9f912b3\",\n    \"png\": \"\u003cbase64 encoded image\u003e\",\n    \"solution\": \"uS6c\"\n  }\n}\n```\n\n* `error_code`: The error code. \n  * 0 = request was processed without error\n  * 1 = internal error\n  * 2 = invalid parameters were provided\n* `error_msg`: The string representation of the error code. Can be 'processed', 'internal error' or 'invalid parameters'.\n* `id`: The id of the CAPTCHA. For CAPTCHAs that are not persisted this field can be ignored.\n* `png`: The raw PNG image data encoded as base64.\n* `solution`: The solution.\n\n## Create new CAPTCHA that is persisted\n\n```bash\ncurl -s -i -XPOST http://localhost:8000/new/\u003cdifficulty\u003e/\u003cmax_tries\u003e/\u003cttl\u003e\n```\n\n* `\u003cdifficulty\u003e`: The difficulty. Valid values are `easy`, `medium`, `hard`.\n* `\u003cmax_tries\u003e`: Maximum number of trials. Valid values are 0..999\n* `\u003cttl\u003e`: Number of seconds after which the CAPTCHA expires. Valid values are 0..999\n* Optionally, you can provide a `X-Client-ID` header. (see above)\n\n**Response**\n\nSee request above.\n\n## Check solution for a CAPTCHA\n\nSolutions can only be checked for CAPTCHAs that have been created via a POST request.\n\n```bash\ncurl -s -i -XPOST http://localhost:8000/solution/\u003cid\u003e/\u003csolution\u003e\n```\n\n* `\u003cid\u003e`: The id of the CAPTCHA.\n* `\u003csolution\u003e`: The CAPTCHA solution.\n\n**Response**\n\nExample of a response of a correct solution:\n\n```\n{\n  \"error_code\": 0,\n  \"error_msg\": \"processed\",\n  \"result\": {\n    \"solution\": \"accepted\",\n    \"trials_left\": 0\n  }\n}\n```\n\n* `error_code`: The error code. 0 = request was processed without error, 1 = internal error, 2 = invalid parameters were provided\n* `error_msg`: The string representation of the error code. Can be 'processed', 'internal error' or 'invalid parameters'.\n* `solution`: Contains the result of the check. Possible values are: 'too many trials', 'accepted' 'incorrect' or 'not found'\n* `trials_left`: Number of attempts left to solve the CAPTCHA.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaniel-e%2Frust-captcha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdaniel-e%2Frust-captcha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaniel-e%2Frust-captcha/lists"}