SlideShare ist ein Scribd-Unternehmen logo
1 von 32
Downloaden Sie, um offline zu lesen
Nordic APIs Tour 2014
Holger Reinhardt
@hlgr360
holger.reinhardt@ca.com
http://www.flickr.com/photos/jurvetson/21470089/
You	
  want	
  a	
  Library	
  	
  
with	
  that	
  (API)?	
  
Designing	
  an	
  API	
  is	
  easy	
  	
  
Effec%ve	
  API	
  design	
  is	
  difficult	
  
•  Informaton
•  Product
•  Service
Business
Asset
•  API
•  SLA
•  EULA
API Provider
•  Building
App
Developer
•  Using API
Application
•  Using App
End-User
The	
  API	
  Value	
  Chain	
  
•  Informaton
•  Product
•  Service
Business
Asset
•  API
•  SLA
•  EULA
API Provider
•  Building
App
Developer
•  Using API
Application
•  Using App
End-User
Effec%ve	
  API	
  Design	
  
And	
  this	
  is	
  when	
  Someone	
  usually	
  asks	
  
A	
  story	
  about	
  two	
  APIs	
  
I	
  love	
  it	
  
I	
  wanted	
  Javascript,	
  but	
  got	
  PHP	
  
I	
  wanted	
  Client-­‐side,	
  but	
  got	
  Server-­‐side	
  
- need to install peck or pearl on my Mac
http://pear.php.net/manual/en/installation.getting.php
- went back to documentation to install oauth
extension, needed autoconf - tried another way
http://stackoverflow.com/questions/5536195/install-pecl-
on-mac-os-x-10-6
- still required autoconf
http://mac-dev-env.patrickbougie.com/autoconf/
-  Error: PECL: configuration option "php_ini" is
not set to php.ini location
http://arcadian83.livejournal.com/16386.html
=> Ready to run php lib from fitbit website
- Enable php
http://editrocket.com/articles/php_apache_mac.html
- Enable apache server
http://reviews.cnet.com/8301-13727_7-57481978-263/how-to-
enable-web-sharing-in-os-x-mountain-lion/
-  sudo apachectl start
=> Ready to start playing with the php lib
small	
  annoyances	
  add	
  up	
  	
  
to	
  create	
  a	
  poor	
  experience	
  
And	
  that	
  PHP	
  code	
  looks	
  complex	
  
