pexels_client

Crates.iopexels_client
lib.rspexels_client
version0.1.1
sourcesrc
created_at2023-04-24 17:18:42.495754
updated_at2023-04-24 17:39:29.820917
descriptionRust wrapper for Pexels API
homepage
repositoryhttps://github.com/sattva9/pexels_client
max_upload_size
id847661
size36,294
Sattva (sattva9)

documentation

https://docs.rs/pexels_client

README

Pexels Client

The pexels_client crate is a wrapper around Pexels API.

Crates.io Documentation

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

Commit count: 6

cargo fmt