SlideShare une entreprise Scribd logo
1  sur  44
The Anatomy of Apps
How iPhone, Android & Facebook Apps Consume APIs

Ed Anuff
@edanuff

Sam Ramji
@sramji

Brian Mulloy
@landlessness                                       Apigee
                                                   @apigee
groups.google.com/group/api-craft
youtube.com/apigee
New!

       IRC Channel
         #api-craft
App    App             App       World of          API   Internal
               App                          API
User   Store         Developer    APIs            Team   Systems
Dogs API

/dogs

/owners



Authorization

OAuth 2.0




RESTful API Design - Second Edition
http://www.youtube.com/watch?v=QpAhXa12xvU
Build an iPhone App, an Android App and a
Facebook Web App*




*Ruby on Rails app hosted on Heroku
http://devcenter.heroku.com/articles/facebook
App    App             App       World of          API   Internal
               App                          API
User   Store         Developer    APIs            Team   Systems
Start with a basic HTTP request
Android

HttpClient client = new DefaultHttpClient();
HttpGet httpGet = new HttpGet("http://api.apizoo.com/v1/dogs");
HttpResponse response = client.execute(httpGet);



iOS

NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL
  URLWithString:@"http://api.apizoo.com/v1/dogs"]];
NSData *response = [NSURLConnection sendSynchronousRequest:request
  returningResponse:nil error:nil];



Ruby on Rails

require 'net/http'
response = Net::HTTP.get(‘api.apizoo.com/v1’, ‘/dogs’)
Parse the data
Android

JSONObject dogs = new JSONObject(response);




iOS

import "JSONKit.h"
NSDictionary *dogs = [response objectFromData];




Ruby on Rails

require 'yajl'
parser = Yajl::Parser.new
dogs = parser.parse(response) # returns a hash
Resource Object Mapping
Route
Map
Use
Android Spring Mobile




Route
requestEntity = new HttpEntity<Object>(requestHeaders);
ResponseEntity<Dog> responseEntity =
   restTemplate.exchange("http://api.apizoo.com/v1/dogs/15", HttpMethod.GET,
   requestEntity, Dog.class);
Android Spring Mobile




Map
// Handled with introspection
Android Spring Mobile




Use
Dog dog = responseEntity.getBody()
iOS RestKit

Route

#import <RestKit/RestKit.h>
RKObjectManager* manager = [RKObjectManager
   objectManagerWithBaseURL:@"http://api.apizoo.com/v1"];
RKDynamicRouter* router = [[RKDynamicRouter new] autorelease];
manager.router = router;

[router routeClass:[Dog class] toResourcePath:@"/dogs"
   forMethod:RKRequestMethodPOST];
[router routeClass:[Dog class] toResourcePath:@"/dogs/(dogID)"];
iOS RestKit



Map

@implementation Dog
+ (NSDictionary*)elementToPropertyMappings {
   return [NSDictionary dictionaryWithKeysAndObjects:
        @"name", @"color", nil];
}
@end
iOS RestKit


Use

Dog* dog = [Dog object];
dog.name = @"Rover";
Dog.color = @"red";

[[RKObjectManager sharedManager] postObject:dog delegate:self];

[[RKObjectManager sharedManager] deleteObject:dog delegate:self];
Ruby on Rails ActiveResource




Route

resource :dogs
Ruby on Rails ActiveResource




Map

class Dog < ActiveResource::Base
 self.site = "http://api.apizoo.com/v1"
end
Ruby on Rails ActiveResource




Use

dog = Dog.new name: ‘Rover’, color: ‘red’

dog.save

dog.destroy
Cache the response in a database
Android Jersey + Jackson




Usage
Roll your own
iOS RestKit + Core Data


Usage

#import <RestKit/CoreData/CoreData.h>
RKObjectManager* manager = [RKObjectManager
   objectManagerWithBaseURL:@"http://api.apizoo.com/v1"];
manager.objectStore = [RKManagedObjectStore
   objectStoreWithStoreFilename:@"DogApp.sqlite"];

@implementation Dog
 + (NSString*)primaryKeyProperty {
   return @"dogID";
 }
@end
Ruby on Rails ActiveResource + ActiveRecord


Usage

class DogResource < ActiveResource::Base
 self.site = http://api.apizoo.com/v1
end

class Dog < ActiveRecord::Base
 # the before methods call DogResource methods
 before_create :create_resource
 before_update :update_resource
 before_destroy :destroy_resource
