SlideShare uma empresa Scribd logo
1 de 32
Using an API
Using an API

   Tools
       HTTPie
       CURL
       Charles – http://www.charlesproxy.com
       Firebug – https://getfirebug.com
Using an API

   HTTPie
       Great for debugging APIs rather than using cURL
       http://www.httpie.org
       Free
       Requires Python
          POST /books HTTP/1.1
          HOST: example.com
          Content-Type: application/hal+json
          Accept-Encoding: identity, deflate, compress, gzip
          Accept: application/hal+json
          User-Agent: HTTPie/0.2.0

          {
               “author”: “Stoyan Stefanov”,
Using an API

   Charles
       http://charlesproxy.com
       Great for debugging AJAX and Flash AMF requests
       Worth the $50 license fee, but (at least on Ubuntu)
        you can use it free, though it shuts down after 30
        minutes.
Using an API

   cURL
       Great to use via PHP, but for command line use
        HTTPie.
   Firebug
       Great for debugging from Firefox.
   Others
       I hear IE has an OK debugging tool like Firebug.
       I have also heard Chrome has a great Firebug'ish
        tool also.
Using an API

   What is an API?
       Application programming interface
                  A specification intended to be used as an
                    interface by software components to
                    communicate with each other. - wikipedia
Using an API

   API types (popular)
       SOAP – Simple Object Access Protocol
       REST – Representational State Transfer
                   (RFC 2616)
       Javascript
       Screen scrape
Using an API

   SOAP basics
       Relies on XML as its message format.
       Uses HTTP, SMTP, TCP, or JMS for transport, but
        usually HTTP.
       Generally uses a WSDL (Web Services Description
        Language) configuration file making it easier to
        build for or connect to the API.
       Cross platform and cross language.
       Very structured – each action is defined (addUser,
        getUsers, getNewUsersSince, etc.)
Using an API

   Javascript basics
       Client side execution
       Communication from client to server
       Usually methods are defined on server side
        (getThis, addThat, etc.)
       Perception of interactivity (desktop feel)
       Can be asynchronous
       Used by Google Maps and others
Using an API

   Screen scrape basics
       Not a true client/server api.
       Relies on regular expression matching of content.
       Usually done over HTTP using cURL.
       Breaks when server content changes.
       Must download all content, so may be slow and
        resource intensive.
Using an API

   REST basics (main focus for this talk)
       Client-Server
       Stateless – each request is complete and self
        contained (struggle with sessions and cookies)
       Cacheable
       Layered – client cannot tell if using end-server,
        allows load balancers, caches, logging, auth.
       Uniform interface – decoupled from architecture
       Methods – GET, POST, PUT, DELETE, HEAD,
        OPTIONS, TRACE, CONNECT
Using an API

   REST safe methods
       No side effects on the server
       GET & HEAD should make no other action than to
        retrieve.
       Allows user agents to represent POST, PUT, and
        DELETE special. (most browsers do not support
        PUT and DELETE out of the box)
Using an API

   Idempotence
       Operations that can be applied multiple times
        without changing the result. (Ex.- N>0 identical
        requests would have the same output)
       GET, HEAD, PUT, and DELETE share this property
       OPTIONS and TRACE are inherently idempotent.
Using an API

   GET
       Safe and idempotent
       No effect on the server


          GET /books/9790482c HTTP/1.1
          Host: example.com
          Accept-Encoding: identity, deflate, compress, gzip
          Accept: application/hal+json
          User-Agent: HTTPie/0.2.0
Using an API

   GET response
       HTTP/1.1 200 OK
       Date: Wed, 08 Aug 2012 09:32:42 GMT
       Server: Apache/2.2.22 (Ubuntu)
       X-Powered-By: PHP/5.3.10-1ubuntu3.2
       ETag: “9790482c-1”
       Last-Modified: Wed, 08 Aug 2012 04:14:30 GMT
       Content-Length: 254
       Content-Type: application/hal+json

       {
           “_links”: {
                  “self”: {
                     “href”: “http://example.com/books/9790482c”
                  }
           },
           “author”: “Luke Welling, Laura Thomson”,
           “id”: “9790482c”,
           “isbn10”: “0672329166”,
Using an API

   POST
       Not safe
       Not idempotent (same post multiple times could
        have different effects on server)
       Used to create resource
       Is often used to also update a resource, though
        PUT is more for updating.
Using an API

   POST example
       POST /books HTTP/1.1
       HOST: example.com
       Content-Type: application/hal+json
       Accept-Encoding: identity, deflate, compress, gzip
       Accept: application/hal+json
       User-Agent: HTTPie/0.2.0

       {
           “author”: “Stoyan Stefanov”,
           “isbn10”: “1449320198”,
           “isbn13”: “9781449320195”,
           “publisher”: “O'Reilly Media”,
           “title”: “Javascript for PHP Developers”,
           “year”: 2012
       }
Using an API

   Created Response
       HTTP/1.1 201 Created
       Date: Sun, 29 Jul 2012 23:26:49 GMT
       Server: Apache/2.2.22 (Ubuntu)
       X-Powered-By: PHP/5.3.10-1ubuntu3.2
       Location: http://example.com/books/decd0562
       Etag: “decd0562-1”
       Last-Modified: Sun, 29 Jul 2012 23:26:49 GMT
       Content-Length: 239
       Content-Type: application/hal+json

       {
           “_links”: {
                  “self”: {
                     “href”: “http://example.com/books/decd0562”
                  }
           },
           “author”: “Stoyan Stefanov”,
           “id”: “decd0562”,
           “isbn10”: “1449320198”,
Using an API

   PUT
       Not safe
       But is idempotent
       Primarily an update action, but can also be used to
        create though POST should be used for that.
Using an API

   Sample PUT

     PUT /books/decd0562 HTTP/1.1
     HOST: example.com
     Content-Type: application/hal+json
     Accept-Encoding: identity, deflate, compress, gzip
     If-Match: “decd0562-1”
     Accept: application/hal+json
     User-Agent: HTTPie/0.2.0

     {
         “_links”: {
                “self”: {
                   “href”: “http://example.com/books/decd0562”
                }
         }
         “author”: “Stoyan Stefanov”,
         “isbn10”: “1449320198”,
Using an API

   Update response
       HTTP/1.1 201 OK
       Date: Sun, 29 Jul 2012 23:26:49 GMT
       Server: Apache/2.2.22 (Ubuntu)
       X-Powered-By: PHP/5.3.10-1ubuntu3.2
       Location: http://example.com/books/decd0562
       Etag: “decd0562-2”
       Last-Modified: Sun, 29 Jul 2012 23:26:49 GMT
       Content-Length: 270
       Content-Type: application/hal+json

       {
           “_links”: {
                  “self”: {
                     “href”: “http://example.com/books/decd0562”
                  }
           },
           “author”: “Stoyan Stefanov”,
           “id”: “decd0562”,
           “isbn10”: “1449320198”,
Using an API

   DELETE
       Not safe
       Is idempotent
       Does not mean to remove the resource, but does
        mean to remove from public view.

         DELETE /books/decd0562 HTTP/1.1
         Host: example.com
         Accept-Encoding: identity, deflate, compress, gzip
         Accept: application/hal+json
         User-Agent: HTTPie/0.2.0
         If-Match: “decd0562-2”
Using an API

   DELETE response



          HTTP/1.1 204 No Content
          Date: Mon, 30 Jul 2012 00:01:44 GMT
          Server: Apache/2.2.22 (Ubuntu)
          X-Powered-By: PHP/5.3.10-1ubuntu3.2
          Content-Length: 0
          Content-Type: application/hal+json
Using an API

   HEAD
       Same as GET, but doesn't return the body
                  An example of use would be to check content
                    length before actually requesting it.
Using an API

   Status codes
       Informational (1xx)
       Successful (2xx)
       Redirection (3xx)
       Client error (4xx)
       Server error (5xx)
Using an API

   Common usage
       Most developers aren't building an API
       Using for sites and application content
       Leverage resources/services (Google Maps)
       Cut development time, add functionality
Using an API

   Resources for great APIs available
       Mashery.com
                    https://developer.mashery.com/apis
       Apigee.com
                    https://apigee.com/providers
       Google
                    https://developers.google.com



                     Let's take a look!!!
Using an API

   Documention tools
       Mashery http://mashery.github.com
                  I/O Docs – interactive API documentation
                  I/O Alfred – Alfred app to use some APIs
                  I/O Wraps – API client library generator
                  Oauth Signature Tool
                  Oauth 1.0 JS Testing Tool
                  AppMobi Sample Apps
Using an API

   Documentation tools
       apigee
                    Providers list
                    “Console” to experiment with APIs
                    “Console To-Go” to add your own API
                    Usergrid – Backend as a service to get mobile
                       apps running quickly.
                    O-Auth api
Using an API

   TO THE CODE!!!
Using an API

   Resources
       http://www.charlesproxy.com
       https://getfirebug.com
       http://www.httpie.org
       https://developer.mashery.com/apis
       https://apigee.com/providers
       https://developers.google.com
Using an API

   Thank You


                      Adam Culp
                      @adamculp
                 http://geekyboy.com


                Please rate this talk at:
                  http://joind.in/6739

Mais conteúdo relacionado

Mais procurados

Getting Started with WebSockets and Server-Sent Events
Getting Started with WebSockets and Server-Sent EventsGetting Started with WebSockets and Server-Sent Events
Getting Started with WebSockets and Server-Sent EventsArun Gupta
 
API Technical Writing
API Technical WritingAPI Technical Writing
API Technical WritingSarah Maddox
 
Understanding REST
Understanding RESTUnderstanding REST
Understanding RESTNitin Pande
 
The REST And Then Some
The REST And Then SomeThe REST And Then Some
The REST And Then SomeNordic APIs
 
Building a desktop app with HTTP::Engine, SQLite and jQuery
Building a desktop app with HTTP::Engine, SQLite and jQueryBuilding a desktop app with HTTP::Engine, SQLite and jQuery
Building a desktop app with HTTP::Engine, SQLite and jQueryTatsuhiko Miyagawa
 
The Internet as Web Services: introduction to ReST
The Internet as Web Services: introduction to ReSTThe Internet as Web Services: introduction to ReST
The Internet as Web Services: introduction to ReSTBruno Kessler Foundation
 
Designing a beautiful REST json api
Designing a beautiful REST json apiDesigning a beautiful REST json api
Designing a beautiful REST json api0x07de
 
JSON REST API for WordPress
JSON REST API for WordPressJSON REST API for WordPress
JSON REST API for WordPressTaylor Lovett
 
Opening up the Social Web - Standards that are bridging the Islands
Opening up the Social Web - Standards that are bridging the IslandsOpening up the Social Web - Standards that are bridging the Islands
Opening up the Social Web - Standards that are bridging the IslandsBastian Hofmann
 
Webpack Encore Symfony Live 2017 San Francisco
Webpack Encore Symfony Live 2017 San FranciscoWebpack Encore Symfony Live 2017 San Francisco
Webpack Encore Symfony Live 2017 San FranciscoRyan Weaver
 
Tornado web
Tornado webTornado web
Tornado webkurtiss
 
Ruby in the Browser - RubyConf 2011
Ruby in the Browser - RubyConf 2011Ruby in the Browser - RubyConf 2011
Ruby in the Browser - RubyConf 2011Ilya Grigorik
 
MongoDB World 2018: Tutorial - Got Dibs? Building a Real-Time Bidding App wit...
MongoDB World 2018: Tutorial - Got Dibs? Building a Real-Time Bidding App wit...MongoDB World 2018: Tutorial - Got Dibs? Building a Real-Time Bidding App wit...
MongoDB World 2018: Tutorial - Got Dibs? Building a Real-Time Bidding App wit...MongoDB
 
Design Beautiful REST + JSON APIs
Design Beautiful REST + JSON APIsDesign Beautiful REST + JSON APIs
Design Beautiful REST + JSON APIsStormpath
 

Mais procurados (18)

Getting Started with WebSockets and Server-Sent Events
Getting Started with WebSockets and Server-Sent EventsGetting Started with WebSockets and Server-Sent Events
Getting Started with WebSockets and Server-Sent Events
 
Plack at OSCON 2010
Plack at OSCON 2010Plack at OSCON 2010
Plack at OSCON 2010
 
API Technical Writing
API Technical WritingAPI Technical Writing
API Technical Writing
 
Understanding REST
Understanding RESTUnderstanding REST
Understanding REST
 
Frans Rosén Keynote at BSides Ahmedabad
Frans Rosén Keynote at BSides AhmedabadFrans Rosén Keynote at BSides Ahmedabad
Frans Rosén Keynote at BSides Ahmedabad
 
The REST And Then Some
The REST And Then SomeThe REST And Then Some
The REST And Then Some
 
Building a desktop app with HTTP::Engine, SQLite and jQuery
Building a desktop app with HTTP::Engine, SQLite and jQueryBuilding a desktop app with HTTP::Engine, SQLite and jQuery
Building a desktop app with HTTP::Engine, SQLite and jQuery
 
The Internet as Web Services: introduction to ReST
The Internet as Web Services: introduction to ReSTThe Internet as Web Services: introduction to ReST
The Internet as Web Services: introduction to ReST
 
Designing a beautiful REST json api
Designing a beautiful REST json apiDesigning a beautiful REST json api
Designing a beautiful REST json api
 
JSON REST API for WordPress
JSON REST API for WordPressJSON REST API for WordPress
JSON REST API for WordPress
 
Opening up the Social Web - Standards that are bridging the Islands
Opening up the Social Web - Standards that are bridging the IslandsOpening up the Social Web - Standards that are bridging the Islands
Opening up the Social Web - Standards that are bridging the Islands
 
Webpack Encore Symfony Live 2017 San Francisco
Webpack Encore Symfony Live 2017 San FranciscoWebpack Encore Symfony Live 2017 San Francisco
Webpack Encore Symfony Live 2017 San Francisco
 
Tornado web
Tornado webTornado web
Tornado web
 
Ruby in the Browser - RubyConf 2011
Ruby in the Browser - RubyConf 2011Ruby in the Browser - RubyConf 2011
Ruby in the Browser - RubyConf 2011
 
Maven 3.0 at Øredev
Maven 3.0 at ØredevMaven 3.0 at Øredev
Maven 3.0 at Øredev
 
Ruby On Grape
Ruby On GrapeRuby On Grape
Ruby On Grape
 
MongoDB World 2018: Tutorial - Got Dibs? Building a Real-Time Bidding App wit...
MongoDB World 2018: Tutorial - Got Dibs? Building a Real-Time Bidding App wit...MongoDB World 2018: Tutorial - Got Dibs? Building a Real-Time Bidding App wit...
MongoDB World 2018: Tutorial - Got Dibs? Building a Real-Time Bidding App wit...
 
Design Beautiful REST + JSON APIs
Design Beautiful REST + JSON APIsDesign Beautiful REST + JSON APIs
Design Beautiful REST + JSON APIs
 

Semelhante a Using an API

Introduction to Apigility
Introduction to ApigilityIntroduction to Apigility
Introduction to ApigilityEngineor
 
Apigility – Lightning Fast API Development - OSSCamp 2014
Apigility – Lightning Fast API Development - OSSCamp 2014 Apigility – Lightning Fast API Development - OSSCamp 2014
Apigility – Lightning Fast API Development - OSSCamp 2014 OSSCube
 
Survival Strategies for API Documentation: Presentation to Southwestern Ontar...
Survival Strategies for API Documentation: Presentation to Southwestern Ontar...Survival Strategies for API Documentation: Presentation to Southwestern Ontar...
Survival Strategies for API Documentation: Presentation to Southwestern Ontar...Tom Johnson
 
ASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiTiago Knoch
 
Apigility introduction v2 (glasgow php)
Apigility introduction v2 (glasgow php)Apigility introduction v2 (glasgow php)
Apigility introduction v2 (glasgow php)Engineor
 
Mastering Microservices with Kong (DevoxxUK 2019)
Mastering Microservices with Kong (DevoxxUK 2019)Mastering Microservices with Kong (DevoxxUK 2019)
Mastering Microservices with Kong (DevoxxUK 2019)Maarten Mulders
 
Plack perl superglue for web frameworks and servers
Plack perl superglue for web frameworks and serversPlack perl superglue for web frameworks and servers
Plack perl superglue for web frameworks and serversTatsuhiko Miyagawa
 
Unleash the power of HTTP with ASP.NET Web API
Unleash the power of HTTP with ASP.NET Web APIUnleash the power of HTTP with ASP.NET Web API
Unleash the power of HTTP with ASP.NET Web APIFilip W
 
Fulfilling the Hypermedia Constraint via HTTP OPTIONS, The HTTP Vocabulary In...
Fulfilling the Hypermedia Constraint via HTTP OPTIONS, The HTTP Vocabulary In...Fulfilling the Hypermedia Constraint via HTTP OPTIONS, The HTTP Vocabulary In...
Fulfilling the Hypermedia Constraint via HTTP OPTIONS, The HTTP Vocabulary In...ruyalarcon
 
Google App Engine for PHP
Google App Engine for PHP Google App Engine for PHP
Google App Engine for PHP Eric Johnson
 
High quality ap is with api platform
High quality ap is with api platformHigh quality ap is with api platform
High quality ap is with api platformNelson Kopliku
 
Using the new WordPress REST API
Using the new WordPress REST APIUsing the new WordPress REST API
Using the new WordPress REST APICaldera Labs
 
The future of server side JavaScript
The future of server side JavaScriptThe future of server side JavaScript
The future of server side JavaScriptOleg Podsechin
 

Semelhante a Using an API (20)

eZ Publish REST API v2
eZ Publish REST API v2eZ Publish REST API v2
eZ Publish REST API v2
 
E zsc2012 rest-api-v2
E zsc2012 rest-api-v2E zsc2012 rest-api-v2
E zsc2012 rest-api-v2
 
Introduction to Apigility
Introduction to ApigilityIntroduction to Apigility
Introduction to Apigility
 
Crafting APIs
Crafting APIsCrafting APIs
Crafting APIs
 
Apigility – Lightning Fast API Development - OSSCamp 2014
Apigility – Lightning Fast API Development - OSSCamp 2014 Apigility – Lightning Fast API Development - OSSCamp 2014
Apigility – Lightning Fast API Development - OSSCamp 2014
 
Survival Strategies for API Documentation: Presentation to Southwestern Ontar...
Survival Strategies for API Documentation: Presentation to Southwestern Ontar...Survival Strategies for API Documentation: Presentation to Southwestern Ontar...
Survival Strategies for API Documentation: Presentation to Southwestern Ontar...
 
ASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiASP.NET Mvc 4 web api
ASP.NET Mvc 4 web api
 
Apigility introduction v2 (glasgow php)
Apigility introduction v2 (glasgow php)Apigility introduction v2 (glasgow php)
Apigility introduction v2 (glasgow php)
 
Gohan
GohanGohan
Gohan
 
APIs Demystified
APIs DemystifiedAPIs Demystified
APIs Demystified
 
Mastering Microservices with Kong (DevoxxUK 2019)
Mastering Microservices with Kong (DevoxxUK 2019)Mastering Microservices with Kong (DevoxxUK 2019)
Mastering Microservices with Kong (DevoxxUK 2019)
 
Talking to Web Services
Talking to Web ServicesTalking to Web Services
Talking to Web Services
 
Plack perl superglue for web frameworks and servers
Plack perl superglue for web frameworks and serversPlack perl superglue for web frameworks and servers
Plack perl superglue for web frameworks and servers
 
Unleash the power of HTTP with ASP.NET Web API
Unleash the power of HTTP with ASP.NET Web APIUnleash the power of HTTP with ASP.NET Web API
Unleash the power of HTTP with ASP.NET Web API
 
Fulfilling the Hypermedia Constraint via HTTP OPTIONS, The HTTP Vocabulary In...
Fulfilling the Hypermedia Constraint via HTTP OPTIONS, The HTTP Vocabulary In...Fulfilling the Hypermedia Constraint via HTTP OPTIONS, The HTTP Vocabulary In...
Fulfilling the Hypermedia Constraint via HTTP OPTIONS, The HTTP Vocabulary In...
 
Google App Engine for PHP
Google App Engine for PHP Google App Engine for PHP
Google App Engine for PHP
 
High quality ap is with api platform
High quality ap is with api platformHigh quality ap is with api platform
High quality ap is with api platform
 
Using the new WordPress REST API
Using the new WordPress REST APIUsing the new WordPress REST API
Using the new WordPress REST API
 
Web Dev 21-01-2024.pptx
Web Dev 21-01-2024.pptxWeb Dev 21-01-2024.pptx
Web Dev 21-01-2024.pptx
 
The future of server side JavaScript
The future of server side JavaScriptThe future of server side JavaScript
The future of server side JavaScript
 

Mais de Adam Culp

Putting legacy to REST with middleware
Putting legacy to REST with middlewarePutting legacy to REST with middleware
Putting legacy to REST with middlewareAdam Culp
 
Release your refactoring superpower
Release your refactoring superpowerRelease your refactoring superpower
Release your refactoring superpowerAdam Culp
 
Managing Technical Debt
Managing Technical DebtManaging Technical Debt
Managing Technical DebtAdam Culp
 
Developing PHP Applications Faster
Developing PHP Applications FasterDeveloping PHP Applications Faster
Developing PHP Applications FasterAdam Culp
 
Containing Quality
Containing QualityContaining Quality
Containing QualityAdam Culp
 
Debugging elephpants
Debugging elephpantsDebugging elephpants
Debugging elephpantsAdam Culp
 
Zend expressive workshop
Zend expressive workshopZend expressive workshop
Zend expressive workshopAdam Culp
 
Expressive Microservice Framework Blastoff
Expressive Microservice Framework BlastoffExpressive Microservice Framework Blastoff
Expressive Microservice Framework BlastoffAdam Culp
 
Foundations of Zend Framework
Foundations of Zend FrameworkFoundations of Zend Framework
Foundations of Zend FrameworkAdam Culp
 
Accidental professional
Accidental professionalAccidental professional
Accidental professionalAdam Culp
 
Build great products
Build great productsBuild great products
Build great productsAdam Culp
 
Does Your Code Measure Up?
Does Your Code Measure Up?Does Your Code Measure Up?
Does Your Code Measure Up?Adam Culp
 
Practical PHP Deployment with Jenkins
Practical PHP Deployment with JenkinsPractical PHP Deployment with Jenkins
Practical PHP Deployment with JenkinsAdam Culp
 
Virtualizing Development
Virtualizing DevelopmentVirtualizing Development
Virtualizing DevelopmentAdam Culp
 
Refactoring Legacy Code
Refactoring Legacy CodeRefactoring Legacy Code
Refactoring Legacy CodeAdam Culp
 
Deprecated: Foundations of Zend Framework 2
Deprecated: Foundations of Zend Framework 2Deprecated: Foundations of Zend Framework 2
Deprecated: Foundations of Zend Framework 2Adam Culp
 
Clean application development tutorial
Clean application development tutorialClean application development tutorial
Clean application development tutorialAdam Culp
 
Refactoring 101
Refactoring 101Refactoring 101
Refactoring 101Adam Culp
 

Mais de Adam Culp (20)

Hypermedia
HypermediaHypermedia
Hypermedia
 
Putting legacy to REST with middleware
Putting legacy to REST with middlewarePutting legacy to REST with middleware
Putting legacy to REST with middleware
 
php-1701-a
php-1701-aphp-1701-a
php-1701-a
 
Release your refactoring superpower
Release your refactoring superpowerRelease your refactoring superpower
Release your refactoring superpower
 
Managing Technical Debt
Managing Technical DebtManaging Technical Debt
Managing Technical Debt
 
Developing PHP Applications Faster
Developing PHP Applications FasterDeveloping PHP Applications Faster
Developing PHP Applications Faster
 
Containing Quality
Containing QualityContaining Quality
Containing Quality
 
Debugging elephpants
Debugging elephpantsDebugging elephpants
Debugging elephpants
 
Zend expressive workshop
Zend expressive workshopZend expressive workshop
Zend expressive workshop
 
Expressive Microservice Framework Blastoff
Expressive Microservice Framework BlastoffExpressive Microservice Framework Blastoff
Expressive Microservice Framework Blastoff
 
Foundations of Zend Framework
Foundations of Zend FrameworkFoundations of Zend Framework
Foundations of Zend Framework
 
Accidental professional
Accidental professionalAccidental professional
Accidental professional
 
Build great products
Build great productsBuild great products
Build great products
 
Does Your Code Measure Up?
Does Your Code Measure Up?Does Your Code Measure Up?
Does Your Code Measure Up?
 
Practical PHP Deployment with Jenkins
Practical PHP Deployment with JenkinsPractical PHP Deployment with Jenkins
Practical PHP Deployment with Jenkins
 
Virtualizing Development
Virtualizing DevelopmentVirtualizing Development
Virtualizing Development
 
Refactoring Legacy Code
Refactoring Legacy CodeRefactoring Legacy Code
Refactoring Legacy Code
 
Deprecated: Foundations of Zend Framework 2
Deprecated: Foundations of Zend Framework 2Deprecated: Foundations of Zend Framework 2
Deprecated: Foundations of Zend Framework 2
 
Clean application development tutorial
Clean application development tutorialClean application development tutorial
Clean application development tutorial
 
Refactoring 101
Refactoring 101Refactoring 101
Refactoring 101
 

Último

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 

Último (20)

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 

Using an API

  • 2. Using an API  Tools  HTTPie  CURL  Charles – http://www.charlesproxy.com  Firebug – https://getfirebug.com
  • 3. Using an API  HTTPie  Great for debugging APIs rather than using cURL  http://www.httpie.org  Free  Requires Python POST /books HTTP/1.1 HOST: example.com Content-Type: application/hal+json Accept-Encoding: identity, deflate, compress, gzip Accept: application/hal+json User-Agent: HTTPie/0.2.0 { “author”: “Stoyan Stefanov”,
  • 4. Using an API  Charles  http://charlesproxy.com  Great for debugging AJAX and Flash AMF requests  Worth the $50 license fee, but (at least on Ubuntu) you can use it free, though it shuts down after 30 minutes.
  • 5. Using an API  cURL  Great to use via PHP, but for command line use HTTPie.  Firebug  Great for debugging from Firefox.  Others  I hear IE has an OK debugging tool like Firebug.  I have also heard Chrome has a great Firebug'ish tool also.
  • 6. Using an API  What is an API?  Application programming interface  A specification intended to be used as an interface by software components to communicate with each other. - wikipedia
  • 7. Using an API  API types (popular)  SOAP – Simple Object Access Protocol  REST – Representational State Transfer  (RFC 2616)  Javascript  Screen scrape
  • 8. Using an API  SOAP basics  Relies on XML as its message format.  Uses HTTP, SMTP, TCP, or JMS for transport, but usually HTTP.  Generally uses a WSDL (Web Services Description Language) configuration file making it easier to build for or connect to the API.  Cross platform and cross language.  Very structured – each action is defined (addUser, getUsers, getNewUsersSince, etc.)
  • 9. Using an API  Javascript basics  Client side execution  Communication from client to server  Usually methods are defined on server side (getThis, addThat, etc.)  Perception of interactivity (desktop feel)  Can be asynchronous  Used by Google Maps and others
  • 10. Using an API  Screen scrape basics  Not a true client/server api.  Relies on regular expression matching of content.  Usually done over HTTP using cURL.  Breaks when server content changes.  Must download all content, so may be slow and resource intensive.
  • 11. Using an API  REST basics (main focus for this talk)  Client-Server  Stateless – each request is complete and self contained (struggle with sessions and cookies)  Cacheable  Layered – client cannot tell if using end-server, allows load balancers, caches, logging, auth.  Uniform interface – decoupled from architecture  Methods – GET, POST, PUT, DELETE, HEAD, OPTIONS, TRACE, CONNECT
  • 12. Using an API  REST safe methods  No side effects on the server  GET & HEAD should make no other action than to retrieve.  Allows user agents to represent POST, PUT, and DELETE special. (most browsers do not support PUT and DELETE out of the box)
  • 13. Using an API  Idempotence  Operations that can be applied multiple times without changing the result. (Ex.- N>0 identical requests would have the same output)  GET, HEAD, PUT, and DELETE share this property  OPTIONS and TRACE are inherently idempotent.
  • 14. Using an API  GET  Safe and idempotent  No effect on the server GET /books/9790482c HTTP/1.1 Host: example.com Accept-Encoding: identity, deflate, compress, gzip Accept: application/hal+json User-Agent: HTTPie/0.2.0
  • 15. Using an API  GET response HTTP/1.1 200 OK Date: Wed, 08 Aug 2012 09:32:42 GMT Server: Apache/2.2.22 (Ubuntu) X-Powered-By: PHP/5.3.10-1ubuntu3.2 ETag: “9790482c-1” Last-Modified: Wed, 08 Aug 2012 04:14:30 GMT Content-Length: 254 Content-Type: application/hal+json { “_links”: { “self”: { “href”: “http://example.com/books/9790482c” } }, “author”: “Luke Welling, Laura Thomson”, “id”: “9790482c”, “isbn10”: “0672329166”,
  • 16. Using an API  POST  Not safe  Not idempotent (same post multiple times could have different effects on server)  Used to create resource  Is often used to also update a resource, though PUT is more for updating.
  • 17. Using an API  POST example POST /books HTTP/1.1 HOST: example.com Content-Type: application/hal+json Accept-Encoding: identity, deflate, compress, gzip Accept: application/hal+json User-Agent: HTTPie/0.2.0 { “author”: “Stoyan Stefanov”, “isbn10”: “1449320198”, “isbn13”: “9781449320195”, “publisher”: “O'Reilly Media”, “title”: “Javascript for PHP Developers”, “year”: 2012 }
  • 18. Using an API  Created Response HTTP/1.1 201 Created Date: Sun, 29 Jul 2012 23:26:49 GMT Server: Apache/2.2.22 (Ubuntu) X-Powered-By: PHP/5.3.10-1ubuntu3.2 Location: http://example.com/books/decd0562 Etag: “decd0562-1” Last-Modified: Sun, 29 Jul 2012 23:26:49 GMT Content-Length: 239 Content-Type: application/hal+json { “_links”: { “self”: { “href”: “http://example.com/books/decd0562” } }, “author”: “Stoyan Stefanov”, “id”: “decd0562”, “isbn10”: “1449320198”,
  • 19. Using an API  PUT  Not safe  But is idempotent  Primarily an update action, but can also be used to create though POST should be used for that.
  • 20. Using an API  Sample PUT PUT /books/decd0562 HTTP/1.1 HOST: example.com Content-Type: application/hal+json Accept-Encoding: identity, deflate, compress, gzip If-Match: “decd0562-1” Accept: application/hal+json User-Agent: HTTPie/0.2.0 { “_links”: { “self”: { “href”: “http://example.com/books/decd0562” } } “author”: “Stoyan Stefanov”, “isbn10”: “1449320198”,
  • 21. Using an API  Update response HTTP/1.1 201 OK Date: Sun, 29 Jul 2012 23:26:49 GMT Server: Apache/2.2.22 (Ubuntu) X-Powered-By: PHP/5.3.10-1ubuntu3.2 Location: http://example.com/books/decd0562 Etag: “decd0562-2” Last-Modified: Sun, 29 Jul 2012 23:26:49 GMT Content-Length: 270 Content-Type: application/hal+json { “_links”: { “self”: { “href”: “http://example.com/books/decd0562” } }, “author”: “Stoyan Stefanov”, “id”: “decd0562”, “isbn10”: “1449320198”,
  • 22. Using an API  DELETE  Not safe  Is idempotent  Does not mean to remove the resource, but does mean to remove from public view. DELETE /books/decd0562 HTTP/1.1 Host: example.com Accept-Encoding: identity, deflate, compress, gzip Accept: application/hal+json User-Agent: HTTPie/0.2.0 If-Match: “decd0562-2”
  • 23. Using an API  DELETE response HTTP/1.1 204 No Content Date: Mon, 30 Jul 2012 00:01:44 GMT Server: Apache/2.2.22 (Ubuntu) X-Powered-By: PHP/5.3.10-1ubuntu3.2 Content-Length: 0 Content-Type: application/hal+json
  • 24. Using an API  HEAD  Same as GET, but doesn't return the body  An example of use would be to check content length before actually requesting it.
  • 25. Using an API  Status codes  Informational (1xx)  Successful (2xx)  Redirection (3xx)  Client error (4xx)  Server error (5xx)
  • 26. Using an API  Common usage  Most developers aren't building an API  Using for sites and application content  Leverage resources/services (Google Maps)  Cut development time, add functionality
  • 27. Using an API  Resources for great APIs available  Mashery.com  https://developer.mashery.com/apis  Apigee.com  https://apigee.com/providers  Google  https://developers.google.com Let's take a look!!!
  • 28. Using an API  Documention tools  Mashery http://mashery.github.com  I/O Docs – interactive API documentation  I/O Alfred – Alfred app to use some APIs  I/O Wraps – API client library generator  Oauth Signature Tool  Oauth 1.0 JS Testing Tool  AppMobi Sample Apps
  • 29. Using an API  Documentation tools  apigee  Providers list  “Console” to experiment with APIs  “Console To-Go” to add your own API  Usergrid – Backend as a service to get mobile apps running quickly.  O-Auth api
  • 30. Using an API  TO THE CODE!!!
  • 31. Using an API  Resources  http://www.charlesproxy.com  https://getfirebug.com  http://www.httpie.org  https://developer.mashery.com/apis  https://apigee.com/providers  https://developers.google.com
  • 32. Using an API  Thank You Adam Culp @adamculp http://geekyboy.com Please rate this talk at: http://joind.in/6739