Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hayd1n/yescaptcha-rs
YesCaptcha SDK for Rust
https://github.com/hayd1n/yescaptcha-rs
recaptcha rust yescaptcha
Last synced: 1 day ago
JSON representation
YesCaptcha SDK for Rust
- Host: GitHub
- URL: https://github.com/hayd1n/yescaptcha-rs
- Owner: hayd1n
- License: mit
- Created: 2024-08-16T03:54:31.000Z (3 months ago)
- Default Branch: master
- Last Pushed: 2024-08-16T04:12:14.000Z (3 months ago)
- Last Synced: 2024-10-31T12:09:29.047Z (8 days ago)
- Topics: recaptcha, rust, yescaptcha
- Language: Rust
- Homepage: https://crates.io/crates/yescaptcha
- Size: 19.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# YesCaptcha Rust SDK
> 🚧 Only some types of tasks have been implemented so far, any [PR](https://github.com/hayd1n/yescaptcha-rs/pulls) is welcome!
## Get Started
```bash
cargo add yescaptcha
```## Examples
[All examples](./examples/)
### ReCaptcha V2
```rust
use std::time::Duration;
use tokio::time::sleep;
use yescaptcha::{
task::recaptcha_v2::{ReCaptchaV2Config, TaskType},
Client, TaskResult,
};#[tokio::main]
async fn main() {
let client_key = "CLIENT_KEY";// Create a new YesCaptcha client
let client = Client::new(client_key);// Create a new ReCaptchaV2 task
let task_config = ReCaptchaV2Config {
website_url: "https://www.google.com/recaptcha/api2/demo".to_string(),
website_key: "6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-".to_string(),
task_type: TaskType::NoCaptchaTaskProxyless,
is_invisible: false,
};// Send the task to the YesCaptcha API
let task = client.create_task(task_config).await.unwrap();// Wait for the task to be completed
loop {
// Get the task result
let result = client.get_task_result(&task).await.unwrap();match result {
TaskResult::Processing => {
println!("Task is not completed yet");
}
TaskResult::Ready(solution) => {
println!("Solution: {:#?}", solution);
// Exit the loop once the task is completed
break;
}
}// Wait for 5 seconds before checking again
sleep(Duration::from_secs(5)).await;
}
}
```