Project

pexels

0.01
The project is in a healthy, maintained state
See more details at https://www.pexels.com/api/documentation/
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
 Project Readme

Pexels Ruby Library

The Pexels Ruby library is a convenient wrapper around the Pexels API that you can use to browse the incredible content uploaded by our talented contributors.

Installation

gem install pexels

Or add it to your Gemfile and run bundle install.

Documentation

See the API docs here

Basic usage

Create a client

# If you don't specify one, the environment variable PEXELS_API_KEY is used by default
client = Pexels::Client.new('your-access-key')

Search for photos

client.photos.search('Cloud')

Find a specific photo

client.photos[2014422] || client.photos.find(2014422)

Browse curated photos

client.photos.curated

Search for videos

client.videos.search('waves')

Find a specific photo

client.videos[2014422] || client.videos.find(2014422)

Browse popular videos

client.videos.popular

Running the test suite

You'll need your own API key to run the test suite, you can get one on the Pexels API Key management page

For ease of use, you'll probably want to copy the provided .env.sample into your own .env file and substitute the PEXELS_API_KEY variable with your own.

cp .env.sample .env
vim .env              #=> Change PEXELS_API_KEY
source .env           #=> Load the environment

make test