end
Simple to do list
Problem: we want new capabilities in our app not
supported by APIs.
Usergrid - Data & Queries
http://www.youtube.com/watch?v=zLl56sU5Bt0
Android

usergrid_ sdk




iOS

Use RESTKit




Ruby on Rails

Probably not applicable
What about offline cases
Android

Roll your own


iOS

-(BOOL)reachable {
Reachability *r = [Reachability
    reachabilityWithHostName:@"api.apizoo.com/v1"];
NetworkStatus internetStatus = [r currentReachabilityStatus];
if(internetStatus == NotReachable) {
 return NO;
}
return YES;
}



Ruby on Rails

Probably not applicable
Get authorization out of the way




Assumption: the APIs we consume use OAuth 2
Android

Roll your own
iOS RestKit

RKObjectManager* objectManager = [RKObjectManager sharedManager];
objectManager.client.baseURL = @”api.apizoo.com/v1";
objectManager.client.OAuth2AccessToken = @"YOUR ACCESS TOKEN";
objectManager.client.authenticationType =
  RKRequestAuthenticationTypeOAuth2;
Ruby on Rails Oauth Gem

@consumer=OAuth::Consumer.new("key","secret", site: "api.apizoo.com/v1")
@request_token=@consumer.get_request_token
session[:request_token]=@request_token
redirect_to @request_token.authorize_url
@access_token=@request_token.get_access_token
Android
Built-in JSON, etc.
Spring Mobile (bundles Jersey & Jackson)

iOS
JSONKit
RestKit
Core Data

Ruby on Rails
YAJL
ActiveResource
Oauth
Coming Up: March Miniseries on Apps & APIs
Questions?
THANK YOU
Subscribe to API webinars at:
youtube.com/apigee
THANK YOU
Chat on IRC
#api-craft
THANK YOU
Questions and ideas to:
groups.google.com/group/api-craft
THANK YOU
Contact us at:

@edanuff
ed@apigee.com


@sramji
sramji@apigee.com

@landlessness
brian@apigee.com

Contenu connexe

En vedette

Visbility at the Edge - Deep Insights from Your API
 Visbility at the Edge - Deep Insights from Your API Visbility at the Edge - Deep Insights from Your API
Visbility at the Edge - Deep Insights from Your APIApigee | Google Cloud
 
Skeuomorphs, Databases, and Mobile Performance
Skeuomorphs, Databases, and Mobile PerformanceSkeuomorphs, Databases, and Mobile Performance
Skeuomorphs, Databases, and Mobile PerformanceApigee | Google Cloud
 
HTML5: The Apps, the Frameworks, the Controversy
HTML5: The Apps, the Frameworks, the Controversy HTML5: The Apps, the Frameworks, the Controversy
HTML5: The Apps, the Frameworks, the Controversy Apigee | Google Cloud
 
The API Facade Pattern: People - Episode 4
The API Facade Pattern: People - Episode 4The API Facade Pattern: People - Episode 4
The API Facade Pattern: People - Episode 4Apigee | Google Cloud
 
Crafting APIs for Mobile Apps - Everything You Need to Know
Crafting APIs for Mobile Apps - Everything You Need to KnowCrafting APIs for Mobile Apps - Everything You Need to Know
Crafting APIs for Mobile Apps - Everything You Need to KnowApigee | Google Cloud
 
Essential API Facade Patterns: One Phase to Two Phase Conversion (Episode 3)
Essential API Facade Patterns: One Phase to Two Phase Conversion (Episode 3)Essential API Facade Patterns: One Phase to Two Phase Conversion (Episode 3)
Essential API Facade Patterns: One Phase to Two Phase Conversion (Episode 3)Apigee | Google Cloud
 
Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episod...
Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episod...Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episod...
Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episod...Apigee | Google Cloud
 
Building your first Native iOs App with an API Backend
Building your first Native iOs App with an API BackendBuilding your first Native iOs App with an API Backend
Building your first Native iOs App with an API BackendApigee | Google Cloud
 
Driving Digital Success: Three ROI Criteria for Competitive Advantage
Driving Digital Success:  Three ROI Criteria for Competitive Advantage Driving Digital Success:  Three ROI Criteria for Competitive Advantage
Driving Digital Success: Three ROI Criteria for Competitive Advantage Apigee | Google Cloud
 
The API Facade Pattern: Common Patterns - Episode 2
The API Facade Pattern: Common Patterns - Episode 2The API Facade Pattern: Common Patterns - Episode 2
The API Facade Pattern: Common Patterns - Episode 2Apigee | Google Cloud
 
