SlideShare a Scribd company logo
1 of 21
HABILELABS PVT. LTD.
YOUR INTEREST OUR INTELLIGENCE
Habilelabs REST API Guidelines
Shankar Morwal
CTO and co-founder
CONTENTS
1. Naming convention
2. Error Handling
3. Versioning
4. Partial Request and pagination
5. Tips
1. API NAMING CONVENTION
NOUNS ARE GOOD, VERBS ARE BAD.
• Keep your URL simple and intuitive.
• Keep Verbs out of your base URLs.
• Use HTTP verbs like GET, POST, UPDATE, DELETE to work on the collections.
• Plural names are better then singular names.
• Some companies use singular but we use plural.
• Use concrete names then using short names.
Collection GET POST Update Delete
/projects List all projects Create a
project
Bulk update
projects
Delete all
project
/projects/:id List one project Error Update a
project if exist
else a error
Delete a
project.
GOOD API NAMES EXAMPLES
BAD NAMES(VERBS) EXAMPLES
/getAllProjects
/deleteAllProjects
/deleteProject
/createProject
/updateProject
/filterProject
/proj (short name)
SIMPLE ASSOCIATIONS USING GOOD NAMES
• Use name convention as /resource/identifier/resource
List all user projects
Good URL
user/:id/projects
Bad : /listAllUserProjects
• If associations are complex then sweep complexity behind the ‘?’ .
Eg. /projects?stage=‘open’&&?value=0,1000
2. ERROR HANDLING IN APIS
ERROR CODE CONVENTIONS
• Many companies use different error code conventions.
• Use HTTP status codes and try to map them cleanly to relevant standard-based codes. There are over 70
HTTP status codes. However, most developers don't have all 70 memorized. So we do not use them all.
• Facebook use only error code 200.
MAKE RETURNED MESSAGES AS VERBOSE AS POSSIBLE.
EXAMPLE : UNAUTHORIZED REQUEST FOR DIFFERENT
COMPANIES
CONFUSED ??
WHAT HABILELABS USE?
RECOMMENDED STATUS CODES
• 200 Ok (All went well)
• 400 bad request (Some required param is missing)
• 401 – Unauthorized ( User not login in. Consumer(Web app, mobile app) of this API should redirect to
Login page.)
• 403 Forbidden/ Access denied (logged user does not have access to this resource)
• 500 Internal server error (something went wrong on server)
VERSIONING
TIPS FOR VERSIONING
• Versioning is one of the most important considerations when designing your
Web API.
• Never release a API without using a version numbers
RECOMMENDED FOR HABILELABS
• We will use version number programmatically.
• Use /version/resource
• Examples
/v1/projects
/v1/projects/:id
/v2/user/:id/projects
PAGINATION AND PARTIAL REQUEST
PAGINATION AND PARTIAL REQUEST
• What others do ?
WHAT WE WILL USE ?
We recommend to use facebook style
/v1/projects?limit=25&offset=50
Limit : number of projects
Offset : Skip these records
Defaults
/v1/projects
Offset = 0
Limit = 10
OTHER IMPORTANT POINTS
• Never use get request to delete a Resource.
• In Json reponse user camelcase in reponse
• Use partial response syntax.
/v1/projects/?fields=name,id,stage
• Consolidate API requests in one subdomain
graph.facebook.com
api.facebook.com
Questions ?
For any questions drop me line at Shankar@habilelabs.io

More Related Content

What's hot

Mobile APIs: Optimizing APIs for Many Devices
Mobile APIs: Optimizing APIs for Many DevicesMobile APIs: Optimizing APIs for Many Devices
Mobile APIs: Optimizing APIs for Many Devices
Apigee | Google Cloud
 
Designing your API Server for mobile apps
Designing your API Server for mobile appsDesigning your API Server for mobile apps
Designing your API Server for mobile apps
Mugunth Kumar
 
Building Awesome APIs in Grails
Building Awesome APIs in GrailsBuilding Awesome APIs in Grails
Building Awesome APIs in Grails
clatimer
 

What's hot (20)

Mobile APIs: Optimizing APIs for Many Devices
Mobile APIs: Optimizing APIs for Many DevicesMobile APIs: Optimizing APIs for Many Devices
Mobile APIs: Optimizing APIs for Many Devices
 
Presentation for soap ui
Presentation for soap uiPresentation for soap ui
Presentation for soap ui
 
The API Facade Pattern: Common Patterns - Episode 2
The API Facade Pattern: Common Patterns - Episode 2The API Facade Pattern: Common Patterns - Episode 2
The API Facade Pattern: Common Patterns - Episode 2
 
Why vREST?
Why vREST?Why vREST?
Why vREST?
 
Multi-Team Development w Ember, Angular, Knockout etc @ Interactive Intelligence
Multi-Team Development w Ember, Angular, Knockout etc @ Interactive IntelligenceMulti-Team Development w Ember, Angular, Knockout etc @ Interactive Intelligence
Multi-Team Development w Ember, Angular, Knockout etc @ Interactive Intelligence
 
Creating an Effective Mobile API
Creating an Effective Mobile API Creating an Effective Mobile API
Creating an Effective Mobile API
 
API Test Automation Tips and Tricks
API Test Automation Tips and TricksAPI Test Automation Tips and Tricks
API Test Automation Tips and Tricks
 
SEO In Joomla - Patrick Jackson (JoomlaDay Melbourne & Sydney 2010)
SEO In Joomla - Patrick Jackson (JoomlaDay Melbourne & Sydney 2010)SEO In Joomla - Patrick Jackson (JoomlaDay Melbourne & Sydney 2010)
SEO In Joomla - Patrick Jackson (JoomlaDay Melbourne & Sydney 2010)
 
継続的な開発スタイル 「AbemaTV iOSアプリを週一でリリースしている話」
継続的な開発スタイル 「AbemaTV iOSアプリを週一でリリースしている話」継続的な開発スタイル 「AbemaTV iOSアプリを週一でリリースしている話」
継続的な開発スタイル 「AbemaTV iOSアプリを週一でリリースしている話」
 
Designing your API Server for mobile apps
Designing your API Server for mobile appsDesigning your API Server for mobile apps
Designing your API Server for mobile apps
 
Nom Nom: Consuming REST APIs
Nom Nom: Consuming REST APIsNom Nom: Consuming REST APIs
Nom Nom: Consuming REST APIs
 
Automate REST API Testing
Automate REST API TestingAutomate REST API Testing
Automate REST API Testing
 
Server-provided animations in iOS apps
Server-provided animations in iOS appsServer-provided animations in iOS apps
Server-provided animations in iOS apps
 
Miracle Inameti-Archibong - We made our website a progressive web app and why...
Miracle Inameti-Archibong - We made our website a progressive web app and why...Miracle Inameti-Archibong - We made our website a progressive web app and why...
Miracle Inameti-Archibong - We made our website a progressive web app and why...
 
Facebook app development
Facebook app developmentFacebook app development
Facebook app development
 
API Testing with Open Source Code and Cucumber
API Testing with Open Source Code and CucumberAPI Testing with Open Source Code and Cucumber
API Testing with Open Source Code and Cucumber
 
IAP introduce@myBook
IAP introduce@myBook IAP introduce@myBook
IAP introduce@myBook
 
Live Panel: Appium Core Committers Answer Your Questions
Live Panel: Appium Core Committers Answer Your Questions		Live Panel: Appium Core Committers Answer Your Questions
Live Panel: Appium Core Committers Answer Your Questions
 
Building Awesome APIs in Grails
Building Awesome APIs in GrailsBuilding Awesome APIs in Grails
Building Awesome APIs in Grails
 
API Test Automation
API Test Automation API Test Automation
API Test Automation
 

Similar to Rest API Guidelines by HabileLabs

Web REST APIs Design Principles
Web REST APIs Design PrinciplesWeb REST APIs Design Principles
Web REST APIs Design Principles
Anji Beeravalli
 

Similar to Rest API Guidelines by HabileLabs (20)

