SlideShare ist ein Scribd-Unternehmen logo
1 von 20
API Best Practices
         @urilavi
    http://bit.ly/scisr
Public API/ Web API


 HTTP / HTTPS
 XML/JSON
Rule #0




   http://www.flickr.com/photos/holeymoon/2131118247/
Rule #1 - Funnel

          Try

          Build

         Adopt
Simplicity?
TDD public API
At least 3 clients
   Different languages




                     http://www.flickr.com/photos/giosp/3933753363/
Cross Cutting Concerns
 Authentication/Authorization
 Versioning
 Sync/Async
 Re-entrance
 Pagination
 Caching
 Throttling
RESTfulness              * Use plural names (reads
                         better with GET)

                         * Avoid methods (it isn’t
                         traversal and grows
                         fast)




Nouns (Method-less)
  2 base URLS per resource
       /events
       /events/10
RESTfulness
HTTP Verbs on collections/elements
  Create
      POST /events
  Fetch
      GET /events/12345
  Update
      PUT /events/12345
Method-based
               * Use verbs
               * Make the
               documentation clear
               that these are “non
               resource” operations




Convert
Translate
Rule #2 - Relationships
Rule #2 - Relationships


 Keep it simple - 3 levels
Rule #2 - Relationships


 Keep it simple - 3 levels

    GET /lecturers/events/10
Rule #3 - Complexity?




  http://www.flickr.com/photos/takomabibelot/4373062612/
Rule #4 - Versioning
                        * Maintain at least one
                        version back




 GET api/v1/events/10
Rule #4 - Versioning
                        * Maintain at least one
                        version back




 GET api/v1/events/10
Rule #5 - Errors

 HTTP status codes
    {200, 400, 500}
 Verbose messages
   link to documentation
Rule #6 - Sync / Async

 Result available - sync
 Result available in x time - async



                     PicScout’s API
Rule #7- Re-entrance




        http://www.flickr.com/photos/leovan/2152274834/


 POST /funds/accounts/1000/
 {‘value’: 100, ‘token’: ‘xbds213’}
Rule #8 - Formatting



 JaaD = JSON as a Default
Rule #9 - Automation?




        http://www.flickr.com/photos/r80o/39304743/


 APIs are for humans

Weitere ähnliche Inhalte

Was ist angesagt?

Browser Wars Episode 1: The Phantom Menace
Browser Wars Episode 1: The Phantom MenaceBrowser Wars Episode 1: The Phantom Menace
Browser Wars Episode 1: The Phantom Menace
Nicholas Zakas
 
[jqconatx] Adaptive Images for Responsive Web Design
[jqconatx] Adaptive Images for Responsive Web Design[jqconatx] Adaptive Images for Responsive Web Design
[jqconatx] Adaptive Images for Responsive Web Design
Christopher Schmitt
 
Fast and Easy Website Tuneups
Fast and Easy Website TuneupsFast and Easy Website Tuneups
Fast and Easy Website Tuneups
Jeff Wisniewski
 

Was ist angesagt? (20)

Sniffing the Mobile Context
Sniffing the Mobile ContextSniffing the Mobile Context
Sniffing the Mobile Context
 
Progressive Enhancement 2.0 (Conference Agnostic)
Progressive Enhancement 2.0 (Conference Agnostic)Progressive Enhancement 2.0 (Conference Agnostic)
Progressive Enhancement 2.0 (Conference Agnostic)
 
Browser Wars Episode 1: The Phantom Menace
Browser Wars Episode 1: The Phantom MenaceBrowser Wars Episode 1: The Phantom Menace
Browser Wars Episode 1: The Phantom Menace
 
State of jQuery '09
State of jQuery '09State of jQuery '09
State of jQuery '09
 
High Performance Websites
High Performance WebsitesHigh Performance Websites
High Performance Websites
 
Making the web faster
Making the web fasterMaking the web faster
Making the web faster
 
