[][src]Struct pexels::Pexels

pub struct Pexels { /* fields omitted */ }

Methods

impl Pexels[src]

Arguments

  • query - Search photos related to the query
  • per_page - Defines the number of results per page (max: 80)
  • page - Defines the number of the page

Example

extern crate pexels;

fn main() {
    let pexels_api_client = pexels::Pexels::new("YOUR_API_KEY".to_string());
    pexels_api_client.photo_search("mountains".to_string(), 15, 1);
}

Example Output

Object({
    "next_page":    String("https://api.pexels.com/v1/search/?page=2&per_page=15&query=mountain"),
    "page":Number(1),
    "per_page":Number(15),
    "photos":Array(    [
        Object(        {
            "height":Number(3248),
            "id":Number(417173),
            "photographer":String("Pixabay"),
            "photographer_url":            String("https://www.pexels.com/@pixabay"),
            "src":Object(            {
                "landscape":                String("https://images.pexels.com/photos/417173/pexels-photo-417173.jpeg?auto=compress&cs=tinysrgb&fit=crop&h=627&w=1200"),
                "large":                String("https://images.pexels.com/photos/417173/pexels-photo-417173.jpeg?auto=compress&cs=tinysrgb&h=650&w=940"),
                "large2x":                String("https://images.pexels.com/photos/417173/pexels-photo-417173.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940"),
                "medium":                String("https://images.pexels.com/photos/417173/pexels-photo-417173.jpeg?auto=compress&cs=tinysrgb&h=350"),
                "original":                String("https://images.pexels.com/photos/417173/pexels-photo-417173.jpeg"),
                "portrait":                String("https://images.pexels.com/photos/417173/pexels-photo-417173.jpeg?auto=compress&cs=tinysrgb&fit=crop&h=1200&w=800"),
                "small":                String("https://images.pexels.com/photos/417173/pexels-photo-417173.jpeg?auto=compress&cs=tinysrgb&h=130"),
                "tiny":                String("https://images.pexels.com/photos/417173/pexels-photo-417173.jpeg?auto=compress&cs=tinysrgb&dpr=1&fit=crop&h=200&w=280")
            }            ),
            "url":            String("https://www.pexels.com/photo/altitude-clouds-cold-daylight-417173/"),
            "width":Number(4872)
        }        ),
        .....
    ]    ),
    "total_results":Number(9478)
})

pub fn photo_curated(&self, per_page: u32, page: u32) -> Value[src]

Pexels add at least one new photo per hour to our curated list so that you get a changing selection of trending photos.

Arguments

  • per_page - Defines the number of results per page (max: 80)
  • page - Defines the number of the page

Example

extern crate pexels;

fn main() {
    let pexels_api_client = pexels::Pexels::new("YOUR_API_KEY".to_string());
    pexels_api_client.photo_curated(15, 1);
}

Example Output

Object({
    "next_page":    String("https://api.pexels.com/v1/curated/?page=2&per_page=15"),
    "page":Number(1),
    "per_page":Number(15),
    "photos":Array(    [
        Object(        {
            "height":Number(2667),
            "id":Number(1492232),
            "photographer":String("Soloman Soh"),
            "photographer_url":            String("https://www.pexels.com/@soloman-soh-674993"),
            "src":Object(            {
                "landscape":                String("https://images.pexels.com/photos/1492232/pexels-photo-1492232.jpeg?auto=compress&cs=tinysrgb&fit=crop&h=627&w=1200"),
                "large":                String("https://images.pexels.com/photos/1492232/pexels-photo-1492232.jpeg?auto=compress&cs=tinysrgb&h=650&w=940"),
                "large2x":                String("https://images.pexels.com/photos/1492232/pexels-photo-1492232.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940"),
                "medium":                String("https://images.pexels.com/photos/1492232/pexels-photo-1492232.jpeg?auto=compress&cs=tinysrgb&h=350"),
                "original":                String("https://images.pexels.com/photos/1492232/pexels-photo-1492232.jpeg"),
                "portrait":                String("https://images.pexels.com/photos/1492232/pexels-photo-1492232.jpeg?auto=compress&cs=tinysrgb&fit=crop&h=1200&w=800"),
                "small":                String("https://images.pexels.com/photos/1492232/pexels-photo-1492232.jpeg?auto=compress&cs=tinysrgb&h=130"),
                "tiny":                String("https://images.pexels.com/photos/1492232/pexels-photo-1492232.jpeg?auto=compress&cs=tinysrgb&dpr=1&fit=crop&h=200&w=280")
            }            ),
            "url":            String("https://www.pexels.com/photo/architectural-photography-of-glass-buliding-1492232/"),
            "width":Number(4000)
        }        ),
        .....
    ]    )
})

