Skip to content

alexdont/giphy_api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GiphyApi

Standalone Elixir client for the Giphy API. Search, trending, and single GIF lookup with typed structs.

Installation

Add giphy_api to your list of dependencies in mix.exs:

def deps do
  [
    {:giphy_api, "~> 0.1.0"}
  ]
end

Configuration

# config/runtime.exs
config :giphy_api, api_key: System.get_env("GIPHY_API_KEY")

Get your API key at developers.giphy.com.

Usage

Search

{:ok, gifs} = GiphyApi.search("funny cat")

# With options
{:ok, gifs} = GiphyApi.search("funny cat", limit: 10, rating: "g", lang: "en")

Trending

{:ok, gifs} = GiphyApi.trending(limit: 20)

Get by ID

{:ok, gif} = GiphyApi.get("xT9IgzoKnwFNmISR8I")

Response

All functions return {:ok, result} or {:error, reason}. Results are %GiphyApi.Gif{} structs:

%GiphyApi.Gif{
  id: "xT9IgzoKnwFNmISR8I",
  title: "Funny Cat GIF",
  url: "https://giphy.com/gifs/...",
  preview_url: "https://media.giphy.com/.../200w.gif",
  preview_width: 200,
  preview_height: 150,
  original_url: "https://media.giphy.com/.../giphy.gif",
  original_width: 480,
  original_height: 360,
  downsized_url: "https://media.giphy.com/.../giphy-downsized-medium.gif",
  username: "catgifs"
}

Options

Option Default Description
:limit 20 Max results (up to 50)
:offset 0 Pagination offset
:rating "pg-13" Content filter: "g", "pg", "pg-13", "r"
:lang "en" Language code (search only)

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages