Giphy v0.1.1 Giphy

An Elixir wrapper for the Giphy API.

Configuration

You will need to set the Giphy API key. The :api_key config option accepts both a String and a {:system, "ENV_VAR"} tuple.

config :giphy, api_key: "YOUR_API_KEY"
# or ...
config :giphy, api_key: {:system, "ENV_VAR"}

Usage

Simply search for whatever GIF you want to find with Giphy.search/2:

Giphy.search("ryan gosling")
# => %Giphy.Page{data: [%Giphy.GIF{}, ...]}

Search results are paginated. You can pass limit and offset parameters:

Giphy.search("ryan gosling", limit: 1, offset: 10)
# => %Giphy.Page{data: [%Giphy.GIF{}, ...]}

More documentation on the structs is located here:

Testing

This library includes a mock API module for testing purposes. In your config/text.exs, set Giphy to use the mock:

config :giphy, api: Giphy.API.Mock

Your tests will then use the mock instead of making HTTP requests. See Giphy.API.Mock for more information.

Summary

Functions

Searches for GIFs matching a given search term. Wraps the Giphy search endpoint

Behaves exactly the same as search/2, but returns a Giphy.Page on success and raises any errors

Types

search_opts()
search_opts() :: [limit: integer, offset: integer]

Functions

search(terms, params \\ [])
search(String.t, search_opts) ::
  {:ok, Giphy.Page.t} |
  {:error, HTTPoison.Response.t} |
  {:error, HTTPoison.Error.t}

Searches for GIFs matching a given search term. Wraps the Giphy search endpoint.

Example

Giphy.search("ryan gosling")
# => {:ok, %Giphy.Page{data: [%Giphy.Image{}]}}

Limit and offset parameters can also be passed:

Giphy.search("ryan gosling", limit: 1, offset: 10)
# => {:error, %Giphy.Page{data: [%Giphy.Image{}]}}
search!(terms, params \\ [])

Behaves exactly the same as search/2, but returns a Giphy.Page on success and raises any errors.