SlideShare une entreprise Scribd logo
1  sur  29
Télécharger pour lire hors ligne
by Mizan Rizqia
Designing a RESTful Web API
OUTLINE
●
Introduction
●
Quick Tips
●
Error Handling
●
Versioning
●
Paginate & Partial Respone
●
Timestamps
●
Authentication
Introduction
REST
Representational State Transfer
Software architecture style consisting of guidelines and best
practice for creating scalable web service
REST Architectural Constrains
● Client Server
● Stateless
● Cacheable
● Layered System
● Code on Demand
(optional)
● Uniform Interface
RESTful
6 Quick Tips
1.Use HTTP Verbs to Mean Something
● GET
● POST
● PUT
● DELETE
6 Quick Tips
2.Provide Sensible Resource Name
● Use identifier (clean URL)
● Good : /user/12345
● Poor : /api?type=user&id=23
● Design for your client, not for your data
● Resource name = NOUNS (avoid verb)
● Use PLURAL
● Use lower-case
● Keep URLs as SHORT as possible
Recommended :
/customers/33245/orders/8769/lineitems/1
6 Quick Tips
6 Quick Tips
3.Use HTTP Response Codes to Indicate
Status
Top 10 HTTP Status Code
● 403 FORBIDDEN
● 404 NOT FOUND
● 405 METHOD NOT ALLOW
● 409 CONFLICT
● 500 INTERNAL SERVER ERROR
● 200 OK
● 201 CREATED
● 204 NO CONTENT
● 400 BAD REQUEST
● 401 UNAUTORIZED
6 Quick Tips
4.Offer Both JSON and XML
● Make the XML that is returned more JSON-like
● JSON-Schema (schema-style validation
capabilities)
6 Quick Tips
5.Create Fine-Gained Resources
● Small resources
● Easy defined resources
● Provide CRUD functionality
● Use-case-oriented
6.Consider Connectedness
● RFC5988 : The HTTP Web Linking Spesification
● RFC3987 : International Resource Identifiers (IRIs)
● RFC4287 : Atom-Style links
Handling Errors
Why is good error design especially important
for API designer?
1. Developer learn to write code through error
2. Developer depend on well-designed error when they are
throubleshooting and resolving issues
Handling Errors Example
● Facebook
HTTP Status Code: 200
{"type" : "OauthException", "message":"(#803) 
Some of the aliases you requested do not exist: 
foo.bar"}
Handling Errors Example
● Twillio
HTTP Status Code: 401
{"status" : "401", 
"message":"Authenticate","code": 20003, 
"moreinfo": 
"http://www.twilio.com/docs/errors/20003"}
Handling Errors Example
● SimpleGeo
HTTP Status Code: 401
{"code" : 401, "message": "Authentication 
Required"}
Handling Errors
Use HTTP Status Code
Google
200 201 304 400 401 403 404 409 410 500
Netflix
200 201 304 400 401 403 404 412 500
Digg
200 400 401 403 404 410 500 503
Handling Errors
How many status codes should you use for your
API? (minimum)
1.Success      – Everything worked
2.Client error – The application did something wrong
3.Server error – The API did something wrong
● 200 ­ OK
● 400 ­ Bad Request
● 500 ­ Internal Server Error
More info: HTTP Status Codes
Versioning
“Never Release an API without a version and
make the version mandatory”
Versioning Example
● Twilio
/2014­04­01/Accounts/
● Salesforce
/services/data/v20.0/sobjects/Accounts
● Facebook
?v=1.0
Versioning Recommendation
● Specify the version with a 'v' prefix, don't use the dot notation.
– /v1/dogs
– /v2/customers
● How many version should you maintain?
– At least one version back
● Should version and format be in URL or headers?
– If it logic, put in URL
– If it doesn't change logic (like Oauth), put it in the header
Pagination & Partial Respone
“Just give the information they need”
Pagination & Partial Respone
● LinkedIn
/people:(id,first­name,last­name,industry)
● Facebook
/joe.smith/friends?fields=id,name,picture
● Google
?fields=title,media:group(media:thumbnail)
Pagination & Partial Respone
● Recommendation
– Add optional fields in comma-delimited list
/dogs?field=name,color,location
/tickets?sort=­updated_at
/tickets?sort=­priority,created_at
– Use limit & offset to paginate object
/dogs?limit=25&offset=50
Search
● Global Search
/search?q=mizan+keren
● Scoped Search
/orders/1001?q=tlab+amazing
● Formatted Search
/search.xml?q=mizan+keren
Timestamp
● Don't use Unix Timestamps
– 1427736345 (ISO 8601:2015-03-30T17:25:45Z)
● Use standard Timestamps
– ISO-8601
– 2015-03-30T16:31:53+00:00
– 2015-03-30T16:31:53Z
Authentication
Three common ways to go with authentication
1. If your API has user-based authentication
Oauth2 - demo
2. If you just need to password protect
HTTP Basic Authentication (not secure)
3. if you want to provide an API key or other sorts of single-string
authentication
Oauth + HTTP Basic Authentication
Authentication – OAuth2 Flow
Complement with an SDK
● Speed adoption on a specific platform
● Simplify integration effort required to work with your
API
● An SDK can help reduce bad or inefficient code
● As a developer resource
– Yahoo
– Paypal
● To market your API specific community
Reference
● https://pages.apigee.com/web-api-design-ebook.html
● http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm
● http://www.restapitutorial.com/
● http://bshaffer.github.io/oauth2-server-php-docs/
● http://code.tutsplus.com/tutorials/laravel-4-a-start-at-a-restful-api-updated--net-29785
● http://www.sitepoint.com/build-rest-resources-laravel/
Matur Sembah Nuwun
Thank you
Mizan Rizqia
baobaz@tlab.co.id
+62-81806406692
@mizanrizqia
/mizanr

Contenu connexe

Tendances

HTTP2 and gRPC
HTTP2 and gRPCHTTP2 and gRPC
HTTP2 and gRPCGuo Jing
 
WebServices SOAP WSDL and UDDI
WebServices SOAP WSDL and UDDIWebServices SOAP WSDL and UDDI
WebServices SOAP WSDL and UDDIRajkattamuri
 
Understanding REST
Understanding RESTUnderstanding REST
Understanding RESTNitin Pande
 
REST-API introduction for developers
REST-API introduction for developersREST-API introduction for developers
REST-API introduction for developersPatrick Savalle
 
OpenID Connect: An Overview
OpenID Connect: An OverviewOpenID Connect: An Overview
OpenID Connect: An OverviewPat Patterson
 
OpenAPI and gRPC Side by-Side
OpenAPI and gRPC Side by-SideOpenAPI and gRPC Side by-Side
OpenAPI and gRPC Side by-SideTim Burks
 
How to write a Neutron Plugin - if you really need to
How to write a Neutron Plugin - if you really need toHow to write a Neutron Plugin - if you really need to
How to write a Neutron Plugin - if you really need tosalv_orlando
 
REST API and CRUD
REST API and CRUDREST API and CRUD
REST API and CRUDPrem Sanil
 
Introduction to the Web API
Introduction to the Web APIIntroduction to the Web API
Introduction to the Web APIBrad Genereaux
 

Tendances (20)

HTTP2 and gRPC
HTTP2 and gRPCHTTP2 and gRPC
HTTP2 and gRPC
 
WebServices SOAP WSDL and UDDI
WebServices SOAP WSDL and UDDIWebServices SOAP WSDL and UDDI
WebServices SOAP WSDL and UDDI
 
An Introduction To REST API
An Introduction To REST APIAn Introduction To REST API
An Introduction To REST API
 
Understanding REST
Understanding RESTUnderstanding REST
Understanding REST
 
REST & RESTful Web Services
REST & RESTful Web ServicesREST & RESTful Web Services
REST & RESTful Web Services
 
REST-API introduction for developers
REST-API introduction for developersREST-API introduction for developers
REST-API introduction for developers
 
Rest API
Rest APIRest API
Rest API
 
OpenID Connect: An Overview
OpenID Connect: An OverviewOpenID Connect: An Overview
OpenID Connect: An Overview
 
Api security
Api security Api security
Api security
 
REST API Authentication Methods.pdf
REST API Authentication Methods.pdfREST API Authentication Methods.pdf
REST API Authentication Methods.pdf
 
Web-Socket
Web-SocketWeb-Socket
Web-Socket
 
Rest api with Python
Rest api with PythonRest api with Python
Rest api with Python
 
Git & GitHub for Beginners
Git & GitHub for BeginnersGit & GitHub for Beginners
Git & GitHub for Beginners
 
Http Protocol
Http ProtocolHttp Protocol
Http Protocol
 
REST API
REST APIREST API
REST API
 
OpenAPI and gRPC Side by-Side
OpenAPI and gRPC Side by-SideOpenAPI and gRPC Side by-Side
OpenAPI and gRPC Side by-Side
 
How to write a Neutron Plugin - if you really need to
How to write a Neutron Plugin - if you really need toHow to write a Neutron Plugin - if you really need to
How to write a Neutron Plugin - if you really need to
 
REST API and CRUD
REST API and CRUDREST API and CRUD
REST API and CRUD
 
gRPC Overview
gRPC OverviewgRPC Overview
gRPC Overview
 
Introduction to the Web API
Introduction to the Web APIIntroduction to the Web API
Introduction to the Web API
 

En vedette

Mari Memahami PSR (PHP Standards Recommendation)
Mari Memahami PSR (PHP Standards Recommendation)Mari Memahami PSR (PHP Standards Recommendation)
Mari Memahami PSR (PHP Standards Recommendation)Mizan Riqzia
 
Nge-GIT (Belajar Git Bareng)
Nge-GIT (Belajar Git Bareng)Nge-GIT (Belajar Git Bareng)
Nge-GIT (Belajar Git Bareng)Mizan Riqzia
 
PHP Server side restful API - linkedin
PHP Server side restful API - linkedinPHP Server side restful API - linkedin
PHP Server side restful API - linkedinVũ Quang Sơn
 
Introduction angular js
Introduction angular jsIntroduction angular js
Introduction angular jsMizan Riqzia
 
RESTful APIs with Herman Radtke
RESTful APIs with Herman RadtkeRESTful APIs with Herman Radtke
RESTful APIs with Herman Radtkeventuraphp
 
Releasing the dopamine
Releasing the dopamineReleasing the dopamine
Releasing the dopaminePaul Boocock
 
Introduction to OOP with PHP
Introduction to OOP with PHPIntroduction to OOP with PHP
Introduction to OOP with PHPMichael Peacock
 
Laravel 5 Tutorial : Membuat Blog Sederhana dengan Laravel 5.3
Laravel 5 Tutorial : Membuat Blog Sederhana dengan Laravel 5.3Laravel 5 Tutorial : Membuat Blog Sederhana dengan Laravel 5.3
Laravel 5 Tutorial : Membuat Blog Sederhana dengan Laravel 5.3harisonmtd
 
OOP Basic - PHP
OOP Basic - PHPOOP Basic - PHP
OOP Basic - PHPSulaeman .
 
RESTful API Design Best Practices Using ASP.NET Web API
RESTful API Design Best Practices Using ASP.NET Web APIRESTful API Design Best Practices Using ASP.NET Web API
RESTful API Design Best Practices Using ASP.NET Web API💻 Spencer Schneidenbach
 
Creating a World-Class RESTful Web Services API
Creating a World-Class RESTful Web Services APICreating a World-Class RESTful Web Services API
Creating a World-Class RESTful Web Services APIDavid Keener
 
Ejercicios resueltos de conjuntos
Ejercicios resueltos de conjuntosEjercicios resueltos de conjuntos
Ejercicios resueltos de conjuntoshernancarrilloa
 
LinkedIn SlideShare: Knowledge, Well-Presented
LinkedIn SlideShare: Knowledge, Well-PresentedLinkedIn SlideShare: Knowledge, Well-Presented
LinkedIn SlideShare: Knowledge, Well-PresentedSlideShare
 
What Makes Great Infographics
What Makes Great InfographicsWhat Makes Great Infographics
What Makes Great InfographicsSlideShare
 
Masters of SlideShare
Masters of SlideShareMasters of SlideShare
Masters of SlideShareKapost
 
STOP! VIEW THIS! 10-Step Checklist When Uploading to Slideshare
STOP! VIEW THIS! 10-Step Checklist When Uploading to SlideshareSTOP! VIEW THIS! 10-Step Checklist When Uploading to Slideshare
STOP! VIEW THIS! 10-Step Checklist When Uploading to SlideshareEmpowered Presentations
 

En vedette (20)

Mari Memahami PSR (PHP Standards Recommendation)
Mari Memahami PSR (PHP Standards Recommendation)Mari Memahami PSR (PHP Standards Recommendation)
Mari Memahami PSR (PHP Standards Recommendation)
 
Nge-GIT (Belajar Git Bareng)
Nge-GIT (Belajar Git Bareng)Nge-GIT (Belajar Git Bareng)
Nge-GIT (Belajar Git Bareng)
 
PHP Server side restful API - linkedin
PHP Server side restful API - linkedinPHP Server side restful API - linkedin
PHP Server side restful API - linkedin
 
Introduction angular js
Introduction angular jsIntroduction angular js
Introduction angular js
 
RESTful APIs with Herman Radtke
RESTful APIs with Herman RadtkeRESTful APIs with Herman Radtke
RESTful APIs with Herman Radtke
 
Releasing the dopamine
Releasing the dopamineReleasing the dopamine
Releasing the dopamine
 
Inheritance and polymorphism
Inheritance and polymorphism   Inheritance and polymorphism
Inheritance and polymorphism
 
Introduction to OOP with PHP
Introduction to OOP with PHPIntroduction to OOP with PHP
Introduction to OOP with PHP
 
Laravel 5 Tutorial : Membuat Blog Sederhana dengan Laravel 5.3
Laravel 5 Tutorial : Membuat Blog Sederhana dengan Laravel 5.3Laravel 5 Tutorial : Membuat Blog Sederhana dengan Laravel 5.3
Laravel 5 Tutorial : Membuat Blog Sederhana dengan Laravel 5.3
 
Tutorial dasar laravel
Tutorial dasar laravelTutorial dasar laravel
Tutorial dasar laravel
 
OOP Basic - PHP
OOP Basic - PHPOOP Basic - PHP
OOP Basic - PHP
 
Fungsi-Fungsi PHP
Fungsi-Fungsi PHPFungsi-Fungsi PHP
Fungsi-Fungsi PHP
 
RESTful API Design Best Practices Using ASP.NET Web API
RESTful API Design Best Practices Using ASP.NET Web APIRESTful API Design Best Practices Using ASP.NET Web API
RESTful API Design Best Practices Using ASP.NET Web API
 
RESTful API Design, Second Edition
RESTful API Design, Second EditionRESTful API Design, Second Edition
RESTful API Design, Second Edition
 
Creating a World-Class RESTful Web Services API
Creating a World-Class RESTful Web Services APICreating a World-Class RESTful Web Services API
Creating a World-Class RESTful Web Services API
 
Ejercicios resueltos de conjuntos
Ejercicios resueltos de conjuntosEjercicios resueltos de conjuntos
Ejercicios resueltos de conjuntos
 
LinkedIn SlideShare: Knowledge, Well-Presented
LinkedIn SlideShare: Knowledge, Well-PresentedLinkedIn SlideShare: Knowledge, Well-Presented
LinkedIn SlideShare: Knowledge, Well-Presented
 
What Makes Great Infographics
What Makes Great InfographicsWhat Makes Great Infographics
What Makes Great Infographics
 
Masters of SlideShare
Masters of SlideShareMasters of SlideShare
Masters of SlideShare
 
STOP! VIEW THIS! 10-Step Checklist When Uploading to Slideshare
STOP! VIEW THIS! 10-Step Checklist When Uploading to SlideshareSTOP! VIEW THIS! 10-Step Checklist When Uploading to Slideshare
STOP! VIEW THIS! 10-Step Checklist When Uploading to Slideshare
 

Similaire à Restful api design

How to build Simple yet powerful API.pptx
How to build Simple yet powerful API.pptxHow to build Simple yet powerful API.pptx
How to build Simple yet powerful API.pptxChanna Ly
 
Web REST APIs Design Principles
Web REST APIs Design PrinciplesWeb REST APIs Design Principles
Web REST APIs Design PrinciplesAnji Beeravalli
 
INTERFACE by apidays 2023 - API Design Governance, Nauman Ali, Stoplight
INTERFACE by apidays 2023 - API Design Governance, Nauman Ali, StoplightINTERFACE by apidays 2023 - API Design Governance, Nauman Ali, Stoplight
INTERFACE by apidays 2023 - API Design Governance, Nauman Ali, Stoplightapidays
 
Apigility introduction v2 (glasgow php)
Apigility introduction v2 (glasgow php)Apigility introduction v2 (glasgow php)
Apigility introduction v2 (glasgow php)Engineor
 
A RESTful introduction
A RESTful introductionA RESTful introduction
A RESTful introductionDaniel Toader
 
API Security - OWASP top 10 for APIs + tips for pentesters
API Security - OWASP top 10 for APIs + tips for pentestersAPI Security - OWASP top 10 for APIs + tips for pentesters
API Security - OWASP top 10 for APIs + tips for pentestersInon Shkedy
 
MuleSoft Surat Virtual Meetup#21 - MuleSoft API and RAML Design Best Practice...
MuleSoft Surat Virtual Meetup#21 - MuleSoft API and RAML Design Best Practice...MuleSoft Surat Virtual Meetup#21 - MuleSoft API and RAML Design Best Practice...
MuleSoft Surat Virtual Meetup#21 - MuleSoft API and RAML Design Best Practice...Jitendra Bafna
 
Deccan ruby-conf-talk
Deccan ruby-conf-talkDeccan ruby-conf-talk
Deccan ruby-conf-talkprchaudhari
 
Создание API, которое полюбят разработчики. Глубокое погружение
Создание API, которое полюбят разработчики. Глубокое погружениеСоздание API, которое полюбят разработчики. Глубокое погружение
Создание API, которое полюбят разработчики. Глубокое погружениеSQALab
 
How to Connect to Any REST API (Without Writing Any Code)
How to Connect to Any REST API (Without Writing Any Code)How to Connect to Any REST API (Without Writing Any Code)
How to Connect to Any REST API (Without Writing Any Code)Safe Software
 
Api best practices
Api best practicesApi best practices
Api best practicesChet Nut
 
Introduction to Apigility
Introduction to ApigilityIntroduction to Apigility
Introduction to ApigilityEngineor
 
Anypoint DataGraph - Consume & Re-use your APIs faster | MuleSoft Mysore Meet...
Anypoint DataGraph - Consume & Re-use your APIs faster | MuleSoft Mysore Meet...Anypoint DataGraph - Consume & Re-use your APIs faster | MuleSoft Mysore Meet...
Anypoint DataGraph - Consume & Re-use your APIs faster | MuleSoft Mysore Meet...MysoreMuleSoftMeetup
 
API (Application program interface)
API (Application program interface)API (Application program interface)
API (Application program interface)Muhammad Jahanzaib
 
APIdays Paris 2014 - Workshop - Craft and Deploy Your API in a Few Clicks Wit...
APIdays Paris 2014 - Workshop - Craft and Deploy Your API in a Few Clicks Wit...APIdays Paris 2014 - Workshop - Craft and Deploy Your API in a Few Clicks Wit...
APIdays Paris 2014 - Workshop - Craft and Deploy Your API in a Few Clicks Wit...Restlet
 
apidays LIVE Paris 2021 - Lessons from the API Stewardship Journey in Azure b...
apidays LIVE Paris 2021 - Lessons from the API Stewardship Journey in Azure b...apidays LIVE Paris 2021 - Lessons from the API Stewardship Journey in Azure b...
apidays LIVE Paris 2021 - Lessons from the API Stewardship Journey in Azure b...apidays
 
A Starters Guide to Building APIs with Javascript
A Starters Guide to Building APIs with JavascriptA Starters Guide to Building APIs with Javascript
A Starters Guide to Building APIs with JavascriptAll Things Open
 

Similaire à Restful api design (20)

How to build Simple yet powerful API.pptx
How to build Simple yet powerful API.pptxHow to build Simple yet powerful API.pptx
How to build Simple yet powerful API.pptx
 
Cqrs api
Cqrs apiCqrs api
Cqrs api
 
Crafting APIs
Crafting APIsCrafting APIs
Crafting APIs
 
Rest api-basic
Rest api-basicRest api-basic
Rest api-basic
 
Web REST APIs Design Principles
Web REST APIs Design PrinciplesWeb REST APIs Design Principles
Web REST APIs Design Principles
 
INTERFACE by apidays 2023 - API Design Governance, Nauman Ali, Stoplight
INTERFACE by apidays 2023 - API Design Governance, Nauman Ali, StoplightINTERFACE by apidays 2023 - API Design Governance, Nauman Ali, Stoplight
INTERFACE by apidays 2023 - API Design Governance, Nauman Ali, Stoplight
 
Apigility introduction v2 (glasgow php)
Apigility introduction v2 (glasgow php)Apigility introduction v2 (glasgow php)
Apigility introduction v2 (glasgow php)
 
A RESTful introduction
A RESTful introductionA RESTful introduction
A RESTful introduction
 
API Security - OWASP top 10 for APIs + tips for pentesters
API Security - OWASP top 10 for APIs + tips for pentestersAPI Security - OWASP top 10 for APIs + tips for pentesters
API Security - OWASP top 10 for APIs + tips for pentesters
 
MuleSoft Surat Virtual Meetup#21 - MuleSoft API and RAML Design Best Practice...
MuleSoft Surat Virtual Meetup#21 - MuleSoft API and RAML Design Best Practice...MuleSoft Surat Virtual Meetup#21 - MuleSoft API and RAML Design Best Practice...
MuleSoft Surat Virtual Meetup#21 - MuleSoft API and RAML Design Best Practice...
 
Deccan ruby-conf-talk
Deccan ruby-conf-talkDeccan ruby-conf-talk
Deccan ruby-conf-talk
 
Создание API, которое полюбят разработчики. Глубокое погружение
Создание API, которое полюбят разработчики. Глубокое погружениеСоздание API, которое полюбят разработчики. Глубокое погружение
Создание API, которое полюбят разработчики. Глубокое погружение
 
How to Connect to Any REST API (Without Writing Any Code)
How to Connect to Any REST API (Without Writing Any Code)How to Connect to Any REST API (Without Writing Any Code)
How to Connect to Any REST API (Without Writing Any Code)
 
Api best practices
Api best practicesApi best practices
Api best practices
 
Introduction to Apigility
Introduction to ApigilityIntroduction to Apigility
Introduction to Apigility
 
Anypoint DataGraph - Consume & Re-use your APIs faster | MuleSoft Mysore Meet...
Anypoint DataGraph - Consume & Re-use your APIs faster | MuleSoft Mysore Meet...Anypoint DataGraph - Consume & Re-use your APIs faster | MuleSoft Mysore Meet...
Anypoint DataGraph - Consume & Re-use your APIs faster | MuleSoft Mysore Meet...
 
API (Application program interface)
API (Application program interface)API (Application program interface)
API (Application program interface)
 
APIdays Paris 2014 - Workshop - Craft and Deploy Your API in a Few Clicks Wit...
APIdays Paris 2014 - Workshop - Craft and Deploy Your API in a Few Clicks Wit...APIdays Paris 2014 - Workshop - Craft and Deploy Your API in a Few Clicks Wit...
APIdays Paris 2014 - Workshop - Craft and Deploy Your API in a Few Clicks Wit...
 
apidays LIVE Paris 2021 - Lessons from the API Stewardship Journey in Azure b...
apidays LIVE Paris 2021 - Lessons from the API Stewardship Journey in Azure b...apidays LIVE Paris 2021 - Lessons from the API Stewardship Journey in Azure b...
apidays LIVE Paris 2021 - Lessons from the API Stewardship Journey in Azure b...
 
A Starters Guide to Building APIs with Javascript
A Starters Guide to Building APIs with JavascriptA Starters Guide to Building APIs with Javascript
A Starters Guide to Building APIs with Javascript
 

Dernier

Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...software pro Development
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024Mind IT Systems
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfryanfarris8
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfVishalKumarJha10
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 

Dernier (20)

Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 

Restful api design

  • 1. by Mizan Rizqia Designing a RESTful Web API
  • 3. Introduction REST Representational State Transfer Software architecture style consisting of guidelines and best practice for creating scalable web service
  • 4. REST Architectural Constrains ● Client Server ● Stateless ● Cacheable ● Layered System ● Code on Demand (optional) ● Uniform Interface RESTful
  • 5. 6 Quick Tips 1.Use HTTP Verbs to Mean Something ● GET ● POST ● PUT ● DELETE
  • 6. 6 Quick Tips 2.Provide Sensible Resource Name ● Use identifier (clean URL) ● Good : /user/12345 ● Poor : /api?type=user&id=23 ● Design for your client, not for your data ● Resource name = NOUNS (avoid verb) ● Use PLURAL ● Use lower-case ● Keep URLs as SHORT as possible Recommended : /customers/33245/orders/8769/lineitems/1
  • 8. 6 Quick Tips 3.Use HTTP Response Codes to Indicate Status Top 10 HTTP Status Code ● 403 FORBIDDEN ● 404 NOT FOUND ● 405 METHOD NOT ALLOW ● 409 CONFLICT ● 500 INTERNAL SERVER ERROR ● 200 OK ● 201 CREATED ● 204 NO CONTENT ● 400 BAD REQUEST ● 401 UNAUTORIZED
  • 9. 6 Quick Tips 4.Offer Both JSON and XML ● Make the XML that is returned more JSON-like ● JSON-Schema (schema-style validation capabilities)
  • 10. 6 Quick Tips 5.Create Fine-Gained Resources ● Small resources ● Easy defined resources ● Provide CRUD functionality ● Use-case-oriented 6.Consider Connectedness ● RFC5988 : The HTTP Web Linking Spesification ● RFC3987 : International Resource Identifiers (IRIs) ● RFC4287 : Atom-Style links
  • 11. Handling Errors Why is good error design especially important for API designer? 1. Developer learn to write code through error 2. Developer depend on well-designed error when they are throubleshooting and resolving issues
  • 12. Handling Errors Example ● Facebook HTTP Status Code: 200 {"type" : "OauthException", "message":"(#803)  Some of the aliases you requested do not exist:  foo.bar"}
  • 13. Handling Errors Example ● Twillio HTTP Status Code: 401 {"status" : "401",  "message":"Authenticate","code": 20003,  "moreinfo":  "http://www.twilio.com/docs/errors/20003"}
  • 14. Handling Errors Example ● SimpleGeo HTTP Status Code: 401 {"code" : 401, "message": "Authentication  Required"}
  • 15. Handling Errors Use HTTP Status Code Google 200 201 304 400 401 403 404 409 410 500 Netflix 200 201 304 400 401 403 404 412 500 Digg 200 400 401 403 404 410 500 503
  • 16. Handling Errors How many status codes should you use for your API? (minimum) 1.Success      – Everything worked 2.Client error – The application did something wrong 3.Server error – The API did something wrong ● 200 ­ OK ● 400 ­ Bad Request ● 500 ­ Internal Server Error More info: HTTP Status Codes
  • 17. Versioning “Never Release an API without a version and make the version mandatory”
  • 18. Versioning Example ● Twilio /2014­04­01/Accounts/ ● Salesforce /services/data/v20.0/sobjects/Accounts ● Facebook ?v=1.0
  • 19. Versioning Recommendation ● Specify the version with a 'v' prefix, don't use the dot notation. – /v1/dogs – /v2/customers ● How many version should you maintain? – At least one version back ● Should version and format be in URL or headers? – If it logic, put in URL – If it doesn't change logic (like Oauth), put it in the header
  • 20. Pagination & Partial Respone “Just give the information they need”
  • 21. Pagination & Partial Respone ● LinkedIn /people:(id,first­name,last­name,industry) ● Facebook /joe.smith/friends?fields=id,name,picture ● Google ?fields=title,media:group(media:thumbnail)
  • 22. Pagination & Partial Respone ● Recommendation – Add optional fields in comma-delimited list /dogs?field=name,color,location /tickets?sort=­updated_at /tickets?sort=­priority,created_at – Use limit & offset to paginate object /dogs?limit=25&offset=50
  • 23. Search ● Global Search /search?q=mizan+keren ● Scoped Search /orders/1001?q=tlab+amazing ● Formatted Search /search.xml?q=mizan+keren
  • 24. Timestamp ● Don't use Unix Timestamps – 1427736345 (ISO 8601:2015-03-30T17:25:45Z) ● Use standard Timestamps – ISO-8601 – 2015-03-30T16:31:53+00:00 – 2015-03-30T16:31:53Z
  • 25. Authentication Three common ways to go with authentication 1. If your API has user-based authentication Oauth2 - demo 2. If you just need to password protect HTTP Basic Authentication (not secure) 3. if you want to provide an API key or other sorts of single-string authentication Oauth + HTTP Basic Authentication
  • 27. Complement with an SDK ● Speed adoption on a specific platform ● Simplify integration effort required to work with your API ● An SDK can help reduce bad or inefficient code ● As a developer resource – Yahoo – Paypal ● To market your API specific community
  • 28. Reference ● https://pages.apigee.com/web-api-design-ebook.html ● http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm ● http://www.restapitutorial.com/ ● http://bshaffer.github.io/oauth2-server-php-docs/ ● http://code.tutsplus.com/tutorials/laravel-4-a-start-at-a-restful-api-updated--net-29785 ● http://www.sitepoint.com/build-rest-resources-laravel/
  • 29. Matur Sembah Nuwun Thank you Mizan Rizqia baobaz@tlab.co.id +62-81806406692 @mizanrizqia /mizanr