Speed is Essential for a Great Web Experience (Canvas Conf Version)
Speed is Essential for a Great Web Experience (Canvas Conf Version)Speed is Essential for a Great Web Experience (Canvas Conf Version)
Speed is Essential for a Great Web Experience (Canvas Conf Version)
 
[jqconatx] Adaptive Images for Responsive Web Design
[jqconatx] Adaptive Images for Responsive Web Design[jqconatx] Adaptive Images for Responsive Web Design
[jqconatx] Adaptive Images for Responsive Web Design
 
PC Monitoring Software
PC Monitoring SoftwarePC Monitoring Software
PC Monitoring Software
 
Keep the Web Fast
Keep the Web FastKeep the Web Fast
Keep the Web Fast
 
5 single page application principles developers need to know
5 single page application principles developers need to know5 single page application principles developers need to know
5 single page application principles developers need to know
 
SearchLove San Diego 2018 | Tom Anthony | An Introduction to HTTP/2 & Service...
SearchLove San Diego 2018 | Tom Anthony | An Introduction to HTTP/2 & Service...SearchLove San Diego 2018 | Tom Anthony | An Introduction to HTTP/2 & Service...
SearchLove San Diego 2018 | Tom Anthony | An Introduction to HTTP/2 & Service...
 
17 Web Performance Metrics You Should Care About
17 Web Performance Metrics You Should Care About17 Web Performance Metrics You Should Care About
17 Web Performance Metrics You Should Care About
 
How I learned to stop worrying and love the .htaccess file
How I learned to stop worrying and love the .htaccess fileHow I learned to stop worrying and love the .htaccess file
How I learned to stop worrying and love the .htaccess file
 
Word campktm speed-security
Word campktm speed-securityWord campktm speed-security
Word campktm speed-security
 
The Case for HTTP/2 - Internetdagarna 2015 - Stockholm
The Case for HTTP/2  - Internetdagarna 2015 - StockholmThe Case for HTTP/2  - Internetdagarna 2015 - Stockholm
The Case for HTTP/2 - Internetdagarna 2015 - Stockholm
 
Fast and Easy Website Tuneups
Fast and Easy Website TuneupsFast and Easy Website Tuneups
Fast and Easy Website Tuneups
 
Web Performance Optimization
Web Performance OptimizationWeb Performance Optimization
Web Performance Optimization
 
10 Tips to make your Website lightning-fast - SMX Stockholm 2012
10 Tips to make your Website lightning-fast - SMX Stockholm 201210 Tips to make your Website lightning-fast - SMX Stockholm 2012
10 Tips to make your Website lightning-fast - SMX Stockholm 2012
 
A faster journey with HTTP
A faster journey with HTTPA faster journey with HTTP
A faster journey with HTTP
 

Andere mochten auch

510G CV 150315 Shane Harris - General R6
510G CV 150315 Shane Harris - General R6510G CV 150315 Shane Harris - General R6
510G CV 150315 Shane Harris - General R6
Shane Harris
 

Andere mochten auch (13)

510G CV 150315 Shane Harris - General R6
510G CV 150315 Shane Harris - General R6510G CV 150315 Shane Harris - General R6
510G CV 150315 Shane Harris - General R6
 
Why don't we have REAL IP to the Edge in Buildings?
Why don't we have REAL IP to the Edge in Buildings?Why don't we have REAL IP to the Edge in Buildings?
Why don't we have REAL IP to the Edge in Buildings?
 
EL FUTURO DEL AGUA: TRATAMIENTO Y REUTILIZACIÓN.
EL FUTURO DEL AGUA:  TRATAMIENTO Y REUTILIZACIÓN.EL FUTURO DEL AGUA:  TRATAMIENTO Y REUTILIZACIÓN.
EL FUTURO DEL AGUA: TRATAMIENTO Y REUTILIZACIÓN.
 
Institutional Change and Parental Compensation in Intergenerational attainment
Institutional Change and Parental Compensation in Intergenerational attainmentInstitutional Change and Parental Compensation in Intergenerational attainment
Institutional Change and Parental Compensation in Intergenerational attainment
 
