### Install Pexels Ruby Gem Source: https://github.com/pexels/pexels-ruby/blob/master/README.md Install the Pexels Ruby library using the gem command or by adding it to your Gemfile. ```Shell gem install pexels ``` -------------------------------- ### Run Pexels Ruby Library Tests Source: https://github.com/pexels/pexels-ruby/blob/master/README.md Setup environment variables and run the test suite for the Pexels Ruby library. ```Shell cp .env.sample .env vim .env #=> Change PEXELS_API_KEY source .env #=> Load the environment make test ``` -------------------------------- ### Get Media for a Collection using Pexels Ruby Client Source: https://github.com/pexels/pexels-ruby/blob/master/README.md Retrieve all media (photos and videos) within a specific collection using its ID. ```Ruby client.collections['collection-id'].media ``` ```Ruby client.collections.find('collection-id').media ``` -------------------------------- ### Get Filtered Media for a Collection using Pexels Ruby Client Source: https://github.com/pexels/pexels-ruby/blob/master/README.md Retrieve media from a collection, filtering results to include only photos or only videos. ```Ruby client.collections['collection-id', type: 'photos'].media ``` ```Ruby client.collections['collection-id', type: 'videos'].media ``` -------------------------------- ### Initialize Pexels Client in Ruby Source: https://github.com/pexels/pexels-ruby/blob/master/README.md Create a new instance of the Pexels client. You can pass your API key directly or rely on the PEXELS_API_KEY environment variable. ```Ruby # If you don't specify one, the environment variable PEXELS_API_KEY is used by default client = Pexels::Client.new('your-access-key') ``` -------------------------------- ### Navigate Pagination using Pexels Ruby Client Source: https://github.com/pexels/pexels-ruby/blob/master/README.md Use the prev_page and next_page methods on a paginated response object to easily fetch adjacent pages of results. ```Ruby response = client.photos.search('dog', page: 2, per_page: 50) response.prev_page # queries page 1 response.next_page # queries page 3 ``` -------------------------------- ### Search Videos using Pexels Ruby Client Source: https://github.com/pexels/pexels-ruby/blob/master/README.md Perform a basic search for videos based on a query string using the Pexels client. ```Ruby client.videos.search('waves') ``` -------------------------------- ### Browse Popular Videos using Pexels Ruby Client Source: https://github.com/pexels/pexels-ruby/blob/master/README.md Access a list of popular videos on Pexels. ```Ruby client.videos.popular ``` -------------------------------- ### Search Photos using Pexels Ruby Client Source: https://github.com/pexels/pexels-ruby/blob/master/README.md Perform a basic search for photos based on a query string using the Pexels client. ```Ruby client.photos.search('Cloud') ``` -------------------------------- ### Search Videos with Filters using Pexels Ruby Client Source: https://github.com/pexels/pexels-ruby/blob/master/README.md Search for videos and apply various filters such as size and orientation to refine the results. ```Ruby client.videos.search('Beach', size: :medium, orientation: :landscape) ``` -------------------------------- ### List Featured Collections using Pexels Ruby Client Source: https://github.com/pexels/pexels-ruby/blob/master/README.md Retrieve a list of featured collections on Pexels. ```Ruby client.collections.featured.all ``` -------------------------------- ### Search Photos with Filters using Pexels Ruby Client Source: https://github.com/pexels/pexels-ruby/blob/master/README.md Search for photos and apply various filters such as color, size, and orientation to refine the results. ```Ruby client.photos.search('Dog', color: :yellow, size: :large, orientation: :square) ``` -------------------------------- ### Browse Curated Photos using Pexels Ruby Client Source: https://github.com/pexels/pexels-ruby/blob/master/README.md Access a list of curated photos selected by Pexels editors. ```Ruby client.photos.curated ``` -------------------------------- ### List User Collections using Pexels Ruby Client Source: https://github.com/pexels/pexels-ruby/blob/master/README.md Retrieve a list of collections belonging to the API user. ```Ruby client.collections.all ``` -------------------------------- ### Access Pagination Info using Pexels Ruby Client Source: https://github.com/pexels/pexels-ruby/blob/master/README.md Perform a paginated request and access properties like total results and total pages from the response object. ```Ruby response = client.photos.search('dog', page: 2, per_page: 50) response.total_results #=> 1000 response.total_pages #= 20 ``` -------------------------------- ### Find Specific Video by ID using Pexels Ruby Client Source: https://github.com/pexels/pexels-ruby/blob/master/README.md Retrieve a specific video by its unique ID using either array-like access or the find method. ```Ruby client.videos[2014422] ``` ```Ruby client.videos.find(2014422) ``` -------------------------------- ### Find Specific Photo by ID using Pexels Ruby Client Source: https://github.com/pexels/pexels-ruby/blob/master/README.md Retrieve a specific photo by its unique ID using either array-like access or the find method. ```Ruby client.photos[2014422] ``` ```Ruby client.photos.find(2014422) ``` -------------------------------- ### Check Remaining Rate Limit using Pexels Ruby Client Source: https://github.com/pexels/pexels-ruby/blob/master/README.md Access the number of requests remaining in your current rate limit window after performing an API request. ```Ruby client.ratelimit_remaining ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.