| Crates.io | yandex-webmaster-api |
| lib.rs | yandex-webmaster-api |
| version | 1.0.4 |
| created_at | 2025-12-19 22:55:30.582783+00 |
| updated_at | 2025-12-20 09:19:49.12264+00 |
| description | Rust client for the Yandex Webmaster API |
| homepage | https://github.com/seo-meow/yandex-webmaster-api |
| repository | https://github.com/seo-meow/yandex-webmaster-api |
| max_upload_size | |
| id | 1995709 |
| size | 167,284 |
Rust client library for the Yandex Webmaster API.
reqwest with middleware supportAdd this to your Cargo.toml:
[dependencies]
yandex-webmaster-api = "1.0.0"
use yandex_webmaster_api::{YandexWebmasterClient, AddHostRequest};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Create a new client with your OAuth token
let client = YandexWebmasterClient::new("your-oauth-token".to_string()).await?;
// The user ID is automatically fetched and stored
println!("User ID: {}", client.user_id());
// List all hosts
let hosts = client.get_hosts().await?;
for host in hosts.hosts {
println!("Host: {}", host.ascii_host_url);
}
// Add a new site
let request = AddHostRequest {
host_url: "https://example.com".to_string(),
};
let new_host = client.add_host(&request).await?;
println!("Added host with ID: {}", new_host.host_id);
Ok(())
}
To use this library, you need a valid OAuth token from Yandex. You can obtain one by following the Yandex OAuth documentation.
The client automatically:
/user endpointuse yandex_webmaster_api::{YandexWebmasterClient, VerificationType};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let client = YandexWebmasterClient::new("your-token".to_string()).await?;
let host_id = "your-host-id";
// Initiate verification
let verification = client.verify_host(host_id, VerificationType::MetaTag).await?;
println!("Verification token: {:?}", verification.verification_uin);
// Check verification status
let status = client.get_verification_status(host_id).await?;
println!("Status: {:?}", status.verification_state);
Ok(())
}
use yandex_webmaster_api::{YandexWebmasterClient, QueryHistoryRequest};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let client = YandexWebmasterClient::new("your-token".to_string()).await?;
let request = QueryHistoryRequest {
date_from: Some("2024-01-01".to_string()),
date_to: Some("2024-01-31".to_string()),
};
let analytics = client.get_query_analytics("host-id", &request).await?;
for point in analytics.points {
println!("Date: {}, Clicks: {:?}", point.date, point.clicks);
}
Ok(())
}
use yandex_webmaster_api::{YandexWebmasterClient, RecrawlRequest};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let client = YandexWebmasterClient::new("your-token".to_string()).await?;
let request = RecrawlRequest {
urls: vec![
"https://example.com/page1".to_string(),
"https://example.com/page2".to_string(),
],
};
let response = client.recrawl_urls("host-id", &request).await?;
println!("Task ID: {}", response.task_id);
println!("Quota remaining: {:?}", response.quota_remainder);
Ok(())
}
Licensed under either of:
at your option.