SlideShare uma empresa Scribd logo
1 de 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

Mais conteúdo relacionado

Mais procurados

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
 

Mais procurados (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
 

Destaque

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
 

Destaque (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
 

Semelhante a 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
 

Semelhante a 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
 

Mais de 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
 

Último

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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

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
 
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
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
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...
 
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
 
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...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
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
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

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

Notas do Editor

  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