SlideShare ist ein Scribd-Unternehmen logo
1 von 49
Downloaden Sie, um offline zu lesen
Building Brilliant APIs
                         that bloody work




Monday, 4 October 2010
Jason Fry


                             @fry15
                          jasonfry.co.uk




Monday, 4 October 2010
Ben Collier



                @ben_c            @redsign
              bencollier.net     redsign.co.uk



Monday, 4 October 2010
Our Inspiration?


                    • Working with a terrible API



Monday, 4 October 2010
Our Inspiration?
                <xml>
                         <head>
                         </head>
                         <body>
                           <response>Random Useless Text</response>
                         </body>
                  </xml>



Monday, 4 October 2010
Why Build APIs?


                    • Mobile Applications
                    • Rich Web Applcations


Monday, 4 October 2010
Mobile Applications


                    • Enables your app to talk to your service
                    • Don’t just open database connections


Monday, 4 October 2010
Websites


                    • Optimisation
                    • Caching


Monday, 4 October 2010
Websites

                    • Twitter
                     • http://engineering.twitter.com
                    • Facebook


Monday, 4 October 2010
But...


                         “I’m not planning on building an API yet so
                                     why should I care?”




Monday, 4 October 2010
What Makes a Brilliant
                                API?



Monday, 4 October 2010
Naming

               • Use descriptive meaningful names
               • Don’t be afraid to use really long names
                         http://ws.audioscrobbler.com/2.0/?
                         method=user.gettopalbums&user=rj




Monday, 4 October 2010
Building URLs

                    • Base URI
                     • e.g. api.twitter.com/v2/
                    • Method
                     • e.g. statuses/user_timeline.xml

Monday, 4 October 2010
Responses


                    • XML / JSON
                    • Clear structure


Monday, 4 October 2010
Responses
         <topalbums user="RJ" type="overall">
          <album rank="1">
            <name>Images and Words</name>
            <playcount>174</playcount>
            <mbid>f20971f2-c8ad-4d26-91ab-730f6dedafb2</mbid>
            <url>
             http://www.last.fm/music/Dream+Theater/Images+and+Words
            </url>
            <artist>
             <name>Dream Theater</name>
             <mbid>28503ab7-8bf2-4666-a7bd-2644bfc7cb1d</mbid>
             <url>http://www.last.fm/music/Dream+Theater</url>
            </artist>
            <image size="small">...</image>
            <image size="medium">...</image>
            <image size="large">...</image>
          </album>
         </topalbums>

Monday, 4 October 2010
Error Codes

                    • Numbers which mean something
                    • Success, error
                     • Missing parameter x
                     • Parameter x must be 3 characters long
                     • etc etc

Monday, 4 October 2010
Types of APIs


               • SOAP

               • RESTful




Monday, 4 October 2010
Types of APIs


                         SOAP
                         Simple Object Access Protocol




Monday, 4 October 2010
Types of APIs


                         RESTful
                         Representable State Transfer




Monday, 4 October 2010
RESTful

                         Based on HTTP Request protocol




Monday, 4 October 2010
RESTful

                         Based on HTTP Request protocol


                 PUT          DELETE         GET          POST




Monday, 4 October 2010
RESTful

                         Based on HTTP Request protocol


                              GET             POST




                                     DELETE
                                      PUT




Monday, 4 October 2010
RESTful

                         Based on HTTP Request protocol


                              GET            POST




Monday, 4 October 2010
Versioning

                    • API version in URL
                    • eg http://locationtextvideoapi.com/2.0/
                    • Allows backwackwards compatibility
                         without sacrificing future versions




Monday, 4 October 2010
Authentication

                    • Two choices
                     • OAuth
                     • Basic (http / session)


Monday, 4 October 2010
Basic Authentication




Monday, 4 October 2010
Basic Authentication


                         Username   Password




Monday, 4 October 2010
Basic Authentication


                         Username     Password


                                    5f4dcc3b5aa765d6
                                    1d8327deb882cf99




Monday, 4 October 2010
Basic Authentication


                         Username     Password


                                    5f4dcc3b5aa765d6
                                    1d8327deb882cf99




Monday, 4 October 2010
OAuth


                         Open Standard   Greater Control   User Safety




