IndexNow API for Rust
A Rust library for instantly notifying search engines about URL changes using the IndexNow protocol. Supports Bing, Yandex, and other IndexNow-compatible search engines.
Features
- 🚀 Async/await support - Built with modern Rust async patterns
- 🔧 Simple API - Easy to integrate with just a few lines of code
- 🌐 Multiple search engines - Works with Bing, Yandex, and other IndexNow endpoints
- 🛡️ Error handling - Comprehensive error types for robust applications
- 📦 Zero-config - Works out of the box with sensible defaults
Quick Start
Add this to your Cargo.toml:
[]
= "0.1.0"
= { = "1", = ["full"] }
Usage
Basic Example
use IndexNowApi;
async
Batch URL Submission
Submit multiple URLs at once for better efficiency:
use IndexNowApi;
async
Custom Search Engine Endpoint
Target specific search engines by setting custom endpoints:
use IndexNowApi;
async
Error Handling
Handle different types of errors gracefully:
use ;
async
API Reference
IndexNowApi
The main struct for interacting with IndexNow APIs.
Constructor
Parameters:
host- Your website's hostname (e.g., "www.example.com")key- Your IndexNow API key (32-character hexadecimal string)
Methods
set_search_engine
Sets a custom search engine endpoint. Default: https://api.indexnow.org
Popular endpoints:
- Bing:
https://www.bing.com - Yandex:
https://yandex.com
set_key_location
Specifies where your API key file is hosted (optional).
send_urls
pub async
Submits a list of URLs to the search engine for indexing.
Limits:
- Maximum 10,000 URLs per request
- URLs must be from the same domain as the
host
Getting Your IndexNow API Key
Step 1: Generate an API Key
Create a 32-character hexadecimal key:
# Using OpenSSL
# Using Python
# Example output: 7be9fca90b3b4b039983fa8f06e03ee8
Step 2: Host the Key File
Create a text file containing only your API key and host it at:
https://yourdomain.com/[your-api-key].txt
Example:
- API Key:
7be9fca90b3b4b039983fa8f06e03ee8 - File location:
https://www.example.com/7be9fca90b3b4b039983fa8f06e03ee8.txt - File contents:
7be9fca90b3b4b039983fa8f06e03ee8
Step 3: Verify Setup
Test your setup by submitting a URL and checking for successful responses.
Supported Search Engines
| Search Engine | Endpoint | Status |
|---|---|---|
| Bing | https://www.bing.com/indexnow |
✅ Supported |
| Yandex | https://yandex.com/indexnow |
✅ Supported |
| Generic | https://api.indexnow.org/indexnow |
✅ Supported |
Best Practices
- Batch requests - Submit multiple URLs in a single request when possible
- Rate limiting - Don't submit the same URL multiple times within 24 hours
- Key security - Keep your API key secure and rotate it periodically
- Error handling - Always handle potential network and API errors
- URL validation - Ensure URLs belong to your verified domain
Error Types
GoogleApiError::Connection(String)
Network connectivity issues, DNS problems, or server timeouts.
GoogleApiError::Status(u8)
HTTP status codes indicating API errors (4xx, 5xx responses).
Examples
Check out the tests/ directory for more usage examples:
Contributing
We welcome contributions! Please feel free to submit issues, feature requests, or pull requests.
Development Setup
Guidelines
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes with tests
- Ensure
cargo testpasses - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Related Resources
Changelog
v0.1.0
- Initial release
- Basic IndexNow API support
- Async/await implementation
- Error handling
- Multiple search engine endpoints
Questions? Open an issue on GitHub or check the documentation.