Building a REST API for Longevity
Building a REST API for LongevityBuilding a REST API for Longevity
Building a REST API for Longevity
 
API Workshop Amsterdam presented by API Architect Ronnie Mitra
API Workshop Amsterdam presented by API Architect Ronnie MitraAPI Workshop Amsterdam presented by API Architect Ronnie Mitra
API Workshop Amsterdam presented by API Architect Ronnie Mitra
 
Web REST APIs Design Principles
Web REST APIs Design PrinciplesWeb REST APIs Design Principles
Web REST APIs Design Principles
 
Lessons learned on the Azure API Stewardship Journey.pptx
Lessons learned on the Azure API Stewardship Journey.pptxLessons learned on the Azure API Stewardship Journey.pptx
Lessons learned on the Azure API Stewardship Journey.pptx
 
How to design effective APIs
How to design effective APIsHow to design effective APIs
How to design effective APIs
 
Building A Great API - Evan Cooke, Cloudstock, December 2010
Building A Great API - Evan Cooke, Cloudstock, December 2010Building A Great API - Evan Cooke, Cloudstock, December 2010
Building A Great API - Evan Cooke, Cloudstock, December 2010
 
Web API Basics
Web API BasicsWeb API Basics
Web API Basics
 
Building the Eventbrite API Ecosystem
Building the Eventbrite API EcosystemBuilding the Eventbrite API Ecosystem
Building the Eventbrite API Ecosystem
 
Approaching APIs
Approaching APIsApproaching APIs
Approaching APIs
 
DataHero / Eventbrite - API Best Practices
DataHero / Eventbrite - API Best PracticesDataHero / Eventbrite - API Best Practices
DataHero / Eventbrite - API Best Practices
 
Scaling API Design - Nordic APIs 2014
Scaling API Design - Nordic APIs 2014Scaling API Design - Nordic APIs 2014
Scaling API Design - Nordic APIs 2014
 
Scaling API Design
Scaling API DesignScaling API Design
Scaling API Design
 
Restful api design
Restful api designRestful api design
Restful api design
 
Web API Design
Web API DesignWeb API Design
Web API Design
 
Web API Design: Crafting Interfaces that Developers Love
Web API Design:  Crafting Interfaces that Developers LoveWeb API Design:  Crafting Interfaces that Developers Love
Web API Design: Crafting Interfaces that Developers Love
 
Most Commonly Seen API Errors (2022)
Most Commonly Seen API Errors (2022)Most Commonly Seen API Errors (2022)
Most Commonly Seen API Errors (2022)
 
New in the Visual Studio 2012 IDE
New in the Visual Studio 2012 IDENew in the Visual Studio 2012 IDE
New in the Visual Studio 2012 IDE
 
Tools and techniques for APIs
Tools and techniques for APIsTools and techniques for APIs
Tools and techniques for APIs
 
Recipes for API Ninjas
Recipes for API NinjasRecipes for API Ninjas
Recipes for API Ninjas
 
Contributing to StrongLoop LoopBack (and other open source projects)
Contributing to StrongLoop LoopBack (and other open source projects)Contributing to StrongLoop LoopBack (and other open source projects)
Contributing to StrongLoop LoopBack (and other open source projects)
 

More from Habilelabs

More from Habilelabs (9)

Basics of MongoDB
Basics of MongoDB Basics of MongoDB
Basics of MongoDB
 
Top 10 frameworks of node js
Top 10 frameworks of node jsTop 10 frameworks of node js
Top 10 frameworks of node js
 
Salesforce Tutorial for Beginners: Basic Salesforce Introduction
Salesforce Tutorial for Beginners: Basic Salesforce IntroductionSalesforce Tutorial for Beginners: Basic Salesforce Introduction
Salesforce Tutorial for Beginners: Basic Salesforce Introduction
 
Introduction to Protractor - Habilelabs
Introduction to Protractor - HabilelabsIntroduction to Protractor - Habilelabs
Introduction to Protractor - Habilelabs
 
MongoDB Security Introduction - Presentation
MongoDB Security Introduction - PresentationMongoDB Security Introduction - Presentation
MongoDB Security Introduction - Presentation
 