Презентация 1.20 - Радиофикация
Презентация 1.20 - РадиофикацияПрезентация 1.20 - Радиофикация
Презентация 1.20 - Радиофикация
 
Presentacion del sector
Presentacion del sectorPresentacion del sector
Presentacion del sector
 
Pri pro presentasion
Pri pro presentasionPri pro presentasion
Pri pro presentasion
 
My Presentation
My PresentationMy Presentation
My Presentation
 
Twitter for Researchers
Twitter for ResearchersTwitter for Researchers
Twitter for Researchers
 
Hcv - immune evasion mechanisms
Hcv - immune evasion mechanismsHcv - immune evasion mechanisms
Hcv - immune evasion mechanisms
 
Seres autenticos
Seres autenticosSeres autenticos
Seres autenticos
 
IoT DDoS Attacks: the stakes have changed
IoT DDoS Attacks: the stakes have changed IoT DDoS Attacks: the stakes have changed
IoT DDoS Attacks: the stakes have changed
 
Unit 2 Rules
Unit 2 RulesUnit 2 Rules
Unit 2 Rules
 

Ähnlich wie API Best Practices

Ruby HTTP clients comparison
Ruby HTTP clients comparisonRuby HTTP clients comparison
Ruby HTTP clients comparison
Hiroshi Nakamura
 
Automate That! Scripting Atlassian applications in Python
Automate That! Scripting Atlassian applications in PythonAutomate That! Scripting Atlassian applications in Python
Automate That! Scripting Atlassian applications in Python
Atlassian
 
Automate that
Automate thatAutomate that
Automate that
Atlassian
 
REST Web Sebvice
REST Web SebviceREST Web Sebvice
REST Web Sebvice
khmerforge
 
Android App Development 06 : Network & Web Services
Android App Development 06 : Network & Web ServicesAndroid App Development 06 : Network & Web Services
Android App Development 06 : Network & Web Services
Anuchit Chalothorn
 

Ähnlich wie API Best Practices (20)

Creating Great REST and gRPC API Experiences (in Swift)
Creating Great REST and gRPC API Experiences (in Swift)Creating Great REST and gRPC API Experiences (in Swift)
Creating Great REST and gRPC API Experiences (in Swift)
 
Talking to Web Services
Talking to Web ServicesTalking to Web Services
Talking to Web Services
 
High Availability by Design
High Availability by DesignHigh Availability by Design
High Availability by Design
 
URL Design
URL DesignURL Design
URL Design
 
ASP.NET WEB API Training
ASP.NET WEB API TrainingASP.NET WEB API Training
ASP.NET WEB API Training
 
distributing over the web
distributing over the webdistributing over the web
distributing over the web
 
Construindo APIs Usando Rails
Construindo APIs Usando RailsConstruindo APIs Usando Rails
Construindo APIs Usando Rails
 
Rapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devicesRapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devices
 
Performance #4 network
Performance #4  networkPerformance #4  network
Performance #4 network
 
Ruby HTTP clients comparison
Ruby HTTP clients comparisonRuby HTTP clients comparison
Ruby HTTP clients comparison
 
Rest with Spring
Rest with SpringRest with Spring
Rest with Spring
 
Automate That! Scripting Atlassian applications in Python
Automate That! Scripting Atlassian applications in PythonAutomate That! Scripting Atlassian applications in Python
Automate That! Scripting Atlassian applications in Python
 
Automate that
Automate thatAutomate that
Automate that
 
REST Web Sebvice
REST Web SebviceREST Web Sebvice
REST Web Sebvice
 
API Design- Best Practices
API Design-   Best PracticesAPI Design-   Best Practices
API Design- Best Practices
 
Rest web services
Rest web servicesRest web services
Rest web services
 
Android App Development 06 : Network & Web Services
Android App Development 06 : Network & Web ServicesAndroid App Development 06 : Network & Web Services
Android App Development 06 : Network & Web Services
 
