Giphy API client for iOS in Objective-C

Overview

Giphy-iOS

Version License Platform

Giphy-iOS is a Giphy API client for iOS in Objective-C.

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

You should read about Giphy's Access and API keys here.

Giphy-iOS / AXCGiphy

'AXCGiphy' provides convenient access to Giphy's API endpoints:

  • search
  • trending
  • translate
  • GIF by ID
  • GIFs by IDs

You can query the endpoints through the blocks based interface:

- (void)viewDidLoad
{
    [super viewDidLoad];
	// set your API key before making any requests. You may use kGiphyPublicAPIKey for development.
    [AXCGiphy setGiphyAPIKey:kGiphyPublicAPIKey];

    [AXCGiphy searchGiphyWithTerm:@"frogs" limit:10 offset:0 completion:^(NSArray *results, NSError *error) {
        self.giphyResults = results;
        [[NSOperationQueue mainQueue] addOperationWithBlock:^{
            [self.collectionView reloadData];
        }];
    }];
}


- (UICollectionViewCell *) collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    AXCCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:kCollectionViewCellIdentifier forIndexPath:indexPath];
    AXCGiphy * gif = self.giphyResults[indexPath.item];
    
    NSURLRequest * request = [NSURLRequest requestWithURL:gif.originalImage.url];
    [[[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
        UIImage * image = [UIImage imageWithData:data];
        [[NSOperationQueue mainQueue] addOperationWithBlock:^{
            cell.imageView.image = image;
        }];
    }] resume];
    
    return cell;
}

AXCGiphy blocks based class methods provide asynchronous access to either AXCGiphy instances or an NSArray of AXCGiphy instances. AXCGiphy instances represent Giphy's gifs and their metadata. However, AXCGiphy only provides URLs to gifs. How you use these URLs is up to you.

My example uses NSURLRequests with NSURLSession to fetch the image data at the URLs and mattt's AnimatedGifSerialization to decode the animated GIFs into animated UIImages. If you are unsure of how to proceed, use my example app as a starting point.

The blocks based class methods return NSURLSessionDataTasks for additional control, should you need it.

AXCGiphy also provides class methods to generate NSURLRequests for these endpoints.

Requirements

AFNetworking/Serialization 2.3.1

Installation

Giphy-iOS is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "Giphy-iOS"
pod 'AFNetworking/Serialization', '~> 2.3.1'

Author

Alex Choi, [email protected]

License

Giphy-iOS is available under the MIT license. See the LICENSE file for more info.

You might also like...
An Elegant Spotify Web API Library Written in Swift for iOS and macOS
An Elegant Spotify Web API Library Written in Swift for iOS and macOS

Written in Swift 4.2 Spartan is a lightweight, elegant, and easy to use Spotify Web API wrapper library for iOS and macOS written in Swift 3. Under th

Easy and powerful way to interact with VK API for iOS and macOS
Easy and powerful way to interact with VK API for iOS and macOS

Easy and powerful way to interact with VK API for iOS and macOS. Key features 😊 It's not ios-vk-sdk 😊 🍏 One library for iOS and mac OS 🍏 🤘 Fully

Twitter API for Cocoa developers

FHSTwitterEngine Twitter API for Cocoa developers Created by Nathaniel Symer FHSTwitterEngine can: Authenticate using OAuth and/or xAuth. Make a reque

Unified API Library for: Cloud Storage, Social Log-In, Social Interaction, Payment, Email, SMS, POIs, Video & Messaging.
Unified API Library for: Cloud Storage, Social Log-In, Social Interaction, Payment, Email, SMS, POIs, Video & Messaging.

Unified API Library for: Cloud Storage, Social Log-In, Social Interaction, Payment, Email, SMS, POIs, Video & Messaging. Included services are Dropbox, Google Drive, OneDrive, OneDrive for Business, Box, Egnyte, PayPal, Stripe, Google Places, Foursquare, Yelp, YouTube, Vimeo, Twitch, Facebook Messenger, Telegram, Line, Viber, Facebook, GitHub, Google+, LinkedIn, Slack, Twitter, Windows Live, Yahoo, Mailjet, Sendgrid, Twilio, Nexmo, Twizo.

A swift SDK for Medium's OAuth2 API

Medium SDK - Swift A library to allow access to Medium API for any Swift iOS application. Features Medium.com authorization & token handling Login sta

Swift Wrapper For Bittrex API

