giphy-api: Giphy HTTP API wrapper and CLI search tool.

[ bsd3, library, web ] [ Propose Tags ]

Please see README.md


[Skip to Readme]
Versions [faq] 0.1.0.0, 0.2.0.0, 0.2.1.0, 0.2.2.0, 0.2.3.0, 0.2.4.0, 0.2.5.0, 0.3.0.0, 0.4.0.0, 0.5.0.0, 0.5.1.0, 0.5.2.0, 0.6.0.0, 0.6.0.1, 0.7.0.0
Change log changelog.md
Dependencies aeson, base (>=4.8 && <5), containers, http-api-data, http-client, http-client-tls, microlens, microlens-th, mtl, network-uri, servant (==0.5.*), servant-client (==0.5.*), text [details]
License BSD-3-Clause
Author Pascal Hartig
Maintainer Pascal Hartig <phartig@rdrei.net>
Revised Revision 1 made by HerbertValerioRiedel at Mon Nov 28 20:26:30 UTC 2016
Category Web
Home page http://github.com/passy/giphy-api#readme
Uploaded by passy at Wed Mar 30 19:24:18 UTC 2016
Distributions LTSHaskell:0.6.0.1, NixOS:0.7.0.0
Executables giphy-search
Downloads 5427 total (207 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2016-03-30 [all 1 reports]

Modules

[Index]

Flags

NameDescriptionDefaultType
buildsample

Build the sample application.

DisabledManual

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

For package maintainers and hackage trustees


Readme for giphy-api-0.3.0.0

[back to package description]

giphy-api

Build Status Hackage

A Haskell wrapper for the Giphy HTTP API using servant-client.

Usage

The module provides a Giphy monad which can be run with runGiphy to lift it into IO. Here's a simple usage example:

{-# LANGUAGE OverloadedStrings #-}

import qualified Data.Text as T
import qualified Web.Giphy as Giphy

apiKey :: Giphy.Key
apiKey = Giphy.Key "dc6zaTOxFJmzC"

sample :: IO ()
sample = do
  let config = Giphy.GiphyConfig apiKey
  resp <- Giphy.runGiphy (app "puppies") config
  print resp

  where
    app :: T.Text -> Giphy.Giphy [Giphy.Gif]
    app q = do
      resp <- Giphy.search $ Giphy.Query q
      return $ Giphy._searchItems resp

For a slightly more complex example, check out the sample app, which also features the use of lenses.

Building

Use stack to build this library.

$ stack setup
$ stack test
# Drop the flag if you don't want the sample app to be built.
$ stack build --flag=giphy-api:buildSample
# To install the sample tool
$ stack install

Sample CLI Tool Usage

$ giphy-search --help
giphy-search

Usage: giphy-search ([-s|--search ARG] | [-t|--translate ARG] | [RANDOM_TAG])
  Find GIFs on the command line.

Available options:
  -h,--help                Show this help text
  -s,--search ARG          Use search to find a matching GIF.
  -t,--translate ARG       Use translate to find a matching GIF.
  -V,--version             Show version information
$ giphy-search puppies
Just https://media2.giphy.com/media/PjQFtJnmdOlwI/giphy.gif
$ giphy-search --translate superman
Just https://media3.giphy.com/media/eOewytQL4tOOA/giphy.gif
$ giphy-search "1C4D539A-B787-497F-B1DC-8FCF8D2C026D"
Nothing

Missing features

  • No network configuration. No proxies, no TLS certificate pinning, no custom networking stack. I'm still learning, let me know how to do this better!

  • There is no compiler flag at the moment to disable lenses if those aren't needed. The library, however, uses microlens so the overhead should be minimal.

  • The "Stickers" API endpoints are currently not covered. If you need them, let me know. PRs obviously very welcome.

  • Some fields are currently not exposed. Again, if you need them, open an issue. For example, I have never seen a type value other than "gif" so I decided to skip it.