MongoDB with NodeJS - Presentation
MongoDB with NodeJS - PresentationMongoDB with NodeJS - Presentation
MongoDB with NodeJS - Presentation
 
JAVASCRIPT PERFORMANCE PATTERN - A Presentation
JAVASCRIPT PERFORMANCE PATTERN - A PresentationJAVASCRIPT PERFORMANCE PATTERN - A Presentation
JAVASCRIPT PERFORMANCE PATTERN - A Presentation
 
A Presentation on MongoDB Introduction - Habilelabs
A Presentation on MongoDB Introduction - HabilelabsA Presentation on MongoDB Introduction - Habilelabs
A Presentation on MongoDB Introduction - Habilelabs
 
Why MongoDB over other Databases - Habilelabs
Why MongoDB over other Databases - HabilelabsWhy MongoDB over other Databases - Habilelabs
Why MongoDB over other Databases - Habilelabs
 

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

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
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
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
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
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
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
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...
 
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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 

Rest API Guidelines by HabileLabs

  • 1. HABILELABS PVT. LTD. YOUR INTEREST OUR INTELLIGENCE
  • 2. Habilelabs REST API Guidelines Shankar Morwal CTO and co-founder
  • 3. CONTENTS 1. Naming convention 2. Error Handling 3. Versioning 4. Partial Request and pagination 5. Tips
  • 4. 1. API NAMING CONVENTION
  • 5. NOUNS ARE GOOD, VERBS ARE BAD. • Keep your URL simple and intuitive. • Keep Verbs out of your base URLs. • Use HTTP verbs like GET, POST, UPDATE, DELETE to work on the collections. • Plural names are better then singular names. • Some companies use singular but we use plural. • Use concrete names then using short names.
  • 6. Collection GET POST Update Delete /projects List all projects Create a project Bulk update projects Delete all project /projects/:id List one project Error Update a project if exist else a error Delete a project. GOOD API NAMES EXAMPLES
  • 8. SIMPLE ASSOCIATIONS USING GOOD NAMES • Use name convention as /resource/identifier/resource List all user projects Good URL user/:id/projects Bad : /listAllUserProjects • If associations are complex then sweep complexity behind the ‘?’ . Eg. /projects?stage=‘open’&&?value=0,1000
  • 10. ERROR CODE CONVENTIONS • Many companies use different error code conventions. • Use HTTP status codes and try to map them cleanly to relevant standard-based codes. There are over 70 HTTP status codes. However, most developers don't have all 70 memorized. So we do not use them all. • Facebook use only error code 200.
  • 11. MAKE RETURNED MESSAGES AS VERBOSE AS POSSIBLE. EXAMPLE : UNAUTHORIZED REQUEST FOR DIFFERENT COMPANIES
  • 13. RECOMMENDED STATUS CODES • 200 Ok (All went well) • 400 bad request (Some required param is missing) • 401 – Unauthorized ( User not login in. Consumer(Web app, mobile app) of this API should redirect to Login page.) • 403 Forbidden/ Access denied (logged user does not have access to this resource) • 500 Internal server error (something went wrong on server)
  • 15. TIPS FOR VERSIONING • Versioning is one of the most important considerations when designing your Web API. • Never release a API without using a version numbers
  • 16. RECOMMENDED FOR HABILELABS • We will use version number programmatically. • Use /version/resource • Examples /v1/projects /v1/projects/:id /v2/user/:id/projects
  • 18. PAGINATION AND PARTIAL REQUEST • What others do ?
  • 19. WHAT WE WILL USE ? We recommend to use facebook style /v1/projects?limit=25&offset=50 Limit : number of projects Offset : Skip these records Defaults /v1/projects Offset = 0 Limit = 10
  • 20. OTHER IMPORTANT POINTS • Never use get request to delete a Resource. • In Json reponse user camelcase in reponse • Use partial response syntax. /v1/projects/?fields=name,id,stage • Consolidate API requests in one subdomain graph.facebook.com api.facebook.com
  • 21. Questions ? For any questions drop me line at Shankar@habilelabs.io