The New 3-Tier Architecture: HTML5, Proxies, and APIs
The New 3-Tier Architecture: HTML5, Proxies, and APIsThe New 3-Tier Architecture: HTML5, Proxies, and APIs
The New 3-Tier Architecture: HTML5, Proxies, and APIsApigee | Google Cloud
 
Essential API Facade Patterns: Session Management (Episode 2)
Essential API Facade Patterns: Session Management (Episode 2)Essential API Facade Patterns: Session Management (Episode 2)
Essential API Facade Patterns: Session Management (Episode 2)Apigee | Google Cloud
 
The Walgreens Story: Putting an API Around Their Stores (Webcast)
The Walgreens Story: Putting an API Around Their Stores (Webcast)The Walgreens Story: Putting an API Around Their Stores (Webcast)
The Walgreens Story: Putting an API Around Their Stores (Webcast)Apigee | Google Cloud
 
Telco Innovation with APIs - Need for speed (Webcast)
Telco Innovation with APIs - Need for speed (Webcast) Telco Innovation with APIs - Need for speed (Webcast)
Telco Innovation with APIs - Need for speed (Webcast) Apigee | Google Cloud
 
APIs Inside Enterprise - SOA Displacement?
APIs Inside Enterprise - SOA Displacement?APIs Inside Enterprise - SOA Displacement?
APIs Inside Enterprise - SOA Displacement?Apigee | Google Cloud
 
DevOps & Apps - Building and Operating Successful Mobile Apps
DevOps & Apps - Building and Operating Successful Mobile AppsDevOps & Apps - Building and Operating Successful Mobile Apps
DevOps & Apps - Building and Operating Successful Mobile AppsApigee | Google Cloud
 
Economic Models for Reinventing Telco - Innovation with APIs
Economic Models for Reinventing Telco - Innovation with APIsEconomic Models for Reinventing Telco - Innovation with APIs
Economic Models for Reinventing Telco - Innovation with APIsApigee | Google Cloud
 
API Management for Software Defined Network (SDN)
API Management for Software Defined Network (SDN)API Management for Software Defined Network (SDN)
API Management for Software Defined Network (SDN)Apigee | Google Cloud
 
OData Introduction and Impact on API Design (Webcast)
OData Introduction and Impact on API Design (Webcast)OData Introduction and Impact on API Design (Webcast)
OData Introduction and Impact on API Design (Webcast)Apigee | Google Cloud
 

En vedette (20)

Visbility at the Edge - Deep Insights from Your API
 Visbility at the Edge - Deep Insights from Your API Visbility at the Edge - Deep Insights from Your API
Visbility at the Edge - Deep Insights from Your API
 
Skeuomorphs, Databases, and Mobile Performance
Skeuomorphs, Databases, and Mobile PerformanceSkeuomorphs, Databases, and Mobile Performance
Skeuomorphs, Databases, and Mobile Performance
 
HTML5: The Apps, the Frameworks, the Controversy
HTML5: The Apps, the Frameworks, the Controversy HTML5: The Apps, the Frameworks, the Controversy
HTML5: The Apps, the Frameworks, the Controversy
 
The API Facade Pattern: People - Episode 4
The API Facade Pattern: People - Episode 4The API Facade Pattern: People - Episode 4
The API Facade Pattern: People - Episode 4
 
Crafting APIs for Mobile Apps - Everything You Need to Know
Crafting APIs for Mobile Apps - Everything You Need to KnowCrafting APIs for Mobile Apps - Everything You Need to Know
Crafting APIs for Mobile Apps - Everything You Need to Know
 
Essential API Facade Patterns: One Phase to Two Phase Conversion (Episode 3)
Essential API Facade Patterns: One Phase to Two Phase Conversion (Episode 3)Essential API Facade Patterns: One Phase to Two Phase Conversion (Episode 3)
Essential API Facade Patterns: One Phase to Two Phase Conversion (Episode 3)
 
Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episod...
Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episod...Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episod...
Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episod...
 
Building your first Native iOs App with an API Backend
Building your first Native iOs App with an API BackendBuilding your first Native iOs App with an API Backend
Building your first Native iOs App with an API Backend
 
Driving Digital Success: Three ROI Criteria for Competitive Advantage
Driving Digital Success:  Three ROI Criteria for Competitive Advantage Driving Digital Success:  Three ROI Criteria for Competitive Advantage
Driving Digital Success: Three ROI Criteria for Competitive Advantage
 
