gophy

package module
v0.0.0-...-8eaf596 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 24, 2015 License: MIT Imports: 7 Imported by: 1

README

gophy

Build Status GoDoc

gophy is a Golang wrapper for the Giphy.com API. gophy is a WIP but aims to eventually have 100% coverage of the API. Gophy requires Go >= 1.1.

See GoDoc for full library documentation.

TODO
  • Random endpoints
  • Full documentation
Example

Using gophy should be simple, just import it into your project, create a client and call the appropriate method. A contrived example is shown below:

package main

import (
	"fmt"
	"github.com/paddycarey/gophy"
)

def main() {
	co := &gophy.ClientOptions{}
	client := gophy.NewClient(co)

	gifs, err := gophy.TrendingGifs("", 20)
	if err != nil {
		panic(err)
	}

	for _, gif := range gifs {
		fmt.Printf("%s: %s", gif.Id, gif.URL)
	}
}

Documentation

Overview

gophy is a simple library designed to give easy access to the Giphy API. gophy aims to have 100% API coverage with a full test suite.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(co *ClientOptions) *Client

func (*Client) GetGifById

func (c *Client) GetGifById(id string) (*Gif, error)

GetGifById returns a single GIF from the Giphy API.

func (*Client) GetGifsById

func (c *Client) GetGifsById(ids ...string) ([]*Gif, error)

GetGifsById returns a number of GIFs from the Giphy API. This method accepts a maximum of 100 ids.

func (*Client) SearchGifs

func (c *Client) SearchGifs(q string, rating string, limit int, offset int) ([]*Gif, int, error)

SearchGifs searches the Giphy API for GIFs with the specified options. Returns a slice containing the returned gifs, the total number of images available for the specified query (so that you can paginate your requests as required), and an error if one occured.

func (*Client) SearchStickers

func (c *Client) SearchStickers(q string, rating string, limit int, offset int) ([]*Gif, int, error)

SearchStickers replicates the functionality and requirements of the classic Giphy search, but returns animated stickers rather than gifs.

func (*Client) TranslateGif

func (c *Client) TranslateGif(q string, rating string) (*Gif, error)

TranslateGif is prototype endpoint for using Giphy as a translation engine for a GIF dialect. The translate API draws on search, but uses the Giphy "special sauce" to handle translating from one vocabulary to another. In this case, words and phrases to GIFs. Returns a single GIF from the Giphy API.

func (*Client) TranslateSticker

func (c *Client) TranslateSticker(q string, rating string) (*Gif, error)

TranslateSticker replicates the functionality and requirements of the classic Giphy translate endpoint, but returns animated stickers rather than gifs.

func (*Client) TrendingGifs

func (c *Client) TrendingGifs(rating string, limit int) ([]*Gif, error)

TrendingGifs fetches GIFs currently trending online. The data returned mirrors that used to create The Hot 100 list of GIFs on Giphy.

func (*Client) TrendingStickers

func (c *Client) TrendingStickers(rating string, limit int) ([]*Gif, error)

TrendingStickers replicates the functionality and requirements of the classic Giphy trending endpoint, but returns animated stickers rather than gifs.

type ClientOptions

type ClientOptions struct {
	ApiKey      string
	ApiEndpoint string
	HttpClient  *http.Client
}

ClientOptions is used when initialising a new `Client` instance via the `NewClient` function. All values are optional.

type Gif

type Gif struct {
	Type               string `json:"type"`
	Id                 string `json:"id"`
	URL                string `json:"url"`
	Tags               string `json:"tags"`
	BitlyGifURL        string `json:"bitly_gif_url"`
	BitlyFullscreenURL string `json:"bitly_fullscreen_url"`
	BitlyTiledURL      string `json:"bitly_tiled_url"`
	Images             struct {
		Original               ImageData `json:"original"`
		FixedHeight            ImageData `json:"fixed_height"`
		FixedHeightStill       ImageData `json:"fixed_height_still"`
		FixedHeightDownsampled ImageData `json:"fixed_height_downsampled"`
		FixedWidth             ImageData `json:"fixed_width"`
		FixedwidthStill        ImageData `json:"fixed_width_still"`
		FixedwidthDownsampled  ImageData `json:"fixed_width_downsampled"`
	} `json:"images"`
}

type ImageData

type ImageData struct {
	URL    string `json:"url"`
	Width  string `json:"width"`
	Height string `json:"height"`
	Size   string `json:"size"`
	Frames string `json:"frames"`
}

Directories

Path Synopsis
Utilities for spinning up/down a HTTP server for use during tests.
Utilities for spinning up/down a HTTP server for use during tests.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL