2 releases
0.1.1 | Apr 24, 2023 |
---|---|
0.1.0 | Apr 24, 2023 |
#680 in Images
34 downloads per month
36KB
805 lines
Pexels Client
The pexels_client crate is a wrapper around Pexels API.
More information about this crate can be found in the crate documentation.
Usage
To use pexels_client
, first add this to your Cargo.toml
:
[dependencies]
pexels_client = "0.1.0"
Examples
Create a Pexels Client:
use pexels_client::PexelsClient;
fn main() {
let client = PexelsClient::new("auth_key".to_string()).unwrap();
}
Search for Photos:
use pexels_client::{PexelsClient, photos::PhotoSearchQuery};
async fn test() {
let client = PexelsClient::new("auth_key".to_string()).unwrap();
let response = client
.photo_search(PhotoSearchQuery::new("tigers".to_string()))
.await
.unwrap();
}
Search for photos with filters:
use pexels_client::{*, photos::PhotoSearchQuery};
async fn test() {
let client = PexelsClient::new("auth_key".to_string()).unwrap();
let query = PhotoSearchQuery::new("tigers".to_string())
.orientation(Orientation::Portrait)
.size(Size::Large)
.color(Color::Blue)
.per_page(5);
let response = client.photo_search(query).await.unwrap();
}
License
Licensed under
- MIT license (LICENSE-MIT)
Dependencies
~4–15MB
~225K SLoC