The API Facade Pattern: Common Patterns - Episode 2
The API Facade Pattern: Common Patterns - Episode 2The API Facade Pattern: Common Patterns - Episode 2
The API Facade Pattern: Common Patterns - Episode 2
 
The New 3-Tier Architecture: HTML5, Proxies, and APIs
The New 3-Tier Architecture: HTML5, Proxies, and APIsThe New 3-Tier Architecture: HTML5, Proxies, and APIs
The New 3-Tier Architecture: HTML5, Proxies, and APIs
 
Essential API Facade Patterns: Session Management (Episode 2)
Essential API Facade Patterns: Session Management (Episode 2)Essential API Facade Patterns: Session Management (Episode 2)
Essential API Facade Patterns: Session Management (Episode 2)
 
The Walgreens Story: Putting an API Around Their Stores (Webcast)
The Walgreens Story: Putting an API Around Their Stores (Webcast)The Walgreens Story: Putting an API Around Their Stores (Webcast)
The Walgreens Story: Putting an API Around Their Stores (Webcast)
 
Telco Innovation with APIs - Need for speed (Webcast)
Telco Innovation with APIs - Need for speed (Webcast) Telco Innovation with APIs - Need for speed (Webcast)
Telco Innovation with APIs - Need for speed (Webcast)
 
APIs Inside Enterprise - SOA Displacement?
APIs Inside Enterprise - SOA Displacement?APIs Inside Enterprise - SOA Displacement?
APIs Inside Enterprise - SOA Displacement?
 
DevOps & Apps - Building and Operating Successful Mobile Apps
DevOps & Apps - Building and Operating Successful Mobile AppsDevOps & Apps - Building and Operating Successful Mobile Apps
DevOps & Apps - Building and Operating Successful Mobile Apps
 
Economic Models for Reinventing Telco - Innovation with APIs
Economic Models for Reinventing Telco - Innovation with APIsEconomic Models for Reinventing Telco - Innovation with APIs
Economic Models for Reinventing Telco - Innovation with APIs
 
API Management for Software Defined Network (SDN)
API Management for Software Defined Network (SDN)API Management for Software Defined Network (SDN)
API Management for Software Defined Network (SDN)
 
OData Introduction and Impact on API Design (Webcast)
OData Introduction and Impact on API Design (Webcast)OData Introduction and Impact on API Design (Webcast)
OData Introduction and Impact on API Design (Webcast)
 
APIs & Copyrights
APIs & CopyrightsAPIs & Copyrights
APIs & Copyrights
 

Similaire à The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs

Design & Deploy a data-driven Web API in 2 hours
Design & Deploy a data-driven Web API in 2 hoursDesign & Deploy a data-driven Web API in 2 hours
Design & Deploy a data-driven Web API in 2 hoursRestlet
 
iOS Swift application architecture
iOS Swift application architectureiOS Swift application architecture
iOS Swift application architectureRomain Rochegude
 
Lecture 12 - Maps, AR_VR_aaaaHardware.pptx
Lecture 12 - Maps, AR_VR_aaaaHardware.pptxLecture 12 - Maps, AR_VR_aaaaHardware.pptx
Lecture 12 - Maps, AR_VR_aaaaHardware.pptxNgLQun
 
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram VaswaniCreating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswanivvaswani
 
Playing with parse.com
Playing with parse.comPlaying with parse.com
Playing with parse.comJUG Genova
 
All a flutter about Flutter.io
All a flutter about Flutter.ioAll a flutter about Flutter.io
All a flutter about Flutter.ioSteven Cooper
 
Using Ruby in Android Development
Using Ruby in Android DevelopmentUsing Ruby in Android Development
Using Ruby in Android DevelopmentAdam Blum
 
Java Libraries You Can’t Afford to Miss
Java Libraries You Can’t Afford to Miss Java Libraries You Can’t Afford to Miss
Java Libraries You Can’t Afford to Miss Andres Almiray
 
Appium Overview - by Daniel Puterman
Appium Overview - by Daniel PutermanAppium Overview - by Daniel Puterman
Appium Overview - by Daniel PutermanApplitools
 
Building Better Web APIs with Rails
Building Better Web APIs with RailsBuilding Better Web APIs with Rails
Building Better Web APIs with RailsAll Things Open
 
Retrofit Library In Android
Retrofit Library In AndroidRetrofit Library In Android
Retrofit Library In AndroidInnovationM
 
Java Libraries You Can't Afford to Miss
Java Libraries You Can't Afford to MissJava Libraries You Can't Afford to Miss
Java Libraries You Can't Afford to MissAndres Almiray
 