BittrexApiKit Swift client for Bittrex api. It support all APIs with most recent changes. more info here let api = Bittrex(apikey: "api key", secretke

An API wrapper for bitFlyer.

SwiftFlyer An API wrapper for bitFlyer that supports all providing API. API Document https://lightning.bitflyer.jp/docs Usage Public API Fetch a marke

A Swift library for the Forecast.io Dark Sky API
A Swift library for the Forecast.io Dark Sky API

Requirements To use ForecastIO, all you need is an API key for the Dark Sky API. ForecastIO supports iOS (≥9.0), macOS (≥10.10), watchOS (≥2.0), and t

A clima based app with use of API
A clima based app with use of API

Clima Our Goal It’s time to take our app development skills to the next level. We’re going to introduce you to the wonderful world of Application Prog

Comments
  • Pod update fail

    Pod update fail

    I think you can change the pod spec url from [email protected]:heyalexchoi/Giphy-iOS.git to https://github.com/heyalexchoi/Giphy-iOS.git, or people use you lib will get the fallowing error while installing the pod

    [!] /usr/bin/git clone [email protected]:heyalexchoi/Giphy-iOS.git /Users/liyipeng/Library/Caches/CocoaPods/GitHub/6c18fae873774676144b1767c5a5be1f87355cad --mirror

    Cloning into bare repository '/Users/liyipeng/Library/Caches/CocoaPods/GitHub/6c18fae873774676144b1767c5a5be1f87355cad'...

    Permission denied (publickey).

    thanks

    opened by SummerTree 1
  • Facing memory leak

    Facing memory leak

    I have integrated your code in my project. Used collection view to load all gif but it is taking too much time to load the gif and after few minutes app is getting crashed. Can you please help me out to resolve this issue?

    opened by igatishah 0
  • API won't return any data

    API won't return any data

    I am use this code: Can't get any data,

    [AXCGiphy searchGiphyWithTerm:@"frogs" limit:10 offset:0 completion:^(NSArray *results, NSError *error) { self.giphyResults = results; [[NSOperationQueue mainQueue] addOperationWithBlock:^{ [self.collectionView reloadData]; }]; }];

    but api Can't get any data.

    opened by brahmostech 0
Releases(0.1.1)
Owner
alex choi
hello this is alex
alex choi
A stable, mature and comprehensive Objective-C library for Twitter REST API 1.1

STTwitter A stable, mature and comprehensive Objective-C library for Twitter REST API 1.1 Like a FOSS version of Twitter Fabric TwitterKit, without th

Nicolas Seriot 1k Nov 30, 2022
An easy-to-use Objective-C wrapper for the Uber API (no longer supported)

UberKit UberKit is a simple Objective-C wrapper for the new Uber API . Installation Cocoapods UberKit is available through Cocoapods. To install it, s

Sachin Kesiraju 95 Jun 30, 2022
ObjectiveFlickr, a Flickr API framework for Objective-C

ObjectiveFlickr ObjectiveFlickr is a Flickr API framework designed for Mac and iPhone apps. OAuth Support ObjectiveFlickr now supports Flickr's new OA

Lukhnos Liu 714 Jan 9, 2023
Unofficial GitHub API client in Swift

Github.swift ❤️ Support my apps ❤️ Push Hero - pure Swift native macOS application to test push notifications PastePal - Pasteboard, note and shortcut

Khoa 184 Nov 25, 2022
Instagram API client written in Swift

SwiftInstagram is a wrapper for the Instagram API written in Swift. It allows you to authenticate users and request data from Instagram effortlessly.

Ander Goig 579 Dec 31, 2022
A Slack API Client for the Perfect Server-Side Swift Framework

PerfectSlackAPIClient is an API Client to access the Slack API from your Perfect Server Side Swift application. It is build on top of PerfectAPIClient

Cap.雪ノ下八幡 2 Dec 1, 2019
Wanikani-swift - Unofficial Swift client for the WaniKani API

WaniKani A Swift library and client for the WaniKani REST API. It currently supp

Aaron Sky 5 Oct 28, 2022
Swift client for Unsplash

Unsplash API client written in Swift. Unsplash offers 2 APIs: Source API (unlimited requests) Official API JSON API (5000 requests / hour) JSON API is

Modo 188 Nov 12, 2022
Unofficial Dribbble iOS wrapper allows you to integrate Dribble API into iOS application (Designer, Shot, Comment, User Story, Like, Follow)

DribbbleSDK DribbbleSDK is easy-to-use iOS wrapper for Dribbble SDK. We're working hard to complete the full coverage of available methods and make th

Agilie Team 74 Dec 2, 2020
A Swift wrapper for Foursquare API. iOS and OSX.

Das Quadrat Das Quadrat is Foursquare API wrapper written in Swift. Features Supports iOS and OSX. Covers all API endpoints. Authorization process imp

Constantine Fry 171 Jun 18, 2022