Crate pexels_client

source ·
Expand description

pexels_client

The pexels_client crate is a convenient wrapper around Pexels API.

Basic Usage

Create a client

Creates pexels client taking authorization key as argument. You can get your authorization key here. You can make multiple requests using same client.

use pexels_client::PexelsClient;

fn main() {
    let client = PexelsClient::new("auth_key".to_string()).unwrap();
}

Search for photos

Returns photos of requested query.

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

Returns photos of requested query 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();
}

Modules

  • Contains Structs required for browsing Collections
  • Contains Structs required for browsing Photos
  • Contains Structs required for browsing Videos

Structs

Enums

Type Definitions