Android & iOS Automation Using Appium
Android & iOS Automation Using AppiumAndroid & iOS Automation Using Appium
Android & iOS Automation Using AppiumMindfire Solutions
 
App engine ja night 9 beertalk2
App engine ja night 9 beertalk2App engine ja night 9 beertalk2
App engine ja night 9 beertalk2SATOSHI TAGOMORI
 
Android Workshop
Android WorkshopAndroid Workshop
Android WorkshopJunda Ong
 

Similaire à The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs (20)

Bpstudy20101221
Bpstudy20101221Bpstudy20101221
Bpstudy20101221
 
Design & Deploy a data-driven Web API in 2 hours
Design & Deploy a data-driven Web API in 2 hoursDesign & Deploy a data-driven Web API in 2 hours
Design & Deploy a data-driven Web API in 2 hours
 
iOS Swift application architecture
iOS Swift application architectureiOS Swift application architecture
iOS Swift application architecture
 
Lecture 12 - Maps, AR_VR_aaaaHardware.pptx
Lecture 12 - Maps, AR_VR_aaaaHardware.pptxLecture 12 - Maps, AR_VR_aaaaHardware.pptx
Lecture 12 - Maps, AR_VR_aaaaHardware.pptx
 
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram VaswaniCreating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswani
 
Playing with parse.com
Playing with parse.comPlaying with parse.com
Playing with parse.com
 
All a flutter about Flutter.io
All a flutter about Flutter.ioAll a flutter about Flutter.io
All a flutter about Flutter.io
 
Using Ruby in Android Development
Using Ruby in Android DevelopmentUsing Ruby in Android Development
Using Ruby in Android Development
 
Java Libraries You Can’t Afford to Miss
Java Libraries You Can’t Afford to Miss Java Libraries You Can’t Afford to Miss
Java Libraries You Can’t Afford to Miss
 
Appium Overview - by Daniel Puterman
Appium Overview - by Daniel PutermanAppium Overview - by Daniel Puterman
Appium Overview - by Daniel Puterman
 
Android intermediatte Full
Android intermediatte FullAndroid intermediatte Full
Android intermediatte Full
 
REST API for your WP7 App
REST API for your WP7 AppREST API for your WP7 App
REST API for your WP7 App
 
Oracle APEX & PhoneGap
Oracle APEX & PhoneGapOracle APEX & PhoneGap
Oracle APEX & PhoneGap
 
Building Better Web APIs with Rails
Building Better Web APIs with RailsBuilding Better Web APIs with Rails
Building Better Web APIs with Rails
 
Retrofit Library In Android
Retrofit Library In AndroidRetrofit Library In Android
Retrofit Library In Android
 
Java Libraries You Can't Afford to Miss
Java Libraries You Can't Afford to MissJava Libraries You Can't Afford to Miss
Java Libraries You Can't Afford to Miss
 
Android & iOS Automation Using Appium
Android & iOS Automation Using AppiumAndroid & iOS Automation Using Appium
Android & iOS Automation Using Appium
 
Appium
AppiumAppium
Appium
 
App engine ja night 9 beertalk2
App engine ja night 9 beertalk2App engine ja night 9 beertalk2
App engine ja night 9 beertalk2
 
Android Workshop
Android WorkshopAndroid Workshop
Android Workshop
 

Plus de Apigee | Google Cloud

Monetization: Unlock More Value from Your APIs
Monetization: Unlock More Value from Your APIs Monetization: Unlock More Value from Your APIs
Monetization: Unlock More Value from Your APIs Apigee | Google Cloud
 
AccuWeather: Recasting API Experiences in a Developer-First World
AccuWeather: Recasting API Experiences in a Developer-First WorldAccuWeather: Recasting API Experiences in a Developer-First World
AccuWeather: Recasting API Experiences in a Developer-First WorldApigee | Google Cloud
 
Which Application Modernization Pattern Is Right For You?
Which Application Modernization Pattern Is Right For You?Which Application Modernization Pattern Is Right For You?
Which Application Modernization Pattern Is Right For You?Apigee | Google Cloud
 
The Four Transformative Forces of the API Management Market
The Four Transformative Forces of the API Management MarketThe Four Transformative Forces of the API Management Market
The Four Transformative Forces of the API Management MarketApigee | Google Cloud
 
Managing the Complexity of Microservices Deployments
Managing the Complexity of Microservices DeploymentsManaging the Complexity of Microservices Deployments
Managing the Complexity of Microservices DeploymentsApigee | Google Cloud
 
Microservices Done Right: Key Ingredients for Microservices Success
Microservices Done Right: Key Ingredients for Microservices SuccessMicroservices Done Right: Key Ingredients for Microservices Success
Microservices Done Right: Key Ingredients for Microservices SuccessApigee | Google Cloud
 
Adapt or Die: Opening Keynote with Chet Kapoor
Adapt or Die: Opening Keynote with Chet KapoorAdapt or Die: Opening Keynote with Chet Kapoor
Adapt or Die: Opening Keynote with Chet KapoorApigee | Google Cloud
 
Adapt or Die: Keynote with Greg Brail
Adapt or Die: Keynote with Greg BrailAdapt or Die: Keynote with Greg Brail
Adapt or Die: Keynote with Greg BrailApigee | Google Cloud
 
Adapt or Die: Keynote with Anant Jhingran
Adapt or Die: Keynote with Anant JhingranAdapt or Die: Keynote with Anant Jhingran
Adapt or Die: Keynote with Anant JhingranApigee | Google Cloud
 
London Adapt or Die: Closing Keynote — Adapt Now!
London Adapt or Die: Closing Keynote — Adapt Now!London Adapt or Die: Closing Keynote — Adapt Now!
London Adapt or Die: Closing Keynote — Adapt Now!Apigee | Google Cloud
 

Plus de Apigee | Google Cloud (20)

How Secure Are Your APIs?
How Secure Are Your APIs?How Secure Are Your APIs?
How Secure Are Your APIs?
 
Magazine Luiza at a glance (1)
Magazine Luiza at a glance (1)Magazine Luiza at a glance (1)
Magazine Luiza at a glance (1)
 
Monetization: Unlock More Value from Your APIs
Monetization: Unlock More Value from Your APIs Monetization: Unlock More Value from Your APIs
Monetization: Unlock More Value from Your APIs
 
Apigee Demo: API Platform Overview
Apigee Demo: API Platform OverviewApigee Demo: API Platform Overview
Apigee Demo: API Platform Overview
 
Ticketmaster at a glance
Ticketmaster at a glanceTicketmaster at a glance
Ticketmaster at a glance
 
AccuWeather: Recasting API Experiences in a Developer-First World
AccuWeather: Recasting API Experiences in a Developer-First WorldAccuWeather: Recasting API Experiences in a Developer-First World
AccuWeather: Recasting API Experiences in a Developer-First World
 
Which Application Modernization Pattern Is Right For You?
Which Application Modernization Pattern Is Right For You?Which Application Modernization Pattern Is Right For You?
Which Application Modernization Pattern Is Right For You?
 
Apigee Product Roadmap Part 2
Apigee Product Roadmap Part 2Apigee Product Roadmap Part 2
Apigee Product Roadmap Part 2
 
The Four Transformative Forces of the API Management Market
The Four Transformative Forces of the API Management MarketThe Four Transformative Forces of the API Management Market
The Four Transformative Forces of the API Management Market
 
Walgreens at a glance
Walgreens at a glanceWalgreens at a glance
Walgreens at a glance
 
Apigee Edge: Intro to Microgateway
Apigee Edge: Intro to MicrogatewayApigee Edge: Intro to Microgateway
Apigee Edge: Intro to Microgateway
 
Managing the Complexity of Microservices Deployments
Managing the Complexity of Microservices DeploymentsManaging the Complexity of Microservices Deployments
Managing the Complexity of Microservices Deployments
 
Pitney Bowes at a glance
Pitney Bowes at a glancePitney Bowes at a glance
Pitney Bowes at a glance
 
Microservices Done Right: Key Ingredients for Microservices Success
Microservices Done Right: Key Ingredients for Microservices SuccessMicroservices Done Right: Key Ingredients for Microservices Success
Microservices Done Right: Key Ingredients for Microservices Success
 
Adapt or Die: Opening Keynote with Chet Kapoor
Adapt or Die: Opening Keynote with Chet KapoorAdapt or Die: Opening Keynote with Chet Kapoor
Adapt or Die: Opening Keynote with Chet Kapoor
 
Adapt or Die: Keynote with Greg Brail
Adapt or Die: Keynote with Greg BrailAdapt or Die: Keynote with Greg Brail
Adapt or Die: Keynote with Greg Brail
 
