Pixabay Rust Client
A Rust wrapper for the Pixabay API with command-line interface.
This project consists of two main components:
- pixabay-sdk: A Rust library for interacting with the Pixabay API
- pixabay-sdk-cli: A command-line interface for using the pixabay-sdk
Features
pixabay-sdk
- Search for images with advanced filtering
- Search for videos with advanced filtering
- Retrieve individual images and videos by ID
- Support for various filters:
- Image types (photo, illustration, vector)
- Video types (film, animation)
- Orientation (horizontal, vertical)
- Categories (nature, animals, people, etc.)
- Minimum dimensions
- Colors
- Editor's choice
- Safe search
- Multiple languages
- Asynchronous operations using tokio
- Type-safe API with proper error handling
pixabay-sdk-cli
- Command-line interface for searching images and videos
- Retrieve individual media items by their ID
- Support for all API parameters
- JSON output for easy integration
Installation
Add the following to your Cargo.toml:
[]
= "xxx"
= { = "0.12", = ["json"] }
= { = "1", = ["full"] }
= "0.15"
Setup
- Clone the repository:
- Build the project:
- Set up your API key:
Create a .env file in the project root:
PIXABAY_API_KEY=your_api_key_here
You can get your API key from Pixabay API Documentation.
Usage
Library Usage
Here's a basic example of using the pixabay-sdk library:
use dotenv;
use ;
use env;
async
CLI Usage
Search for Images
# Basic search
# Advanced search with filters
Get Image by ID
Search for Videos
# Basic search
# Advanced search with filters
Get Video by ID
API Reference
Client Methods
search_images(query, per_page, page)- Simple image searchsearch_images_advanced(params)- Advanced image search with parametersget_image(id)- Get a specific image by IDsearch_videos(query, per_page, page)- Simple video searchsearch_videos_advanced(params)- Advanced video search with parametersget_video(id)- Get a specific video by ID
Types
ImageType: All, Photo, Illustration, VectorVideoType: All, Film, AnimationOrientation: All, Horizontal, VerticalOrder: Popular, LatestCategory: Backgrounds, Fashion, Nature, Science, Education, Feelings, Health, People, Religion, Places, Animals, Industry, Computer, Food, Sports, Transportation, Travel, Buildings, Business, MusicLanguage: Multiple language codes supported (En, De, Fr, Es, etc.)
Error Handling
The library provides comprehensive error handling:
use ;
match client.search_images.await
Rate Limits
By default, the Pixabay API allows up to 100 requests per 60 seconds. The library will return a RateLimitExceeded error when you hit this limit.
Documentation
For detailed API documentation, visit:
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 or MIT license, shall be dual licensed as above, without any additional terms or conditions.