pub fn photo_detail(&self, id: String) -> Value[src]

If you have the id of a photo, you can retrieve the data of it.

Arguments

  • id - id of the photo

Example

extern crate pexels;

fn main() {
    let pexels_api_client = pexels::Pexels::new("YOUR_API_KEY".to_string());
    pexels_api_client.photo_detail("417173".to_string());
}

Example Output

Object({
    "height":Number(4160),
    "id":Number(2608372),
    "photographer":String("Kei Scampa"),
    "photographer_url":    String("https://www.pexels.com/@kei-scampa-1201427"),
    "src":Object(    {
        "landscape":        String("https://images.pexels.com/photos/2608372/pexels-photo-2608372.jpeg?auto=compress&cs=tinysrgb&fit=crop&h=627&w=1200"),
        "large":        String("https://images.pexels.com/photos/2608372/pexels-photo-2608372.jpeg?auto=compress&cs=tinysrgb&h=650&w=940"),
        "large2x":        String("https://images.pexels.com/photos/2608372/pexels-photo-2608372.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940"),
        "medium":        String("https://images.pexels.com/photos/2608372/pexels-photo-2608372.jpeg?auto=compress&cs=tinysrgb&h=350"),
        "original":        String("https://images.pexels.com/photos/2608372/pexels-photo-2608372.jpeg"),
        "portrait":        String("https://images.pexels.com/photos/2608372/pexels-photo-2608372.jpeg?auto=compress&cs=tinysrgb&fit=crop&h=1200&w=800"),
        "small":        String("https://images.pexels.com/photos/2608372/pexels-photo-2608372.jpeg?auto=compress&cs=tinysrgb&h=130"),
        "tiny":        String("https://images.pexels.com/photos/2608372/pexels-photo-2608372.jpeg?auto=compress&cs=tinysrgb&dpr=1&fit=crop&h=200&w=280")
    }    ),
    "url":    String("https://www.pexels.com/photo/woman-inside-vehicle-2608372/"),
    "width":Number(6240)
})

impl Pexels[src]

Arguments

  • query - Get videos related to this query.
  • per_page - Defines the number of results per page (max: 80)
  • page - Defines the number of the page

Example

extern crate pexels;

fn main() {
    let pexels_api_client = pexels::Pexels::new("YOUR_API_KEY".to_string());
    pexels_api_client.video_search("mountains".to_string(), 15, 1);
}

Example Output