Adapt or Die: Keynote with Anant Jhingran
Adapt or Die: Keynote with Anant JhingranAdapt or Die: Keynote with Anant Jhingran
Adapt or Die: Keynote with Anant Jhingran
 
London Adapt or Die: Opening Keynot
London Adapt or Die: Opening KeynotLondon Adapt or Die: Opening Keynot
London Adapt or Die: Opening Keynot
 
London Adapt or Die: Lunch keynote
London Adapt or Die: Lunch keynoteLondon Adapt or Die: Lunch keynote
London Adapt or Die: Lunch keynote
 
London Adapt or Die: Closing Keynote — Adapt Now!
London Adapt or Die: Closing Keynote — Adapt Now!London Adapt or Die: Closing Keynote — Adapt Now!
London Adapt or Die: Closing Keynote — Adapt Now!
 

Dernier

WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 

Dernier (20)

WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 

The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs

  • 1. The Anatomy of Apps How iPhone, Android & Facebook Apps Consume APIs Ed Anuff @edanuff Sam Ramji @sramji Brian Mulloy @landlessness Apigee @apigee
  • 4. New! IRC Channel #api-craft
  • 5. App App App World of API Internal App API User Store Developer APIs Team Systems
  • 6. Dogs API /dogs /owners Authorization OAuth 2.0 RESTful API Design - Second Edition http://www.youtube.com/watch?v=QpAhXa12xvU
  • 7. Build an iPhone App, an Android App and a Facebook Web App* *Ruby on Rails app hosted on Heroku http://devcenter.heroku.com/articles/facebook
  • 8. App App App World of API Internal App API User Store Developer APIs Team Systems
  • 9. Start with a basic HTTP request
  • 10. Android HttpClient client = new DefaultHttpClient(); HttpGet httpGet = new HttpGet("http://api.apizoo.com/v1/dogs"); HttpResponse response = client.execute(httpGet); iOS NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://api.apizoo.com/v1/dogs"]]; NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil]; Ruby on Rails require 'net/http' response = Net::HTTP.get(‘api.apizoo.com/v1’, ‘/dogs’)
  • 12. Android JSONObject dogs = new JSONObject(response); iOS import "JSONKit.h" NSDictionary *dogs = [response objectFromData]; Ruby on Rails require 'yajl' parser = Yajl::Parser.new dogs = parser.parse(response) # returns a hash
  • 15. Android Spring Mobile Route requestEntity = new HttpEntity<Object>(requestHeaders); ResponseEntity<Dog> responseEntity = restTemplate.exchange("http://api.apizoo.com/v1/dogs/15", HttpMethod.GET, requestEntity, Dog.class);
  • 16. Android Spring Mobile Map // Handled with introspection
  • 17. Android Spring Mobile Use Dog dog = responseEntity.getBody()
  • 18. iOS RestKit Route #import <RestKit/RestKit.h> RKObjectManager* manager = [RKObjectManager objectManagerWithBaseURL:@"http://api.apizoo.com/v1"]; RKDynamicRouter* router = [[RKDynamicRouter new] autorelease]; manager.router = router; [router routeClass:[Dog class] toResourcePath:@"/dogs" forMethod:RKRequestMethodPOST]; [router routeClass:[Dog class] toResourcePath:@"/dogs/(dogID)"];
  • 19. iOS RestKit Map @implementation Dog + (NSDictionary*)elementToPropertyMappings { return [NSDictionary dictionaryWithKeysAndObjects: @"name", @"color", nil]; } @end
  • 20. iOS RestKit Use Dog* dog = [Dog object]; dog.name = @"Rover"; Dog.color = @"red"; [[RKObjectManager sharedManager] postObject:dog delegate:self]; [[RKObjectManager sharedManager] deleteObject:dog delegate:self];
  • 21. Ruby on Rails ActiveResource Route resource :dogs
  • 22. Ruby on Rails ActiveResource Map class Dog < ActiveResource::Base self.site = "http://api.apizoo.com/v1" end
  • 23. Ruby on Rails ActiveResource Use dog = Dog.new name: ‘Rover’, color: ‘red’ dog.save dog.destroy
  • 24. Cache the response in a database
  • 25. Android Jersey + Jackson Usage Roll your own
  • 26. iOS RestKit + Core Data Usage #import <RestKit/CoreData/CoreData.h> RKObjectManager* manager = [RKObjectManager objectManagerWithBaseURL:@"http://api.apizoo.com/v1"]; manager.objectStore = [RKManagedObjectStore objectStoreWithStoreFilename:@"DogApp.sqlite"]; @implementation Dog + (NSString*)primaryKeyProperty { return @"dogID"; } @end
  • 27. Ruby on Rails ActiveResource + ActiveRecord Usage class DogResource < ActiveResource::Base self.site = http://api.apizoo.com/v1 end class Dog < ActiveRecord::Base # the before methods call DogResource methods before_create :create_resource before_update :update_resource before_destroy :destroy_resource end
  • 28. Simple to do list
  • 29. Problem: we want new capabilities in our app not supported by APIs.
  • 30. Usergrid - Data & Queries http://www.youtube.com/watch?v=zLl56sU5Bt0
  • 31. Android usergrid_ sdk iOS Use RESTKit Ruby on Rails Probably not applicable
  • 33. Android Roll your own iOS -(BOOL)reachable { Reachability *r = [Reachability reachabilityWithHostName:@"api.apizoo.com/v1"]; NetworkStatus internetStatus = [r currentReachabilityStatus]; if(internetStatus == NotReachable) { return NO; } return YES; } Ruby on Rails Probably not applicable
  • 34. Get authorization out of the way Assumption: the APIs we consume use OAuth 2
  • 36. iOS RestKit RKObjectManager* objectManager = [RKObjectManager sharedManager]; objectManager.client.baseURL = @”api.apizoo.com/v1"; objectManager.client.OAuth2AccessToken = @"YOUR ACCESS TOKEN"; objectManager.client.authenticationType = RKRequestAuthenticationTypeOAuth2;
  • 37. Ruby on Rails Oauth Gem @consumer=OAuth::Consumer.new("key","secret", site: "api.apizoo.com/v1") @request_token=@consumer.get_request_token session[:request_token]=@request_token redirect_to @request_token.authorize_url @access_token=@request_token.get_access_token
  • 38. Android Built-in JSON, etc. Spring Mobile (bundles Jersey & Jackson) iOS JSONKit RestKit Core Data Ruby on Rails YAJL ActiveResource Oauth
  • 39. Coming Up: March Miniseries on Apps & APIs
  • 41. THANK YOU Subscribe to API webinars at: youtube.com/apigee
  • 42. THANK YOU Chat on IRC #api-craft
  • 43. THANK YOU Questions and ideas to: groups.google.com/group/api-craft
  • 44. THANK YOU Contact us at: @edanuff ed@apigee.com @sramji sramji@apigee.com @landlessness brian@apigee.com

