SlideShare a Scribd company logo
1 of 21
HABILELABS PVT. LTD.
YOUR INTEREST OUR INTELLIGENCE
4 BASIC API DESIGN GUIDELINES
4 BASIC API DESIGN GUIDELINES
1. Naming convention
2. Error Handling and status codes
3. Versioning
4. Pagination and Partial request
1. 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
BAD NAMES(VERBS)
/getAllProjects
/deleteAllProjects
/deleteProject
/createProject
/updateProject
/filterProject
/proj (short name)
SIMPLIFY ASSOCIATIONS
• 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 & STATUS CODE
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
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)
3. 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 YOU
• We will use version number programmatically.
• Use /version/resource
• Examples
/v1/projects
/v1/projects/:id
/v2/user/:id/projects
4. PAGINATION AND PARTIAL REQUEST
PAGINATION AND PARTIAL REQUEST
• What others do ?
Read Complete Post Here:
WHAT YOU SHOULD 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
CONTACT US
Visit Habilelabs: http://www.habilelabs.io/
Contact us: http://www.habilelabs.io/contact-us/
Like us at facebook: https://www.facebook.com/habilelabs/
THANK YOU
http://www.habilelabs.io/

More Related Content

What's hot

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)Patrick Jackson
 
Pepperoni 2.0 - How to spice up your mobile apps
Pepperoni 2.0 - How to spice up your mobile apps Pepperoni 2.0 - How to spice up your mobile apps
Pepperoni 2.0 - How to spice up your mobile apps Futurice
 
Wordpress Settings API
Wordpress Settings APIWordpress Settings API
Wordpress Settings APIVishal Kothari
 
An Introduction To Automated API Testing
An Introduction To Automated API TestingAn Introduction To Automated API Testing
An Introduction To Automated API TestingSauce Labs
 
Why vREST?
Why vREST?Why vREST?
Why vREST?vrest_io
 
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 IntelligenceTodd Jordan
 
WordPress Plugins to add style to your website
WordPress Plugins to add style to your websiteWordPress Plugins to add style to your website
WordPress Plugins to add style to your websiteBelinda Johnstone
 
Facebook app development
Facebook app developmentFacebook app development
Facebook app developmentJohn Boudreaux
 
Automated Acceptance Testing Example
Automated Acceptance Testing ExampleAutomated Acceptance Testing Example
Automated Acceptance Testing ExampleHani Massoud
 
What's New on the Facebook Platform, April 2011
What's New on the Facebook Platform, April 2011What's New on the Facebook Platform, April 2011
What's New on the Facebook Platform, April 2011Iskandar Najmuddin
 
Building with linked_in_api
Building with linked_in_apiBuilding with linked_in_api
Building with linked_in_apiMatchFWD
 
Getting coding in under a hour with Imagine Microsoft
Getting coding in under a hour with Imagine MicrosoftGetting coding in under a hour with Imagine Microsoft
Getting coding in under a hour with Imagine MicrosoftLee Stott
 
How to use Salesforce Workbench like a Pro
How to use Salesforce Workbench like a ProHow to use Salesforce Workbench like a Pro
How to use Salesforce Workbench like a ProAtul Gupta(8X)
 
Extending Your Reach with Career Portal and Search Engine Optimization
Extending Your Reach with Career Portal and Search Engine OptimizationExtending Your Reach with Career Portal and Search Engine Optimization
Extending Your Reach with Career Portal and Search Engine OptimizationJeremyOtt5
 
Anypoint access management
Anypoint access management Anypoint access management
Anypoint access management Shanky Gupta
 
Server-provided animations in iOS apps
Server-provided animations in iOS appsServer-provided animations in iOS apps
Server-provided animations in iOS appsValerii Chevtaev
 
Bulk Update Operations in Salesforce using BOFC App
Bulk Update Operations in Salesforce using BOFC AppBulk Update Operations in Salesforce using BOFC App
Bulk Update Operations in Salesforce using BOFC AppAtocloud
 
API Test Automation Tips and Tricks
API Test Automation Tips and TricksAPI Test Automation Tips and Tricks
API Test Automation Tips and Trickstesthive
 

What's hot (20)

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)
 