Object({
    "page":Number(1),
    "per_page":Number(15),
    "total_results":Number(367),
    "url":    String("http://api-videos.pexels.com/search/mountain"),
    "videos":Array(    [
        Object(        {
            "duration":Number(7),
            "full_res":Null,
            "height":Number(720),
            "id":Number(857195),
            "image":            String("https://images.pexels.com/videos/857195/free-video-857195.jpg?fit=crop&w=1200&h=630&auto=compress&cs=tinysrgb"),
            "url":            String("https://videos.pexels.com/videos/time-lapse-video-of-night-sky-857195"),
            "video_files":Array(            [
                Object(                {
                    "file_type":String("video/mp4"),
                    "height":Number(360),
                    "id":Number(9015),
                    "link":                    String("https://player.vimeo.com/external/189545487.sd.mp4?s=8cd2af1ec08f7ce121a5a6a09c78c05237943524&profile_id=164&oauth2_token_id=57447761"),
                    "quality":String("sd"),
                    "width":Number(640)
                }                ),
                Object(                {
                    "file_type":String("video/mp4"),
                    "height":Number(720),
                    "id":Number(9016),
                    "link":                    String("https://player.vimeo.com/external/189545487.hd.mp4?s=131fa753bd9d7d6085af29f3603f4b65cbb3ab31&profile_id=174&oauth2_token_id=57447761"),
                    "quality":String("hd"),
                    "width":Number(1280)
                }                ),
                Object(                {
                    "file_type":String("video/mp4"),
                    "height":Number(540),
                    "id":Number(9017),
                    "link":                    String("https://player.vimeo.com/external/189545487.sd.mp4?s=8cd2af1ec08f7ce121a5a6a09c78c05237943524&profile_id=165&oauth2_token_id=57447761"),
                    "quality":String("sd"),
                    "width":Number(960)
                }                ),
                Object(                {
                    "file_type":String("video/mp4"),
                    "height":Null,
                    "id":Number(9018),
                    "link":                    String("https://player.vimeo.com/external/189545487.m3u8?s=d35298d7880d7056964e7738f358f60202f75ee7&oauth2_token_id=57447761"),
                    "quality":String("hls"),
                    "width":Null
                }                )
            ]            ),
            "video_pictures":Array(            [
                Object(                {
                    "id":Number(12841),
                    "nr":Number(0),
                    "picture":                    String("https://static-videos.pexels.com/videos/857195/pictures/preview-0.jpg")
                }                ),
                Object(                {
                    "id":Number(12842),
                    "nr":Number(1),
                    "picture":                    String("https://static-videos.pexels.com/videos/857195/pictures/preview-1.jpg")
                }                ),
                Object(                {
                    "id":Number(12843),
                    "nr":Number(2),
                    "picture":                    String("https://static-videos.pexels.com/videos/857195/pictures/preview-2.jpg")
                }                ),
                Object(                {
                    "id":Number(12844),
                    "nr":Number(3),
                    "picture":                    String("https://static-videos.pexels.com/videos/857195/pictures/preview-3.jpg")
                }                ),
                Object(                {
                    "id":Number(12845),
                    "nr":Number(4),
                    "picture":                    String("https://static-videos.pexels.com/videos/857195/pictures/preview-4.jpg")
                }                ),
                Object(                {
                    "id":Number(12846),
                    "nr":Number(5),
                    "picture":                    String("https://static-videos.pexels.com/videos/857195/pictures/preview-5.jpg")
                }                ),
                Object(                {
                    "id":Number(12847),
                    "nr":Number(6),
                    "picture":                    String("https://static-videos.pexels.com/videos/857195/pictures/preview-6.jpg")
                }                ),
                Object(                {
                    "id":Number(12848),
                    "nr":Number(7),
                    "picture":                    String("https://static-videos.pexels.com/videos/857195/pictures/preview-7.jpg")
                }                ),
                Object(                {
                    "id":Number(12849),
                    "nr":Number(8),
                    "picture":                    String("https://static-videos.pexels.com/videos/857195/pictures/preview-8.jpg")
                }                ),
                Object(                {
                    "id":Number(12850),
                    "nr":Number(9),
                    "picture":                    String("https://static-videos.pexels.com/videos/857195/pictures/preview-9.jpg")
                }                ),
                Object(                {
                    "id":Number(12851),
                    "nr":Number(10),
                    "picture":                    String("https://static-videos.pexels.com/videos/857195/pictures/preview-10.jpg")
                }                ),
                Object(                {
                    "id":Number(12852),
                    "nr":Number(11),
                    "picture":                    String("https://static-videos.pexels.com/videos/857195/pictures/preview-11.jpg")
                }                ),
                Object(                {
                    "id":Number(12853),
                    "nr":Number(12),
                    "picture":                    String("https://static-videos.pexels.com/videos/857195/pictures/preview-12.jpg")
                }                ),
                Object(                {
                    "id":Number(12854),
                    "nr":Number(13),
                    "picture":                    String("https://static-videos.pexels.com/videos/857195/pictures/preview-13.jpg")
                }                ),
                Object(                {
                    "id":Number(12855),
                    "nr":Number(14),
                    "picture":                    String("https://static-videos.pexels.com/videos/857195/pictures/preview-14.jpg")
                }                )
            ]            ),
            "width":Number(1280)
        }        ),
        .....
    ]    )
})