Notes de l'éditeur

  1. Creative Commons Attribution-Share Alike 3.0 United States License
  2. Android &amp; iOS default response is a hash/dictionaryRuby on Rails
  3. Android &amp; iOS default response is a hash/dictionaryRuby on Rails
  4. Android &amp; iOS default response is a hash/dictionaryRuby on Rails
  5. Android &amp; iOS default response is a hash/dictionaryRuby on Rails
  6. Android &amp; iOS default response is a hash/dictionaryRuby on Rails
  7. Android &amp; iOS default response is a hash/dictionaryRuby on Rails
  8. Android &amp; iOS default response is a hash/dictionaryRuby on Rails
  9. Android &amp; iOS default response is a hash/dictionaryRuby on Rails
  10. Android &amp; iOS default response is a hash/dictionaryRuby on Rails
  11. Android &amp; iOS default response is a hash/dictionaryRuby on Rails
  12. Android &amp; iOS default response is a hash/dictionaryRuby on Rails
  13. Android &amp; iOS default response is a hash/dictionaryRuby on Rails
  14. Android &amp; iOS default response is a hash/dictionaryRuby on Rails
  15. iOSFun factoid: the app store will reject your app if you don’t properly test your app using the reachability APIAndroidSearch around for Reachability - Connectivity Manager
  16. If you provide and consume the api then auth is what u make it.Oauth 2 is a standard but not too heavyAbout 70% of the reason folks go to a special purpose built client library is auth, the second is object marshaling.The standard clients start to screw you over…Parameter signing are a nightmare for the app developer. RestKit
  17. AndroidSUN JerseySpring MobileTradeoffs are around the App SizeForOauth: do the flow with the web browser but oauth 2 is a really pragmatic spec you can also pass a username and password. It will be up to the app. Client id and the client token. Get back an access token either in the header or as a param.
  18. AndroidSUN JerseySpring MobileTradeoffs are around the App SizeForOauth: do the flow with the web browser but oauth 2 is a really pragmatic spec you can also pass a username and password. It will be up to the app. Client id and the client token. Get back an access token either in the header or as a param.