<?php
// Base URL
$baseUrl = 'http://api.fitbit.com';
// Request token path
$req_url = $baseUrl . '/oauth/request_token';
// Authorization path
$authurl = $baseUrl . '/oauth/authorize';
// Access token path
$acc_url = $baseUrl . '/oauth/access_token';
// Consumer key
$conskey = 'local-fitbit-example-php-client-application';
// Consumer secret
$conssec = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
// Fitbit API call (get activities for specified date)
$apiCall = "http://api.fitbit.com/1/user/-/activities/date/2014-01-25.xml";
// HR: callback url
$callbackUrl = "http://localhost/~h_reinhardt/fitbit/php/
completeAuthorization.php";
// Start session to store the information between calls
session_start();
// In state=1 the next request should include an oauth_token.
// If it doesn't go back to 0
if ( !isset($_GET['oauth_token']) && $_SESSION['state']==1 )
$_SESSION['state'] = 0;
try
{
// Create OAuth object
$oauth = new OAuth($conskey,
$conssec,OAUTH_SIG_METHOD_HMACSHA1,OAUTH_AUTH_TYPE_AUT
HORIZATION);
// Enable ouath debug (should be disabled in production)
$oauth->enableDebug();
if ( $_SESSION['state'] == 0 )
{
// Getting request token. Callback URL is the Absolute URL to which
the server provder will redirect the User back when the obtaining user
authorization step is completed.
$request_token_info = $oauth->getRequestToken($req_url,
$callbackUrl);
// Storing key and state in a session.
$_SESSION['secret'] = $request_token_info['oauth_token_secret'];
$_SESSION['state'] = 1;
// Redirect to the authorization.
header('Location: '.$authurl.'?oauth_token='.
$request_token_info['oauth_token']);
exit;
}
else if ( $_SESSION['state']==1 )
{
// Authorized. Getting access token and secret
$oauth->setToken($_GET['oauth_token'],$_SESSION['secret']);
$access_token_info = $oauth->getAccessToken($acc_url);
// Storing key and state in a session.
$_SESSION['state'] = 2;
$_SESSION['token'] = $access_token_info['oauth_token'];
$_SESSION['secret'] = $access_token_info['oauth_token_secret'];
}
// Setting asccess token to the OAuth object
$oauth->setToken($_SESSION['token'],$_SESSION['secret']);
// Performing API call
$oauth->fetch($apiCall);
// Getting last response
$response = $oauth->getLastResponse();
// Initializing the simple_xml object using API response
But	
  that	
  SDK	
  looks	
  sHcky	
  and	
  heavy	
  
<?php
require 'php-sdk/src/temboo.php';
// Instantiate the Choreo, using a previously instantiated Temboo_Session
object, eg:
// $session = new Temboo_Session('hlgr360', 'APP_NAME', 'APP_KEY');
$session = new Temboo_Session('hlgr360', 'myFirstApp',
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
$getActivities = new Fitbit_Activities_GetActivities($session);
// Get an input object for the Choreo
$getActivitiesInputs = $getActivities->newInputs();
// Set credential to use for execution
$getActivitiesInputs->setCredential('apiacademy');
// Set inputs
$getActivitiesInputs->setDate("2014-01-25")->setResponseFormat("xml");
// Execute Choreo and get results
$getActivitiesResults = $getActivities->execute($getActivitiesInputs)-
>getResults();
// Initializing the simple_xml object using API response
$xml = simplexml_load_string($getActivitiesResults->getResponse());
?>
$(document).ready( function () {
OAuth.initialize(’xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx’);
// Using popup (option 1)
OAuth.popup('fitbit', function(error, result) {
if (error) {
console.log(err); // do something with error
return;
};
result.get("/1/user/-/profile.json").done(function(res) {
console.log("Hello, ", res);
var $img = $("<img>",{src: res.user.avatar});
$(".avatar").append($img);
$(".name").append(res.user.fullName);
$(".dateofbirth").append(res.user.dateOfBirth);
$(".metric").append(res.user.distanceUnit);
$(".stridewalking").append(res.user.strideLengthWalking);
$(".striderunning").append(res.user.strideLengthRunning);
});
});
// Using redirection (option 2)
//OAuth.redirect('fitbit', "callback/url");
});
fitbit-profile.html fitbit.js
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Fitbit client-side example using OAuth.io</title>
</head>
<body>
<script type="text/javascript" src="jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="oauth.js"></script>
<script type="text/javascript" src="fitjs.js"></script>
<!-- Show some basic profile -->
<div class="avatar"/>Avatar: </div></br>
<div class="name">Name: </div></br>
<div class="dateofbirth">Born: </div></br>
<div class="metric">Unit: </div></br>
<div class="stridewalking">Stride (walking): </div></br>
<div class="striderunning">Stride (running): </div></br>
</body>
</html>
Using	
  a	
  SDK	
  might	
  be	
  easier,	
  unHl	
  it	
  isn’t	
  
 
SDK	
  Benefits	
  
	
  
•  Time	
  to	
  First	
  Use	
  (Developer	
  On-­‐boarding)	
  
•  Best	
  client	
  for	
  your	
  API	
  
•  Simplify	
  API	
  design	
  by	
  extracHng	
  business	
  
logic	
  into	
  the	
  SDK	
  
•  Strongly-­‐typed	
  language	
  representaHon	
  	
  
 
SDK	
  Drawbacks	
  
	
  
•  Making	
  API	
  design	
  an	
  aPerthought	
  
•  Picking	
  plaQorm	
  and	
  framework	
  winners	
  
•  3rd	
  party	
  framework	
  dependencies	
  
•  Version	
  dependencies	
  between	
  SDK	
  and	
  API	
  
•  SDK	
  carry-­‐on	
  weight	
  
•  Long-­‐term	
  support	
  costs	
  
 
Using	
  SDKs	
  in	
  Produc%on?	
  
	
  
•  InstrumentaHon?	
  
•  Metrics?	
  
•  Error	
  Handling	
  and	
  Idempotency?	
  
•  Performance	
  and	
  Persistent	
  ConnecHons?	
  
•  Just	
  Grep?	
  
•  Just	
  Patch?	
  
For a more detailed discussion see http://brandur.org/sdk
 
When	
  to	
  consider	
  SDKs?	
  
	
  
•  Time-­‐To-­‐First-­‐Use	
  
•  Best	
  client	
  for	
  your	
  API	
  
•  Small	
  Group	
  of	
  Known	
  Users	
  (Private	
  or	
  
Partner	
  APIs)	
  
•  Developer	
  ExpectaHons	
  
 
Provide	
  SDKs	
  for	
  on-­‐boarding	
  
TransiHon	
  to	
  Web-­‐APIs	
  for	
  produc%on	
  

Weitere ähnliche Inhalte

Was ist angesagt?

Behavior Driven Development with Cucumber
Behavior Driven Development with CucumberBehavior Driven Development with Cucumber
Behavior Driven Development with Cucumber
Brandon Keepers
 

Was ist angesagt? (20)

Building Better Web APIs with Rails
Building Better Web APIs with RailsBuilding Better Web APIs with Rails
Building Better Web APIs with Rails
 
RESTful API - Best Practices
RESTful API - Best PracticesRESTful API - Best Practices
RESTful API - Best Practices
 
Effectively Testing Services - Burlington Ruby Conf
Effectively Testing Services - Burlington Ruby ConfEffectively Testing Services - Burlington Ruby Conf
Effectively Testing Services - Burlington Ruby Conf
 
BDD - Writing better scenario
BDD - Writing better scenarioBDD - Writing better scenario
BDD - Writing better scenario
 
Building RESTful APIs w/ Grape
Building RESTful APIs w/ GrapeBuilding RESTful APIs w/ Grape
Building RESTful APIs w/ Grape
 
Authenticating and Securing Node.js APIs
Authenticating and Securing Node.js APIsAuthenticating and Securing Node.js APIs
Authenticating and Securing Node.js APIs
 
Behavior Driven Development with Cucumber
Behavior Driven Development with CucumberBehavior Driven Development with Cucumber
Behavior Driven Development with Cucumber
 
A tech writer, a map, and an app
A tech writer, a map, and an appA tech writer, a map, and an app
A tech writer, a map, and an app
 
StrongLoop Node.js API Security & Customization
StrongLoop Node.js API Security & CustomizationStrongLoop Node.js API Security & Customization
StrongLoop Node.js API Security & Customization
 
Plugins unplugged
Plugins unpluggedPlugins unplugged
Plugins unplugged
 
RESTful services and OAUTH protocol in IoT
RESTful services and OAUTH protocol in IoTRESTful services and OAUTH protocol in IoT
RESTful services and OAUTH protocol in IoT
 
How Bitbucket Pipelines Loads Connect UI Assets Super-fast
How Bitbucket Pipelines Loads Connect UI Assets Super-fastHow Bitbucket Pipelines Loads Connect UI Assets Super-fast
How Bitbucket Pipelines Loads Connect UI Assets Super-fast
 
api-platform: the ultimate API platform
api-platform: the ultimate API platformapi-platform: the ultimate API platform
api-platform: the ultimate API platform
 
Externalizing Chatter Using Heroku, Angular.js, Node.js and Chatter REST APIs
Externalizing Chatter Using Heroku, Angular.js, Node.js and Chatter REST APIsExternalizing Chatter Using Heroku, Angular.js, Node.js and Chatter REST APIs
Externalizing Chatter Using Heroku, Angular.js, Node.js and Chatter REST APIs
 
EuroPython 2011 - How to build complex web applications having fun?
EuroPython 2011 - How to build complex web applications having fun?EuroPython 2011 - How to build complex web applications having fun?
EuroPython 2011 - How to build complex web applications having fun?
 
Cutting edge HTML5 API you can use today (by Bohdan Rusinka)
 Cutting edge HTML5 API you can use today (by Bohdan Rusinka) Cutting edge HTML5 API you can use today (by Bohdan Rusinka)
Cutting edge HTML5 API you can use today (by Bohdan Rusinka)
 
A Debugging Adventure: Journey through Ember.js Glue
A Debugging Adventure: Journey through Ember.js GlueA Debugging Adventure: Journey through Ember.js Glue
A Debugging Adventure: Journey through Ember.js Glue
 
Apex & jQuery Mobile
Apex & jQuery MobileApex & jQuery Mobile
Apex & jQuery Mobile
 
Introduction to Usergrid - ApacheCon EU 2014
Introduction to Usergrid - ApacheCon EU 2014Introduction to Usergrid - ApacheCon EU 2014
Introduction to Usergrid - ApacheCon EU 2014
 
Cqrs api
Cqrs apiCqrs api
Cqrs api
 

Andere mochten auch

Формирование бизнес идеи
Формирование бизнес идеиФормирование бизнес идеи
Формирование бизнес идеи
okyykg
 
аудит
аудитаудит
аудит
okyykg
 
тайм менеджмент 3_лекция
тайм менеджмент 3_лекциятайм менеджмент 3_лекция
тайм менеджмент 3_лекция
okyykg
 
Работа Публичного центра правовой и социальной информации г. Кемерово
Работа Публичного центра правовой и социальной информации г. КемеровоРабота Публичного центра правовой и социальной информации г. Кемерово
Работа Публичного центра правовой и социальной информации г. Кемерово
kemrsl
 
1400 ping madsen-nordicapis-connect-01
1400 ping madsen-nordicapis-connect-011400 ping madsen-nordicapis-connect-01
1400 ping madsen-nordicapis-connect-01
Nordic APIs
 

Andere mochten auch (16)

Introduction to the Client Portal
Introduction to the Client PortalIntroduction to the Client Portal
Introduction to the Client Portal
 
Формирование бизнес идеи
Формирование бизнес идеиФормирование бизнес идеи
Формирование бизнес идеи
 
Zello & Voice Changer - Two Way Radio Using Smartphone with Different Voices
Zello & Voice Changer - Two Way Radio Using Smartphone with Different VoicesZello & Voice Changer - Two Way Radio Using Smartphone with Different Voices
Zello & Voice Changer - Two Way Radio Using Smartphone with Different Voices
 
Chapter 1 lesson 4
Chapter 1   lesson 4Chapter 1   lesson 4
Chapter 1 lesson 4
 
Геопортал МГУ в 2010-2013 гг.
Геопортал МГУ в 2010-2013 гг. Геопортал МГУ в 2010-2013 гг.
Геопортал МГУ в 2010-2013 гг.
 
Beyond general ledgers
Beyond general ledgersBeyond general ledgers
Beyond general ledgers
 
аудит
аудитаудит
аудит
 
тайм менеджмент 3_лекция
тайм менеджмент 3_лекциятайм менеджмент 3_лекция
тайм менеджмент 3_лекция
 
Evaluation question 6
Evaluation question 6Evaluation question 6
Evaluation question 6
 
Работа Публичного центра правовой и социальной информации г. Кемерово
Работа Публичного центра правовой и социальной информации г. КемеровоРабота Публичного центра правовой и социальной информации г. Кемерово
Работа Публичного центра правовой и социальной информации г. Кемерово
 
Telementoring: Augmented Reality in Orthopedic Education
Telementoring: Augmented Reality in Orthopedic EducationTelementoring: Augmented Reality in Orthopedic Education
Telementoring: Augmented Reality in Orthopedic Education
 
Change Voice In Garena Plus
Change Voice In Garena PlusChange Voice In Garena Plus
Change Voice In Garena Plus
 
Smart home
Smart homeSmart home
Smart home
 
시스템 최신기술 Part1
시스템 최신기술 Part1시스템 최신기술 Part1
시스템 최신기술 Part1
 
Being Social In a Crisis2
Being Social In a Crisis2Being Social In a Crisis2
Being Social In a Crisis2
 
1400 ping madsen-nordicapis-connect-01
1400 ping madsen-nordicapis-connect-011400 ping madsen-nordicapis-connect-01
1400 ping madsen-nordicapis-connect-01
 

Ähnlich wie Do you want a SDK with that API? (Nordic APIS April 2014)

Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
Tom Croucher
 

Ähnlich wie Do you want a SDK with that API? (Nordic APIS April 2014) (20)

Angular Tutorial Freshers and Experienced
Angular Tutorial Freshers and ExperiencedAngular Tutorial Freshers and Experienced
Angular Tutorial Freshers and Experienced
 
How to build a High Performance PSGI/Plack Server
How to build a High Performance PSGI/Plack Server How to build a High Performance PSGI/Plack Server
How to build a High Performance PSGI/Plack Server
 
WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015
 
Mashing up JavaScript
Mashing up JavaScriptMashing up JavaScript
Mashing up JavaScript
 
Mashing up JavaScript – Advanced Techniques for modern Web Apps
Mashing up JavaScript – Advanced Techniques for modern Web AppsMashing up JavaScript – Advanced Techniques for modern Web Apps
Mashing up JavaScript – Advanced Techniques for modern Web Apps
 
Angular Workshop_Sarajevo2
Angular Workshop_Sarajevo2Angular Workshop_Sarajevo2
Angular Workshop_Sarajevo2
 
Angular js security
Angular js securityAngular js security
Angular js security
 
Silex Cheat Sheet
Silex Cheat SheetSilex Cheat Sheet
Silex Cheat Sheet
 
Silex Cheat Sheet
Silex Cheat SheetSilex Cheat Sheet
Silex Cheat Sheet
 
Express Presentation
Express PresentationExpress Presentation
Express Presentation
 
JavaScript Promise
JavaScript PromiseJavaScript Promise
JavaScript Promise
 
Make WordPress realtime.
Make WordPress realtime.Make WordPress realtime.
Make WordPress realtime.
 
Future of Web Apps: Google Gears
Future of Web Apps: Google GearsFuture of Web Apps: Google Gears
Future of Web Apps: Google Gears
 
Doctrine For Beginners
Doctrine For BeginnersDoctrine For Beginners
Doctrine For Beginners
 
YUI on the go
YUI on the goYUI on the go
YUI on the go
 
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
 
REST in AngularJS
REST in AngularJSREST in AngularJS
REST in AngularJS
 
関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい
 
Mojolicious. Веб в коробке!
Mojolicious. Веб в коробке!Mojolicious. Веб в коробке!
Mojolicious. Веб в коробке!
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
 

Mehr von Nordic APIs

The Federated Future: Pioneering Next-Gen Solutions in API Management - Marku...
The Federated Future: Pioneering Next-Gen Solutions in API Management - Marku...The Federated Future: Pioneering Next-Gen Solutions in API Management - Marku...
The Federated Future: Pioneering Next-Gen Solutions in API Management - Marku...
Nordic APIs
 
Inclusive, Accessible Tech: Bias-Free Language in Code and Configurations - A...
Inclusive, Accessible Tech: Bias-Free Language in Code and Configurations - A...Inclusive, Accessible Tech: Bias-Free Language in Code and Configurations - A...
Inclusive, Accessible Tech: Bias-Free Language in Code and Configurations - A...
Nordic APIs
 

Mehr von Nordic APIs (20)

How I Built Bill, the AI-Powered Chatbot That Reads Our Docs for Fun , by Tod...
How I Built Bill, the AI-Powered Chatbot That Reads Our Docs for Fun , by Tod...How I Built Bill, the AI-Powered Chatbot That Reads Our Docs for Fun , by Tod...
How I Built Bill, the AI-Powered Chatbot That Reads Our Docs for Fun , by Tod...
 
The Art of API Design, by David Biesack at Apiture
The Art of API Design, by David Biesack at ApitureThe Art of API Design, by David Biesack at Apiture
The Art of API Design, by David Biesack at Apiture
 
ABAC, ReBAC, Zanzibar, ALFA… How Should I Implement AuthZ in My APIs? by Dav...
ABAC, ReBAC, Zanzibar, ALFA…  How Should I Implement AuthZ in My APIs? by Dav...ABAC, ReBAC, Zanzibar, ALFA…  How Should I Implement AuthZ in My APIs? by Dav...
ABAC, ReBAC, Zanzibar, ALFA… How Should I Implement AuthZ in My APIs? by Dav...
 
Crafting a Cloud Native API Platform to Accelerate Your Platform Maturity - B...
Crafting a Cloud Native API Platform to Accelerate Your Platform Maturity - B...Crafting a Cloud Native API Platform to Accelerate Your Platform Maturity - B...
Crafting a Cloud Native API Platform to Accelerate Your Platform Maturity - B...
 
The Federated Future: Pioneering Next-Gen Solutions in API Management - Marku...
The Federated Future: Pioneering Next-Gen Solutions in API Management - Marku...The Federated Future: Pioneering Next-Gen Solutions in API Management - Marku...
The Federated Future: Pioneering Next-Gen Solutions in API Management - Marku...
 
API Authorization Using an Identity Server and Gateway - Aldo Pietropaolo, SGNL
API Authorization Using an Identity Server and Gateway - Aldo Pietropaolo, SGNLAPI Authorization Using an Identity Server and Gateway - Aldo Pietropaolo, SGNL
API Authorization Using an Identity Server and Gateway - Aldo Pietropaolo, SGNL
 
API Discovery from Crawl to Run - Rob Dickinson, Graylog
API Discovery from Crawl to Run - Rob Dickinson, GraylogAPI Discovery from Crawl to Run - Rob Dickinson, Graylog
API Discovery from Crawl to Run - Rob Dickinson, Graylog
 
Productizing and Monetizing APIs - Derric Gilling, Moseif
Productizing and Monetizing APIs - Derric Gilling, MoseifProductizing and Monetizing APIs - Derric Gilling, Moseif
Productizing and Monetizing APIs - Derric Gilling, Moseif
 
Securely Boosting Any Product with Generative AI APIs - Ruben Sitbon, Sipios
Securely Boosting Any Product with Generative AI APIs - Ruben Sitbon, SipiosSecurely Boosting Any Product with Generative AI APIs - Ruben Sitbon, Sipios
Securely Boosting Any Product with Generative AI APIs - Ruben Sitbon, Sipios
 
Security of LLM APIs by Ankita Gupta, Akto.io
Security of LLM APIs by Ankita Gupta, Akto.ioSecurity of LLM APIs by Ankita Gupta, Akto.io
Security of LLM APIs by Ankita Gupta, Akto.io
 
I'm an API Hacker, Here's How to Go from Making APIs to Breaking Them - Katie...
I'm an API Hacker, Here's How to Go from Making APIs to Breaking Them - Katie...I'm an API Hacker, Here's How to Go from Making APIs to Breaking Them - Katie...
I'm an API Hacker, Here's How to Go from Making APIs to Breaking Them - Katie...
 
Unleashing the Potential of GraphQL with Streaming Data - Kishore Banala, Net...
Unleashing the Potential of GraphQL with Streaming Data - Kishore Banala, Net...Unleashing the Potential of GraphQL with Streaming Data - Kishore Banala, Net...
Unleashing the Potential of GraphQL with Streaming Data - Kishore Banala, Net...
 
Reigniting the API Description Wars with TypeSpec and the Next Generation of ...
Reigniting the API Description Wars with TypeSpec and the Next Generation of...Reigniting the API Description Wars with TypeSpec and the Next Generation of...
Reigniting the API Description Wars with TypeSpec and the Next Generation of ...
 
Establish, Grow, and Mature Your API Platform - James Higginbotham, LaunchAny
Establish, Grow, and Mature Your API Platform - James Higginbotham, LaunchAnyEstablish, Grow, and Mature Your API Platform - James Higginbotham, LaunchAny
Establish, Grow, and Mature Your API Platform - James Higginbotham, LaunchAny
 
Inclusive, Accessible Tech: Bias-Free Language in Code and Configurations - A...
Inclusive, Accessible Tech: Bias-Free Language in Code and Configurations - A...Inclusive, Accessible Tech: Bias-Free Language in Code and Configurations - A...
Inclusive, Accessible Tech: Bias-Free Language in Code and Configurations - A...
 
Going Platinum: How to Make a Hit API by Bill Doerrfeld, Nordic APIs
Going Platinum: How to Make a Hit API by Bill Doerrfeld, Nordic APIsGoing Platinum: How to Make a Hit API by Bill Doerrfeld, Nordic APIs
Going Platinum: How to Make a Hit API by Bill Doerrfeld, Nordic APIs
 
Getting Better at Risk Management Using Event Driven Mesh Architecture - Ragh...
Getting Better at Risk Management Using Event Driven Mesh Architecture - Ragh...Getting Better at Risk Management Using Event Driven Mesh Architecture - Ragh...
Getting Better at Risk Management Using Event Driven Mesh Architecture - Ragh...
 
GenAI: Producing and Consuming APIs by Paul Dumas, Gartner
GenAI: Producing and Consuming APIs by Paul Dumas, GartnerGenAI: Producing and Consuming APIs by Paul Dumas, Gartner
GenAI: Producing and Consuming APIs by Paul Dumas, Gartner
 
The SAS developer portal – developer.sas.com 2.0: How we built it by Joe Furb...
The SAS developer portal –developer.sas.com 2.0: How we built it by Joe Furb...The SAS developer portal –developer.sas.com 2.0: How we built it by Joe Furb...
The SAS developer portal – developer.sas.com 2.0: How we built it by Joe Furb...
 
How Netflix Uses Data Abstraction to Operate Services at Scale - Vidhya Arvin...
How Netflix Uses Data Abstraction to Operate Services at Scale - Vidhya Arvin...How Netflix Uses Data Abstraction to Operate Services at Scale - Vidhya Arvin...
How Netflix Uses Data Abstraction to Operate Services at Scale - Vidhya Arvin...
 

Kürzlich hochgeladen

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 

Kürzlich hochgeladen (20)

call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
ManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide Deck
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
 
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 

Do you want a SDK with that API? (Nordic APIS April 2014)

  • 1. Nordic APIs Tour 2014 Holger Reinhardt @hlgr360 holger.reinhardt@ca.com
  • 2. http://www.flickr.com/photos/jurvetson/21470089/ You  want  a  Library     with  that  (API)?  
  • 3. Designing  an  API  is  easy     Effec%ve  API  design  is  difficult  
  • 4. •  Informaton •  Product •  Service Business Asset •  API •  SLA •  EULA API Provider •  Building App Developer •  Using API Application •  Using App End-User The  API  Value  Chain  
  • 5. •  Informaton •  Product •  Service Business Asset •  API •  SLA •  EULA API Provider •  Building App Developer •  Using API Application •  Using App End-User Effec%ve  API  Design  
  • 6. And  this  is  when  Someone  usually  asks  
  • 7.
  • 8. A  story  about  two  APIs  
  • 9.
  • 10.
  • 12.
  • 13.
  • 14. I  wanted  Javascript,  but  got  PHP  
  • 15. I  wanted  Client-­‐side,  but  got  Server-­‐side  
  • 16. - need to install peck or pearl on my Mac http://pear.php.net/manual/en/installation.getting.php - went back to documentation to install oauth extension, needed autoconf - tried another way http://stackoverflow.com/questions/5536195/install-pecl- on-mac-os-x-10-6 - still required autoconf http://mac-dev-env.patrickbougie.com/autoconf/ -  Error: PECL: configuration option "php_ini" is not set to php.ini location http://arcadian83.livejournal.com/16386.html => Ready to run php lib from fitbit website
  • 17. - Enable php http://editrocket.com/articles/php_apache_mac.html - Enable apache server http://reviews.cnet.com/8301-13727_7-57481978-263/how-to- enable-web-sharing-in-os-x-mountain-lion/ -  sudo apachectl start => Ready to start playing with the php lib
  • 18. small  annoyances  add  up     to  create  a  poor  experience  
  • 19. And  that  PHP  code  looks  complex  
  • 20. <?php // Base URL $baseUrl = 'http://api.fitbit.com'; // Request token path $req_url = $baseUrl . '/oauth/request_token'; // Authorization path $authurl = $baseUrl . '/oauth/authorize'; // Access token path $acc_url = $baseUrl . '/oauth/access_token'; // Consumer key $conskey = 'local-fitbit-example-php-client-application'; // Consumer secret $conssec = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; // Fitbit API call (get activities for specified date) $apiCall = "http://api.fitbit.com/1/user/-/activities/date/2014-01-25.xml"; // HR: callback url $callbackUrl = "http://localhost/~h_reinhardt/fitbit/php/ completeAuthorization.php"; // Start session to store the information between calls session_start(); // In state=1 the next request should include an oauth_token. // If it doesn't go back to 0 if ( !isset($_GET['oauth_token']) && $_SESSION['state']==1 ) $_SESSION['state'] = 0; try { // Create OAuth object $oauth = new OAuth($conskey, $conssec,OAUTH_SIG_METHOD_HMACSHA1,OAUTH_AUTH_TYPE_AUT HORIZATION); // Enable ouath debug (should be disabled in production) $oauth->enableDebug(); if ( $_SESSION['state'] == 0 ) { // Getting request token. Callback URL is the Absolute URL to which the server provder will redirect the User back when the obtaining user authorization step is completed. $request_token_info = $oauth->getRequestToken($req_url, $callbackUrl); // Storing key and state in a session. $_SESSION['secret'] = $request_token_info['oauth_token_secret']; $_SESSION['state'] = 1; // Redirect to the authorization. header('Location: '.$authurl.'?oauth_token='. $request_token_info['oauth_token']); exit; } else if ( $_SESSION['state']==1 ) { // Authorized. Getting access token and secret $oauth->setToken($_GET['oauth_token'],$_SESSION['secret']); $access_token_info = $oauth->getAccessToken($acc_url); // Storing key and state in a session. $_SESSION['state'] = 2; $_SESSION['token'] = $access_token_info['oauth_token']; $_SESSION['secret'] = $access_token_info['oauth_token_secret']; } // Setting asccess token to the OAuth object $oauth->setToken($_SESSION['token'],$_SESSION['secret']); // Performing API call $oauth->fetch($apiCall); // Getting last response $response = $oauth->getLastResponse(); // Initializing the simple_xml object using API response
  • 21.
  • 22. But  that  SDK  looks  sHcky  and  heavy  
  • 23. <?php require 'php-sdk/src/temboo.php'; // Instantiate the Choreo, using a previously instantiated Temboo_Session object, eg: // $session = new Temboo_Session('hlgr360', 'APP_NAME', 'APP_KEY'); $session = new Temboo_Session('hlgr360', 'myFirstApp', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); $getActivities = new Fitbit_Activities_GetActivities($session); // Get an input object for the Choreo $getActivitiesInputs = $getActivities->newInputs(); // Set credential to use for execution $getActivitiesInputs->setCredential('apiacademy'); // Set inputs $getActivitiesInputs->setDate("2014-01-25")->setResponseFormat("xml"); // Execute Choreo and get results $getActivitiesResults = $getActivities->execute($getActivitiesInputs)- >getResults(); // Initializing the simple_xml object using API response $xml = simplexml_load_string($getActivitiesResults->getResponse()); ?>
  • 24.
  • 25.
  • 26. $(document).ready( function () { OAuth.initialize(’xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx’); // Using popup (option 1) OAuth.popup('fitbit', function(error, result) { if (error) { console.log(err); // do something with error return; }; result.get("/1/user/-/profile.json").done(function(res) { console.log("Hello, ", res); var $img = $("<img>",{src: res.user.avatar}); $(".avatar").append($img); $(".name").append(res.user.fullName); $(".dateofbirth").append(res.user.dateOfBirth); $(".metric").append(res.user.distanceUnit); $(".stridewalking").append(res.user.strideLengthWalking); $(".striderunning").append(res.user.strideLengthRunning); }); }); // Using redirection (option 2) //OAuth.redirect('fitbit', "callback/url"); }); fitbit-profile.html fitbit.js <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Fitbit client-side example using OAuth.io</title> </head> <body> <script type="text/javascript" src="jquery-1.10.2.min.js"></script> <script type="text/javascript" src="oauth.js"></script> <script type="text/javascript" src="fitjs.js"></script> <!-- Show some basic profile --> <div class="avatar"/>Avatar: </div></br> <div class="name">Name: </div></br> <div class="dateofbirth">Born: </div></br> <div class="metric">Unit: </div></br> <div class="stridewalking">Stride (walking): </div></br> <div class="striderunning">Stride (running): </div></br> </body> </html>
  • 27. Using  a  SDK  might  be  easier,  unHl  it  isn’t  
  • 28.   SDK  Benefits     •  Time  to  First  Use  (Developer  On-­‐boarding)   •  Best  client  for  your  API   •  Simplify  API  design  by  extracHng  business   logic  into  the  SDK   •  Strongly-­‐typed  language  representaHon    
  • 29.   SDK  Drawbacks     •  Making  API  design  an  aPerthought   •  Picking  plaQorm  and  framework  winners   •  3rd  party  framework  dependencies   •  Version  dependencies  between  SDK  and  API   •  SDK  carry-­‐on  weight   •  Long-­‐term  support  costs  
  • 30.   Using  SDKs  in  Produc%on?     •  InstrumentaHon?   •  Metrics?   •  Error  Handling  and  Idempotency?   •  Performance  and  Persistent  ConnecHons?   •  Just  Grep?   •  Just  Patch?   For a more detailed discussion see http://brandur.org/sdk
  • 31.   When  to  consider  SDKs?     •  Time-­‐To-­‐First-­‐Use   •  Best  client  for  your  API   •  Small  Group  of  Known  Users  (Private  or   Partner  APIs)   •  Developer  ExpectaHons  
  • 32.   Provide  SDKs  for  on-­‐boarding   TransiHon  to  Web-­‐APIs  for  produc%on