Monday, 4 October 2010
Responses




Monday, 4 October 2010
Responses



                         XML      JSON     .plist




Monday, 4 October 2010
Responses

                                  Objects




                         XML       JSON     .plist




Monday, 4 October 2010
XML


                    • PHP DomDocument
                    • PEAR Library for exporting straight from
                         MySQL




Monday, 4 October 2010
JSON




Monday, 4 October 2010
JSON
                              $arr = 
            array ('a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5);




Monday, 4 October 2010
JSON
                              $arr = 
            array ('a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5);


                         echo json_encode($arr);




Monday, 4 October 2010
JSON
                              $arr = 
            array ('a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5);


                         echo json_encode($arr);



                         {"a":1,"b":2,"c":3,"d":4,"e":5}




Monday, 4 October 2010
UGC


                   Images



                                     Encoding.com
                  Audio /
                            FFMpeg
                   Video
                                      Vzaar.com

Monday, 4 October 2010
Media Links


                    • Link in a logical way
                    • Eg: http://apisrock.com/64x64/23456.jpg


Monday, 4 October 2010
Location Aware




                         Location based searching can be a bitch




Monday, 4 October 2010
Documentation




Monday, 4 October 2010
Documentation


                    • Do it



Monday, 4 October 2010
Documentation


                    • Do it
                    • Even if it’s not public facing- do it!


Monday, 4 October 2010
Hosting


                    • Build in PHP / MySQL
                     • Deployable on Amazon Web Services


Monday, 4 October 2010
Some Good Examples


                    • Last.fm
                    • Twitter
                    • Foursquare


Monday, 4 October 2010
Any questions?


                    • Good.



Monday, 4 October 2010
Thanks
                     Ben Collier            Jason Fry
                   me@bencollier.net   jason@jasonfry.co.uk
                       @ben_c                 @fry15




Monday, 4 October 2010
Thanks
                     Ben Collier            Jason Fry
                   me@bencollier.net   jason@jasonfry.co.uk
                       @ben_c                 @fry15
  Bubble Image- http://www.flickr.com/photos/philippbunge/
    Hammock- http://www.flickr.com/photos/ironrodart/
     Padlock- http://www.flickr.com/photos/sooperkuh/
      Binary Windows - http://www.flickr.com/photos/
                       9619972@N08/
   Boxing Lemur - http://www.flickr.com/photos/e_phots/
                 Earth from Space - NASA
Monday, 4 October 2010

Weitere ähnliche Inhalte

Ähnlich wie Building Brilliant APIs

ExpressionEngine FUGN presentation
ExpressionEngine FUGN presentationExpressionEngine FUGN presentation
ExpressionEngine FUGN presentationJens Brynildsen
 
BRAINREPUBLIC - Powered by no-SQL
BRAINREPUBLIC - Powered by no-SQLBRAINREPUBLIC - Powered by no-SQL
BRAINREPUBLIC - Powered by no-SQLAndreas Jung
 
let's talk web standards
let's talk web standardslet's talk web standards
let's talk web standardsZi Bin Cheah
 
In depth with html5 java2days 2010
In depth with html5 java2days 2010In depth with html5 java2days 2010
In depth with html5 java2days 2010Mystic Coders, LLC
 
Opening up the Social Web - Standards that are bridging the Islands
Opening up the Social Web - Standards that are bridging the Islands Opening up the Social Web - Standards that are bridging the Islands
Opening up the Social Web - Standards that are bridging the Islands Bastian Hofmann
 
OSMC 2010 | OpenNMS Kickstart by Ronny Trommer
OSMC 2010 | OpenNMS Kickstart by Ronny TrommerOSMC 2010 | OpenNMS Kickstart by Ronny Trommer
OSMC 2010 | OpenNMS Kickstart by Ronny TrommerNETWAYS
 
ツイキャス・東京ユーザー会 資料
ツイキャス・東京ユーザー会 資料ツイキャス・東京ユーザー会 資料
ツイキャス・東京ユーザー会 資料yoski
 
Sdforum 11-04-2010
Sdforum 11-04-2010Sdforum 11-04-2010
Sdforum 11-04-2010Ted Dunning
 
Debugging your JavaScript
Debugging your JavaScriptDebugging your JavaScript
Debugging your JavaScriptDiogo Antunes
 
Large problems, Mostly Solved
Large problems, Mostly SolvedLarge problems, Mostly Solved
Large problems, Mostly Solvedericholscher
 
Persistence Smoothie: Blending SQL and NoSQL (RubyNation Edition)
Persistence  Smoothie: Blending SQL and NoSQL (RubyNation Edition)Persistence  Smoothie: Blending SQL and NoSQL (RubyNation Edition)
Persistence Smoothie: Blending SQL and NoSQL (RubyNation Edition)Michael Bleigh
 
Crowd-sourced Automated Firefox UI Testing
Crowd-sourced Automated Firefox UI TestingCrowd-sourced Automated Firefox UI Testing
Crowd-sourced Automated Firefox UI TestingHenrik Skupin
 
MongoDB on Rails (and Ruby)
MongoDB on Rails (and Ruby)MongoDB on Rails (and Ruby)
MongoDB on Rails (and Ruby)jan_mindmatters
 
Using+javascript+to+build+native+i os+applications
Using+javascript+to+build+native+i os+applicationsUsing+javascript+to+build+native+i os+applications
Using+javascript+to+build+native+i os+applicationsMuhammad Ikram Ul Haq
 
livedoor における Twitter 活用事例と個人的趣味な小ネタたちのご紹介
livedoor における Twitter 活用事例と個人的趣味な小ネタたちのご紹介livedoor における Twitter 活用事例と個人的趣味な小ネタたちのご紹介
livedoor における Twitter 活用事例と個人的趣味な小ネタたちのご紹介Koichi Taniguchi
 
Html5/CSS3 in shanghai 2010
Html5/CSS3 in shanghai 2010Html5/CSS3 in shanghai 2010
Html5/CSS3 in shanghai 2010Zi Bin Cheah
 

Ähnlich wie Building Brilliant APIs (20)

ExpressionEngine FUGN presentation
ExpressionEngine FUGN presentationExpressionEngine FUGN presentation
ExpressionEngine FUGN presentation
 
BRAINREPUBLIC - Powered by no-SQL
BRAINREPUBLIC - Powered by no-SQLBRAINREPUBLIC - Powered by no-SQL
BRAINREPUBLIC - Powered by no-SQL
 
let's talk web standards
let's talk web standardslet's talk web standards
let's talk web standards
 
In depth with html5 java2days 2010
In depth with html5 java2days 2010In depth with html5 java2days 2010
In depth with html5 java2days 2010
 
Opening up the Social Web - Standards that are bridging the Islands
Opening up the Social Web - Standards that are bridging the Islands Opening up the Social Web - Standards that are bridging the Islands
Opening up the Social Web - Standards that are bridging the Islands
 
OSMC 2010 | OpenNMS Kickstart by Ronny Trommer
OSMC 2010 | OpenNMS Kickstart by Ronny TrommerOSMC 2010 | OpenNMS Kickstart by Ronny Trommer
OSMC 2010 | OpenNMS Kickstart by Ronny Trommer
 
ツイキャス・東京ユーザー会 資料
ツイキャス・東京ユーザー会 資料ツイキャス・東京ユーザー会 資料
ツイキャス・東京ユーザー会 資料
 
Sdforum 11-04-2010
Sdforum 11-04-2010Sdforum 11-04-2010
Sdforum 11-04-2010
 
SD Forum 11 04-2010
SD Forum 11 04-2010SD Forum 11 04-2010
SD Forum 11 04-2010
 
Debugging your JavaScript
Debugging your JavaScriptDebugging your JavaScript
Debugging your JavaScript
 
Enterprise Drupal
Enterprise DrupalEnterprise Drupal
Enterprise Drupal
 
Large problems, Mostly Solved
Large problems, Mostly SolvedLarge problems, Mostly Solved
Large problems, Mostly Solved
 
Persistence Smoothie: Blending SQL and NoSQL (RubyNation Edition)
Persistence  Smoothie: Blending SQL and NoSQL (RubyNation Edition)Persistence  Smoothie: Blending SQL and NoSQL (RubyNation Edition)
Persistence Smoothie: Blending SQL and NoSQL (RubyNation Edition)
 
Crowd-sourced Automated Firefox UI Testing
Crowd-sourced Automated Firefox UI TestingCrowd-sourced Automated Firefox UI Testing
Crowd-sourced Automated Firefox UI Testing
 
MongoDB on Rails (and Ruby)
MongoDB on Rails (and Ruby)MongoDB on Rails (and Ruby)
MongoDB on Rails (and Ruby)
 
Using+javascript+to+build+native+i os+applications
Using+javascript+to+build+native+i os+applicationsUsing+javascript+to+build+native+i os+applications
Using+javascript+to+build+native+i os+applications
 
Meet Couch DB
Meet Couch DBMeet Couch DB
Meet Couch DB
 
Is these a bug
Is these a bugIs these a bug
Is these a bug
 
livedoor における Twitter 活用事例と個人的趣味な小ネタたちのご紹介
livedoor における Twitter 活用事例と個人的趣味な小ネタたちのご紹介livedoor における Twitter 活用事例と個人的趣味な小ネタたちのご紹介
livedoor における Twitter 活用事例と個人的趣味な小ネタたちのご紹介
 
Html5/CSS3 in shanghai 2010
Html5/CSS3 in shanghai 2010Html5/CSS3 in shanghai 2010
Html5/CSS3 in shanghai 2010
 

Kürzlich hochgeladen

activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfJamie (Taka) Wang
 
How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?IES VE
 
UiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPathCommunity
 
Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URLRuncy Oommen
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6DianaGray10
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfDianaGray10
 
Empowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintEmpowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintMahmoud Rabie
 
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDELiveplex
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaborationbruanjhuli
 
Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024SkyPlanner
 
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsIgniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsSafe Software
 
VoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBXVoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBXTarek Kalaji
 
COMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a WebsiteCOMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a Websitedgelyza
 
Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1DianaGray10
 
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Will Schroeder
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAshyamraj55
 
Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Brian Pichman
 
Comparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioComparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioChristian Posta
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxMatsuo Lab
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Commit University
 

Kürzlich hochgeladen (20)

activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
 
How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?
 
UiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation Developers
 
Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URL
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
 
Empowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintEmpowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership Blueprint
 
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
 
Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024
 
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsIgniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
 
VoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBXVoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBX
 
COMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a WebsiteCOMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a Website
 
Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1
 
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
 
Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )
 
Comparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioComparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and Istio
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptx
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)
 

Building Brilliant APIs

  • 1. Building Brilliant APIs that bloody work Monday, 4 October 2010
  • 2. Jason Fry @fry15 jasonfry.co.uk Monday, 4 October 2010
  • 3. Ben Collier @ben_c @redsign bencollier.net redsign.co.uk Monday, 4 October 2010
  • 4. Our Inspiration? • Working with a terrible API Monday, 4 October 2010
  • 5. Our Inspiration? <xml> <head> </head> <body> <response>Random Useless Text</response> </body> </xml> Monday, 4 October 2010
  • 6. Why Build APIs? • Mobile Applications • Rich Web Applcations Monday, 4 October 2010
  • 7. Mobile Applications • Enables your app to talk to your service • Don’t just open database connections Monday, 4 October 2010
  • 8. Websites • Optimisation • Caching Monday, 4 October 2010
  • 9. Websites • Twitter • http://engineering.twitter.com • Facebook Monday, 4 October 2010
  • 10. But... “I’m not planning on building an API yet so why should I care?” Monday, 4 October 2010
  • 11. What Makes a Brilliant API? Monday, 4 October 2010
  • 12. Naming • Use descriptive meaningful names • Don’t be afraid to use really long names http://ws.audioscrobbler.com/2.0/? method=user.gettopalbums&user=rj Monday, 4 October 2010
  • 13. Building URLs • Base URI • e.g. api.twitter.com/v2/ • Method • e.g. statuses/user_timeline.xml Monday, 4 October 2010
  • 14. Responses • XML / JSON • Clear structure Monday, 4 October 2010
  • 15. Responses <topalbums user="RJ" type="overall"> <album rank="1"> <name>Images and Words</name> <playcount>174</playcount> <mbid>f20971f2-c8ad-4d26-91ab-730f6dedafb2</mbid> <url> http://www.last.fm/music/Dream+Theater/Images+and+Words </url> <artist> <name>Dream Theater</name> <mbid>28503ab7-8bf2-4666-a7bd-2644bfc7cb1d</mbid> <url>http://www.last.fm/music/Dream+Theater</url> </artist> <image size="small">...</image> <image size="medium">...</image> <image size="large">...</image> </album> </topalbums> Monday, 4 October 2010
  • 16. Error Codes • Numbers which mean something • Success, error • Missing parameter x • Parameter x must be 3 characters long • etc etc Monday, 4 October 2010
  • 17. Types of APIs • SOAP • RESTful Monday, 4 October 2010
  • 18. Types of APIs SOAP Simple Object Access Protocol Monday, 4 October 2010
  • 19. Types of APIs RESTful Representable State Transfer Monday, 4 October 2010
  • 20. RESTful Based on HTTP Request protocol Monday, 4 October 2010
  • 21. RESTful Based on HTTP Request protocol PUT DELETE GET POST Monday, 4 October 2010
  • 22. RESTful Based on HTTP Request protocol GET POST DELETE PUT Monday, 4 October 2010
  • 23. RESTful Based on HTTP Request protocol GET POST Monday, 4 October 2010
  • 24. Versioning • API version in URL • eg http://locationtextvideoapi.com/2.0/ • Allows backwackwards compatibility without sacrificing future versions Monday, 4 October 2010
  • 25. Authentication • Two choices • OAuth • Basic (http / session) Monday, 4 October 2010
  • 27. Basic Authentication Username Password Monday, 4 October 2010
  • 28. Basic Authentication Username Password 5f4dcc3b5aa765d6 1d8327deb882cf99 Monday, 4 October 2010
  • 29. Basic Authentication Username Password 5f4dcc3b5aa765d6 1d8327deb882cf99 Monday, 4 October 2010
  • 30. OAuth Open Standard Greater Control User Safety Monday, 4 October 2010
  • 32. Responses XML JSON .plist Monday, 4 October 2010
  • 33. Responses Objects XML JSON .plist Monday, 4 October 2010
  • 34. XML • PHP DomDocument • PEAR Library for exporting straight from MySQL Monday, 4 October 2010
  • 36. JSON $arr =  array ('a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5); Monday, 4 October 2010
  • 37. JSON $arr =  array ('a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5); echo json_encode($arr); Monday, 4 October 2010
  • 38. JSON $arr =  array ('a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5); echo json_encode($arr); {"a":1,"b":2,"c":3,"d":4,"e":5} Monday, 4 October 2010
  • 39. UGC Images Encoding.com Audio / FFMpeg Video Vzaar.com Monday, 4 October 2010
  • 40. Media Links • Link in a logical way • Eg: http://apisrock.com/64x64/23456.jpg Monday, 4 October 2010
  • 41. Location Aware Location based searching can be a bitch Monday, 4 October 2010
  • 43. Documentation • Do it Monday, 4 October 2010
  • 44. Documentation • Do it • Even if it’s not public facing- do it! Monday, 4 October 2010
  • 45. Hosting • Build in PHP / MySQL • Deployable on Amazon Web Services Monday, 4 October 2010
  • 46. Some Good Examples • Last.fm • Twitter • Foursquare Monday, 4 October 2010
  • 47. Any questions? • Good. Monday, 4 October 2010
  • 48. Thanks Ben Collier Jason Fry me@bencollier.net jason@jasonfry.co.uk @ben_c @fry15 Monday, 4 October 2010
  • 49. Thanks Ben Collier Jason Fry me@bencollier.net jason@jasonfry.co.uk @ben_c @fry15 Bubble Image- http://www.flickr.com/photos/philippbunge/ Hammock- http://www.flickr.com/photos/ironrodart/ Padlock- http://www.flickr.com/photos/sooperkuh/ Binary Windows - http://www.flickr.com/photos/ 9619972@N08/ Boxing Lemur - http://www.flickr.com/photos/e_phots/ Earth from Space - NASA Monday, 4 October 2010