Pepperoni 2.0 - How to spice up your mobile apps
Pepperoni 2.0 - How to spice up your mobile apps Pepperoni 2.0 - How to spice up your mobile apps
Pepperoni 2.0 - How to spice up your mobile apps
 
Wordpress Settings API
Wordpress Settings APIWordpress Settings API
Wordpress Settings API
 
An Introduction To Automated API Testing
An Introduction To Automated API TestingAn Introduction To Automated API Testing
An Introduction To Automated API Testing
 
Why vREST?
Why vREST?Why vREST?
Why vREST?
 
digiQC new features Update
digiQC new features UpdatedigiQC new features Update
digiQC new features Update
 
Introduction to APIs
Introduction to APIsIntroduction to APIs
Introduction to APIs
 
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
 
WordPress Plugins to add style to your website
WordPress Plugins to add style to your websiteWordPress Plugins to add style to your website
WordPress Plugins to add style to your website
 
Facebook app development
Facebook app developmentFacebook app development
Facebook app development
 
Automated Acceptance Testing Example
Automated Acceptance Testing ExampleAutomated Acceptance Testing Example
Automated Acceptance Testing Example
 
What's New on the Facebook Platform, April 2011
What's New on the Facebook Platform, April 2011What's New on the Facebook Platform, April 2011
What's New on the Facebook Platform, April 2011
 
Building with linked_in_api
Building with linked_in_apiBuilding with linked_in_api
Building with linked_in_api
 
Getting coding in under a hour with Imagine Microsoft
Getting coding in under a hour with Imagine MicrosoftGetting coding in under a hour with Imagine Microsoft
Getting coding in under a hour with Imagine Microsoft
 
How to use Salesforce Workbench like a Pro
How to use Salesforce Workbench like a ProHow to use Salesforce Workbench like a Pro
How to use Salesforce Workbench like a Pro
 
Extending Your Reach with Career Portal and Search Engine Optimization
Extending Your Reach with Career Portal and Search Engine OptimizationExtending Your Reach with Career Portal and Search Engine Optimization
Extending Your Reach with Career Portal and Search Engine Optimization
 
Anypoint access management
Anypoint access management Anypoint access management
Anypoint access management
 
Server-provided animations in iOS apps
Server-provided animations in iOS appsServer-provided animations in iOS apps
Server-provided animations in iOS apps
 
Bulk Update Operations in Salesforce using BOFC App
Bulk Update Operations in Salesforce using BOFC AppBulk Update Operations in Salesforce using BOFC App
Bulk Update Operations in Salesforce using BOFC App
 
API Test Automation Tips and Tricks
API Test Automation Tips and TricksAPI Test Automation Tips and Tricks
API Test Automation Tips and Tricks
 

Similar to 4 basic api design guidelines

Building a REST API for Longevity
Building a REST API for LongevityBuilding a REST API for Longevity
Building a REST API for LongevityMuleSoft
 
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 IDELearnNowOnline
 
Approaching APIs
Approaching APIsApproaching APIs
Approaching APIsRoss Singer
 
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 MitraCA API Management
 
Web REST APIs Design Principles
Web REST APIs Design PrinciplesWeb REST APIs Design Principles
Web REST APIs Design PrinciplesAnji Beeravalli
 
Set up an SharePoint On-Premises environment for developing provider-hosted a...
Set up an SharePoint On-Premises environment for developing provider-hosted a...Set up an SharePoint On-Premises environment for developing provider-hosted a...
Set up an SharePoint On-Premises environment for developing provider-hosted a...SPC Adriatics
 
Restful api design
Restful api designRestful api design
Restful api designMizan Riqzia
 
DataHero / Eventbrite - API Best Practices
DataHero / Eventbrite - API Best PracticesDataHero / Eventbrite - API Best Practices
DataHero / Eventbrite - API Best PracticesJeff Zabel
 
Tutorial, Part 1: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
Tutorial, Part 1: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...Tutorial, Part 1: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
Tutorial, Part 1: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...SPTechCon
 
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 2010Twilio Inc
 
Recipes for API Ninjas
Recipes for API NinjasRecipes for API Ninjas
Recipes for API NinjasNordic APIs
 
Building the Eventbrite API Ecosystem
Building the Eventbrite API EcosystemBuilding the Eventbrite API Ecosystem
Building the Eventbrite API EcosystemMitch Colleran
 