Arguments

  • per_page - Defines the number of results per page (max: 80)
  • page - Defines the number of the page

Example

extern crate pexels;

fn main() {
    let pexels_api_client = pexels::Pexels::new("YOUR_API_KEY".to_string());
    pexels_api_client.video_popular(15, 1);
}

Example Output

Object({
    "page":Number(1),
    "per_page":Number(15),
    "total_results":Number(7621),
    "url":    String("http://api-videos.pexels.com/popular-videos"),
    "videos":Array(    [
        Object(        {
            "duration":Number(18),
            "full_res":Null,
            "height":Number(1080),
            "id":Number(2268807),
            "image":            String("https://images.pexels.com/videos/2268807/free-video-2268807.jpg?fit=crop&w=1200&h=630&auto=compress&cs=tinysrgb"),
            "url":            String("https://videos.pexels.com/videos/an-open-book-2268807"),
            "video_files":Array(            [
                Object(                {
                    "file_type":String("video/mp4"),
                    "height":Number(240),
                    "id":Number(100777),
                    "link":                    String("https://player.vimeo.com/external/334034343.sd.mp4?s=86f5d7798a820e355dea70d0c50d892298f976af&profile_id=139&oauth2_token_id=57447761"),
                    "quality":String("sd"),
                    "width":Number(426)
                }                ),
                Object(                {
                    "file_type":String("video/mp4"),
                    "height":Number(720),
                    "id":Number(100778),
                    "link":                    String("https://player.vimeo.com/external/334034343.hd.mp4?s=b00f209591054430d09b2ecffa47e320a0477941&profile_id=174&oauth2_token_id=57447761"),
                    "quality":String("hd"),
                    "width":Number(1280)
                }                ),
                Object(                {
                    "file_type":String("video/mp4"),
                    "height":Number(360),
                    "id":Number(100779),
                    "link":                    String("https://player.vimeo.com/external/334034343.sd.mp4?s=86f5d7798a820e355dea70d0c50d892298f976af&profile_id=164&oauth2_token_id=57447761"),
                    "quality":String("sd"),
                    "width":Number(640)
                }                ),
                Object(                {
                    "file_type":String("video/mp4"),
                    "height":Number(1080),
                    "id":Number(100780),
                    "link":                    String("https://player.vimeo.com/external/334034343.hd.mp4?s=b00f209591054430d09b2ecffa47e320a0477941&profile_id=175&oauth2_token_id=57447761"),
                    "quality":String("hd"),
                    "width":Number(1920)
                }                ),
                Object(                {
                    "file_type":String("video/mp4"),
                    "height":Number(540),
                    "id":Number(100781),
                    "link":                    String("https://player.vimeo.com/external/334034343.sd.mp4?s=86f5d7798a820e355dea70d0c50d892298f976af&profile_id=165&oauth2_token_id=57447761"),
                    "quality":String("sd"),
                    "width":Number(960)
                }                ),
                Object(                {
                    "file_type":String("video/mp4"),
                    "height":Null,
                    "id":Number(100782),
                    "link":                    String("https://player.vimeo.com/external/334034343.m3u8?s=f4a110cb30a7d0f9894b034f8d75e6a8d4fe0348&oauth2_token_id=57447761"),
                    "quality":String("hls"),
                    "width":Null
                }                )
            ]            ),
            "video_pictures":Array(            [
                Object(                {
                    "id":Number(252273),
                    "nr":Number(0),
                    "picture":                    String("https://static-videos.pexels.com/videos/2268807/pictures/preview-0.jpg")
                }                ),
                Object(                {
                    "id":Number(252274),
                    "nr":Number(1),
                    "picture":                    String("https://static-videos.pexels.com/videos/2268807/pictures/preview-1.jpg")
                }                ),
                Object(                {
                    "id":Number(252275),
                    "nr":Number(2),
                    "picture":                    String("https://static-videos.pexels.com/videos/2268807/pictures/preview-2.jpg")
                }                ),
                Object(                {
                    "id":Number(252276),
                    "nr":Number(3),
                    "picture":                    String("https://static-videos.pexels.com/videos/2268807/pictures/preview-3.jpg")
                }                ),
                Object(                {
                    "id":Number(252277),
                    "nr":Number(4),
                    "picture":                    String("https://static-videos.pexels.com/videos/2268807/pictures/preview-4.jpg")
                }                ),
                Object(                {
                    "id":Number(252278),
                    "nr":Number(5),
                    "picture":                    String("https://static-videos.pexels.com/videos/2268807/pictures/preview-5.jpg")
                }                ),
                Object(                {
                    "id":Number(252279),
                    "nr":Number(6),
                    "picture":                    String("https://static-videos.pexels.com/videos/2268807/pictures/preview-6.jpg")
                }                ),
                Object(                {
                    "id":Number(252280),
                    "nr":Number(7),
                    "picture":                    String("https://static-videos.pexels.com/videos/2268807/pictures/preview-7.jpg")
                }                ),
                Object(                {
                    "id":Number(252281),
                    "nr":Number(8),
                    "picture":                    String("https://static-videos.pexels.com/videos/2268807/pictures/preview-8.jpg")
                }                ),
                Object(                {
                    "id":Number(252282),
                    "nr":Number(9),
                    "picture":                    String("https://static-videos.pexels.com/videos/2268807/pictures/preview-9.jpg")
                }                ),
                Object(                {
                    "id":Number(252283),
                    "nr":Number(10),
                    "picture":                    String("https://static-videos.pexels.com/videos/2268807/pictures/preview-10.jpg")
                }                ),
                Object(                {
                    "id":Number(252284),
                    "nr":Number(11),
                    "picture":                    String("https://static-videos.pexels.com/videos/2268807/pictures/preview-11.jpg")
                }                ),
                Object(                {
                    "id":Number(252285),
                    "nr":Number(12),
                    "picture":                    String("https://static-videos.pexels.com/videos/2268807/pictures/preview-12.jpg")
                }                ),
                Object(                {
                    "id":Number(252287),
                    "nr":Number(13),
                    "picture":                    String("https://static-videos.pexels.com/videos/2268807/pictures/preview-13.jpg")
                }                ),
                Object(                {
                    "id":Number(252288),
                    "nr":Number(14),
                    "picture":                    String("https://static-videos.pexels.com/videos/2268807/pictures/preview-14.jpg")
                }                )
            ]            ),
            "width":Number(1920)
        }        ),
        .....
    ]    )
})

impl Pexels[src]

pub fn new(api_key: String) -> Pexels[src]

Create a new Pexels API client.

Trait Implementations

impl Clone for Pexels[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Pexels[src]

Auto Trait Implementations

impl Send for Pexels

impl Unpin for Pexels

impl Sync for Pexels

impl !UnwindSafe for Pexels

impl !RefUnwindSafe for Pexels

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Erased for T

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Err = <U as TryFrom<T>>::Err