ashtonav/opencaptcha

GitHub: ashtonav/opencaptcha

一个开源免费的公共 API 服务,通过简单的 REST 调用将文本转换为带扭曲效果、支持多语言和自定义配色的 CAPTCHA 验证码图像。

Stars: 17 | Forks: 3

# OpenCaptcha ![banner](https://static.pigsec.cn/wp-content/uploads/repos/2026/05/4b91e9afc6022226.png) [![codecov](https://codecov.io/gh/ashtonav/opencaptcha/graph/badge.svg?token=ZD0L2LC2U0)](https://codecov.io/gh/ashtonav/opencaptcha) [![可维护性评分](https://sonarcloud.io/api/project_badges/measure?project=ashtonav_opencaptcha&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=ashtonav_opencaptcha) [![.NET](https://static.pigsec.cn/wp-content/uploads/repos/2026/05/abd31afe05022227.svg)](https://github.com/ashtonav/opencaptcha/actions/workflows/dotnet.yml) [![license](https://img.shields.io/github/license/ashtonav/opencaptcha.svg)](LICENSE) OpenCaptcha 是一个开源、免费的公共 API,用于从文本生成 CAPTCHA 图像。 OpenCaptcha 提供: - 免费的公共 API,访问地址为 [api.opencaptcha.io](https://api.opencaptcha.io)。 - 文档位于 [opencaptcha.io](https://opencaptcha.io)。 - 自托管支持(请参阅[安装说明](#installation)部分)。 ## 使用说明 ### 示例 1:生成的 CAPTCHA 图像会随机扭曲。 ![banner](https://static.pigsec.cn/wp-content/uploads/repos/2026/05/561111e715022227.gif) [![试一试](https://img.shields.io/badge/-Try%20it%20out-brightgreen?style=for-the-badge)](https://hoppscotch.io/?method=POST&url=https%3A%2F%2Fapi.opencaptcha.io%2Fcaptcha&bodyMode=raw&contentType=application%2Fjson&rawParams=%7B%22text%22%3A%22captcha%22%7D) ``` curl -X 'POST' \ 'https://api.opencaptcha.io/captcha' \ -H 'Content-Type: application/json' \ -d '{ "text": "captcha" }' ``` ### 示例 2:生成的 CAPTCHA 图像可以包含多种语言的文本。 ![banner](https://static.pigsec.cn/wp-content/uploads/repos/2026/05/aebdc47048022228.gif) [![试一试](https://img.shields.io/badge/-Try%20it%20out-brightgreen?style=for-the-badge)](https://hoppscotch.io/?method=POST&url=https%3A%2F%2Fapi.opencaptcha.io%2Fcaptcha&bodyMode=raw&contentType=application%2Fjson&rawParams=%7B%22text%22%3A%22%E6%99%AE%E9%80%9A%22%7D) ``` curl -X 'POST' \ 'https://api.opencaptcha.io/captcha' \ -H 'Content-Type: application/json' \ -d '{ "text": "普通" }' ``` ### 示例 3:生成的 CAPTCHA 图像可以有不同的颜色。 ![banner](https://static.pigsec.cn/wp-content/uploads/repos/2026/05/aaa214c7ab022229.gif) [![试一试](https://img.shields.io/badge/-Try%20it%20out-brightgreen?style=for-the-badge)](https://hoppscotch.io/?method=POST&url=https%3A%2F%2Fapi.opencaptcha.io%2Fcaptcha&bodyMode=raw&contentType=application%2Fjson&rawParams=%7B%22text%22%3A%22hello%20world%22%2C%22theme%22%3A%7B%22primaryColor%22%3A%22%23ADD8E6%22%2C%22secondaryColor%22%3A%22%23FFFFFF%22%7D%7D) ``` curl -X 'POST' \ 'https://api.opencaptcha.io/captcha' \ -H 'Content-Type: application/json' \ -d '{ "text": "hello world", "theme": { "primaryColor": "#ADD8E6", "secondaryColor": "#FFFFFF" } }' ``` ## 安装说明 ### 方式 1:使用 Docker(推荐用于自托管) #### 前置条件 - Docker。 #### 运行方法 1. 在项目的根文件夹中,运行以下命令: docker build -t opencaptcha -f ./src/Captcha.WebApi/Dockerfile . docker run -it -p 5280:8080 opencaptcha 2. 可以通过 [http://localhost:5280](http://localhost:5280) 访问该 API。 ### 方式 2:使用 Visual Studio(推荐用于开发目的) #### 前置条件 - Visual Studio 2026。 - 通过 Visual Studio Installer 安装了 ASP.NET 和 Web 开发组件。 - .NET 10 SDK。 #### 运行方法 1. 在 Visual Studio 2026 中打开解决方案。 2. 构建并启动 Captcha.WebApi 项目。 3. 可以通过 [https://localhost:5280](https://localhost:5280) 访问该 API。 #### 测试方法 1. 在 Visual Studio 2026 中打开解决方案。 2. 在测试资源管理器中运行测试。 ## 致谢 本项目有很大一部分,尤其是 CAPTCHA 生成代码,灵感来源于 [BrainJar](https://web.archive.org/web/20241116012010/https://www.codeproject.com/Articles/5947/CAPTCHA-Image) 最初于 2004 年 2 月 9 日发布的工作。 ## 贡献 接受 Pull requests。 ## 许可证 [MIT](https://choosealicense.com/licenses/mit/)。
标签:API, CAPTCHA, REST API, Syscall, Web开发, 免费API, 公共API, 反机器人, 后端服务, 图像处理, 图像生成, 多人体追踪, 多语言, 安全防护, 开源, 扭曲变形, 文字转图片, 网络安全, 脚本检测, 自托管, 请求拦截, 防爬虫, 隐私保护, 验证码, 验证码生成器