Crates.io | google-indexing-api |
lib.rs | google-indexing-api |
version | 0.1.4 |
source | src |
created_at | 2023-05-23 23:31:44.830292 |
updated_at | 2023-09-15 22:36:47.673114 |
description | GoogleIndexing API |
homepage | |
repository | https://github.com/uiuifree/rust-google-indexing-api |
max_upload_size | |
id | 872459 |
size | 22,321 |
This is a Rust library for interfacing with the Google Indexing API. It allows you to notify Google about pages on your web app for indexing in search results.
To use the google-indexing-api in your Rust project, add it as a dependency in your Cargo.toml:
[dependencies]
google-indexing-api = "0.1"
async fn main() {
use google_indexing_api::{GoogleIndexingApi, UrlNotificationsType};
let api = GoogleIndexingApi::url_notifications();
// Notify Google about a URL update
let response = api.publish("YOUR_GOOGLE_TOKEN", "https://yourwebsite.com/page1", UrlNotificationsType::UPDATED).await;
// Notify Google about a URL delete
let response = api.publish("YOUR_GOOGLE_TOKEN", "https://yourwebsite.com/page1", UrlNotificationsType::DELETED).await;
// Retrieve metadata about a URL
let metadata = api.get_metadata("YOUR_GOOGLE_TOKEN", "https://yourwebsite.com/page1").await;
// Batch notify Google about multiple URL updates
let urls = vec!["https://yourwebsite.com/page1", "https://yourwebsite.com/page2"];
let batch_response = api.batch("YOUR_GOOGLE_TOKEN", urls, UrlNotificationsType::UPDATED).await;
}
The library provides structured error handling through the GoogleApiError enum. You can match against it to handle specific error scenarios in your application.