Consuming GRIN GLOBAL Webservices
Consuming GRIN GLOBAL WebservicesConsuming GRIN GLOBAL Webservices
Consuming GRIN GLOBAL Webservices
 
JavaOne 2009 - TS-5276 - RESTful Protocol Buffers
JavaOne 2009 - TS-5276 - RESTful  Protocol BuffersJavaOne 2009 - TS-5276 - RESTful  Protocol Buffers
JavaOne 2009 - TS-5276 - RESTful Protocol Buffers
 
Service approach for development Rest API in Symfony2
Service approach for development Rest API in Symfony2Service approach for development Rest API in Symfony2
Service approach for development Rest API in Symfony2
 

Mehr von Uri Lavi (8)

JavaScript TDD
JavaScript TDDJavaScript TDD
JavaScript TDD
 
Intro to Mahout
Intro to MahoutIntro to Mahout
Intro to Mahout
 
Cloud Aware Architecture
Cloud Aware ArchitectureCloud Aware Architecture
Cloud Aware Architecture
 
Software craftsmanship - 4
Software craftsmanship - 4Software craftsmanship - 4
Software craftsmanship - 4
 
Software Craftsmanship - 3
Software Craftsmanship - 3Software Craftsmanship - 3
Software Craftsmanship - 3
 
Software Craftsmanship - 2
Software Craftsmanship - 2Software Craftsmanship - 2
Software Craftsmanship - 2
 
Software Craftsmanship - 1 Meeting
Software Craftsmanship - 1 MeetingSoftware Craftsmanship - 1 Meeting
Software Craftsmanship - 1 Meeting
 
Effective Code Review
Effective Code ReviewEffective Code Review
Effective Code Review
 

Kürzlich hochgeladen

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Kürzlich hochgeladen (20)

Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
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
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
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...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
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
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 

API Best Practices

  • 1. API Best Practices @urilavi http://bit.ly/scisr
  • 2. Public API/ Web API HTTP / HTTPS XML/JSON
  • 3. Rule #0 http://www.flickr.com/photos/holeymoon/2131118247/
  • 4. Rule #1 - Funnel Try Build Adopt
  • 5. Simplicity? TDD public API At least 3 clients Different languages http://www.flickr.com/photos/giosp/3933753363/
  • 6. Cross Cutting Concerns Authentication/Authorization Versioning Sync/Async Re-entrance Pagination Caching Throttling
  • 7. RESTfulness * Use plural names (reads better with GET) * Avoid methods (it isn’t traversal and grows fast) Nouns (Method-less) 2 base URLS per resource /events /events/10
  • 8. RESTfulness HTTP Verbs on collections/elements Create POST /events Fetch GET /events/12345 Update PUT /events/12345
  • 9. Method-based * Use verbs * Make the documentation clear that these are “non resource” operations Convert Translate
  • 10. Rule #2 - Relationships
  • 11. Rule #2 - Relationships Keep it simple - 3 levels
  • 12. Rule #2 - Relationships Keep it simple - 3 levels GET /lecturers/events/10
  • 13. Rule #3 - Complexity? http://www.flickr.com/photos/takomabibelot/4373062612/
  • 14. Rule #4 - Versioning * Maintain at least one version back GET api/v1/events/10
  • 15. Rule #4 - Versioning * Maintain at least one version back GET api/v1/events/10
  • 16. Rule #5 - Errors HTTP status codes {200, 400, 500} Verbose messages link to documentation
  • 17. Rule #6 - Sync / Async Result available - sync Result available in x time - async PicScout’s API
  • 18. Rule #7- Re-entrance http://www.flickr.com/photos/leovan/2152274834/ POST /funds/accounts/1000/ {‘value’: 100, ‘token’: ‘xbds213’}
  • 19. Rule #8 - Formatting JaaD = JSON as a Default
  • 20. Rule #9 - Automation? http://www.flickr.com/photos/r80o/39304743/ APIs are for humans

Hinweis der Redaktion

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n