Method: Unsplash::Photo.search

Defined in:
lib/unsplash/photo.rb

.search(query, page = 1, per_page = 10, orientation = nil, content_filter = "low") ⇒ SearchResult

Search for photos by keyword.

Parameters:

  • query (String)

    Keywords to search for.

  • page (Integer) (defaults to: 1)

    Which page of search results to return.

  • per_page (Integer) (defaults to: 10)

    The number of users search result per page. (default: 10, maximum: 30)

  • orientation (String) (defaults to: nil)

    Filter by orientation of the photo. Valid values are landscape, portrait, and squarish.

  • content_filter (String) (defaults to: "low")

    Limit results by content_filter to avoid content that may be unsuitable for younger audiences. Valid values are low, high. Defaults to low.

Returns:



90
91
92
93
94
95
96
97
98
99
# File 'lib/unsplash/photo.rb', line 90

def search(query, page = 1, per_page = 10, orientation = nil, content_filter = "low")
  params = {
    query:    query,
    page:     page,
    per_page: per_page,
    orientation: orientation,
    content_filter: content_filter
  }.select { |_k, v| v }
  Unsplash::Search.search("/search/photos", self, params)
end