WordPress Rest API
WordPress Rest APIWordPress Rest API
WordPress Rest APIBrian Layman
 
Essential Knowledge for SharePoint Add-Ins
Essential Knowledge for SharePoint Add-InsEssential Knowledge for SharePoint Add-Ins
Essential Knowledge for SharePoint Add-InsInnoTech
 
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.pptxapidays
 
Building Creative Product Extensions with Experience Manager
Building Creative Product Extensions with Experience ManagerBuilding Creative Product Extensions with Experience Manager
Building Creative Product Extensions with Experience Managerconnectwebex
 
Scaling API Design - Nordic APIs 2014
Scaling API Design - Nordic APIs 2014Scaling API Design - Nordic APIs 2014
Scaling API Design - Nordic APIs 2014Jason Harmon
 
Scaling API Design
Scaling API DesignScaling API Design
Scaling API DesignJason Harmon
 

Similar to 4 basic api design guidelines (20)

Building a REST API for Longevity
Building a REST API for LongevityBuilding a REST API for Longevity
Building a REST API for Longevity
 
How to design effective APIs
How to design effective APIsHow to design effective APIs
How to design effective APIs
 
Web API Basics
Web API BasicsWeb API Basics
Web API Basics
 
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
 
Approaching APIs
Approaching APIsApproaching APIs
Approaching APIs
 
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
 
Set up an SharePoint On-Premises environment for developing provider-hosted a...
Set up an SharePoint On-Premises environment for developing provider-hosted a...Set up an SharePoint On-Premises environment for developing provider-hosted a...
Set up an SharePoint On-Premises environment for developing provider-hosted a...
 
Restful api design
Restful api designRestful api design
Restful api design
 
DataHero / Eventbrite - API Best Practices
DataHero / Eventbrite - API Best PracticesDataHero / Eventbrite - API Best Practices
DataHero / Eventbrite - API Best Practices
 
Tutorial, Part 1: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
Tutorial, Part 1: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...Tutorial, Part 1: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
Tutorial, Part 1: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
 
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
 
Recipes for API Ninjas
Recipes for API NinjasRecipes for API Ninjas
Recipes for API Ninjas
 
Building the Eventbrite API Ecosystem
Building the Eventbrite API EcosystemBuilding the Eventbrite API Ecosystem
Building the Eventbrite API Ecosystem
 
WordPress Rest API
WordPress Rest APIWordPress Rest API
WordPress Rest API
 
Essential Knowledge for SharePoint Add-Ins
Essential Knowledge for SharePoint Add-InsEssential Knowledge for SharePoint Add-Ins
Essential Knowledge for SharePoint Add-Ins
 
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
 
Building Creative Product Extensions with Experience Manager
Building Creative Product Extensions with Experience ManagerBuilding Creative Product Extensions with Experience Manager
Building Creative Product Extensions with Experience Manager
 
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
 

Recently uploaded

AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfngoud9212
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 

Recently uploaded (20)

AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdf
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 

4 basic api design guidelines

  • 1. HABILELABS PVT. LTD. YOUR INTEREST OUR INTELLIGENCE
  • 2. 4 BASIC API DESIGN GUIDELINES
  • 3. 4 BASIC API DESIGN GUIDELINES 1. Naming convention 2. Error Handling and status codes 3. Versioning 4. Pagination and Partial request
  • 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
  • 8. SIMPLIFY ASSOCIATIONS • 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
  • 9. 2. ERROR HANDLING & STATUS CODE
  • 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
  • 12. 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)
  • 14. 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
  • 15. RECOMMENDED FOR YOU • We will use version number programmatically. • Use /version/resource • Examples /v1/projects /v1/projects/:id /v2/user/:id/projects
  • 16. 4. PAGINATION AND PARTIAL REQUEST
  • 17. PAGINATION AND PARTIAL REQUEST • What others do ? Read Complete Post Here:
  • 18. WHAT YOU SHOULD 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
  • 19. 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
  • 20. CONTACT US Visit Habilelabs: http://www.habilelabs.io/ Contact us: http://www.habilelabs.io/contact-us/ Like us at facebook: https://www.facebook.com/habilelabs/