SlideShare a Scribd company logo
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

More Related Content

What's hot

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
Arun Gupta
 
Plack at OSCON 2010
Plack at OSCON 2010Plack at OSCON 2010
Plack at OSCON 2010
Tatsuhiko Miyagawa
 
API Technical Writing
API Technical WritingAPI Technical Writing
API Technical Writing
Sarah Maddox
 
Understanding REST
Understanding RESTUnderstanding REST
Understanding REST
Nitin Pande
 
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
Security BSides Ahmedabad
 
The REST And Then Some
The REST And Then SomeThe REST And Then Some
The REST And Then Some
Nordic 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 jQuery
Tatsuhiko 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 ReST
Bruno Kessler Foundation
 
Designing a beautiful REST json api
Designing a beautiful REST json apiDesigning a beautiful REST json api
Designing a beautiful REST json api
0x07de
 
JSON REST API for WordPress
JSON REST API for WordPressJSON REST API for WordPress
JSON REST API for WordPress
Taylor 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 Islands
Bastian 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 Francisco
Ryan Weaver
 
Tornado web
Tornado webTornado web
Tornado web
kurtiss
 
Ruby in the Browser - RubyConf 2011
Ruby in the Browser - RubyConf 2011Ruby in the Browser - RubyConf 2011
Ruby in the Browser - RubyConf 2011
Ilya Grigorik
 
Maven 3.0 at Øredev
Maven 3.0 at ØredevMaven 3.0 at Øredev
Maven 3.0 at Øredev
Matthew McCullough
 
Ruby On Grape
Ruby On GrapeRuby On Grape
Ruby On Grape
Andrii Furmanets
 
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 APIs
Stormpath
 

What's hot (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
 

Similar to Using an API

eZ Publish REST API v2
eZ Publish REST API v2eZ Publish REST API v2
eZ Publish REST API v2
Bertrand Dunogier
 
E zsc2012 rest-api-v2
E zsc2012 rest-api-v2E zsc2012 rest-api-v2
E zsc2012 rest-api-v2
Bertrand Dunogier
 
Introduction to Apigility
Introduction to ApigilityIntroduction to Apigility
Introduction to Apigility
Engineor
 
Crafting APIs
Crafting APIsCrafting APIs
Crafting APIs
Tatiana Al-Chueyr
 
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 api
Tiago Knoch
 
Apigility introduction v2 (glasgow php)
Apigility introduction v2 (glasgow php)Apigility introduction v2 (glasgow php)
Apigility introduction v2 (glasgow php)
Engineor
 
Gohan
GohanGohan
Gohan
Nachi Ueno
 
APIs Demystified
APIs DemystifiedAPIs Demystified
APIs Demystified
Brandon West
 
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
 
Talking to Web Services
Talking to Web ServicesTalking to Web Services
Talking to Web Services
DrupalcampAtlanta2012
 
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
Tatsuhiko 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 API
Filip 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 platform
Nelson Kopliku
 
Using the new WordPress REST API
Using the new WordPress REST APIUsing the new WordPress REST API
Using the new WordPress REST API
Caldera Labs
 
Web Dev 21-01-2024.pptx
Web Dev 21-01-2024.pptxWeb Dev 21-01-2024.pptx
Web Dev 21-01-2024.pptx
PARDHIVANNABATTULA
 
The future of server side JavaScript
The future of server side JavaScriptThe future of server side JavaScript
The future of server side JavaScript
Oleg Podsechin
 

Similar to 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
 

More from Adam Culp

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

More from 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
 

Recently uploaded

Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdfNunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
flufftailshop
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 
Azure API Management to expose backend services securely
Azure API Management to expose backend services securelyAzure API Management to expose backend services securely
Azure API Management to expose backend services securely
Dinusha Kumarasiri
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
Wouter Lemaire
 
A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024
Intelisync
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
SitimaJohn
 
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - HiikeSystem Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
Hiike
 
Trusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process MiningTrusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process Mining
LucaBarbaro3
 
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStrDeep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
saastr
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
Postman
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
Zilliz
 

Recently uploaded (20)

Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdfNunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 
Azure API Management to expose backend services securely
Azure API Management to expose backend services securelyAzure API Management to expose backend services securely
Azure API Management to expose backend services securely
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
 
A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
 
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - HiikeSystem Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
 
Trusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process MiningTrusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process Mining
 
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStrDeep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
 

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