SlideShare a Scribd company logo
Building APIs that
don’t suck!
(To be taken with a grain of salt)
Why?
Endpoint Theory
Noun vs Verb
POST /users
POST /users/create
Resources are Nouns
Verbs can be made Nouns
POST /users/123/checkin
POST /users/123/checkins
Endpoint Theory contd...
Singular vs Plural
GET /users/1,GET /users
GET /user/1, GET /users
Use HTTP Verbs appropriately
GET Retrieve GET /users/123
POST Create POST /users
PUT Replace PUT /users/123
PATCH Update PATCH /users/123
DELET
E
Delete DELETE /users/123
Resource Relationships - keep it simple
GET /users/1/checkins
GET /users/1/checkins/123
GET /checkins/123
Use HTTP Status Codes appropriately
2xx Success 200(OK), 202(Created)
3xx Redirect 301(Redirect), 303(Moved
Permanently)
4xx Client Error 400(Bad Req), 401(Unauthorized),
404(Not Found),
422(Unprocessable)
5xx Server Error 500(Internal Err)
Payload Design - think of the user
{
"data": {
"type": "entity_type"
"attributes": {
....
}
}
}
{
"errors": {
"status": 422,
"title": "Bad api call",
"detail": "Details...”
}
}
HATEOAS & being RESTful
1. Content Negotiation
Hypermedia As The Engine Of Application State
GET /configs
HTTP Header:
Accept: application/x-yaml
HATEOAS & being RESTful
2. Hypermedia
Controls
"data": {
"type": "users"
"attributes": {
....
},
"links": [ {
"rel": "self",
"uri": "/users/1"
}, {
"rel": "checkins",
"uri": "/users/1/checkins"
}]
}
FAQ
Versioning - Semantic Versioning (http://semver.org)
Documentation - Slate or Swagger
Testing - JSON-Schema validation
Standards - JSON-API, but I can’t recommend it!
UGLY Parts - Filtering, Foreign-Key relations, Sideloading
GraphQL - Not a REST API, Infinite API
Take Away
API
Be thoughtful when designing APIs
Follow good practices
Stay consistent
Try not to break it (Semantic versioning)
TLC
Thank you
“Life is short.. Work somewhere
awesome”
http://www.enova.com

More Related Content

PPT
Did you know about blood??
PDF
bioinfolec_20070706 4th
DOCX
Adding videos
PDF
REST in ( a mobile ) peace @ WHYMCA 05-21-2011
PPT
RESTful SOA - 中科院暑期讲座
PPT
JavaOne 2009 - TS-5276 - RESTful Protocol Buffers
PDF
Indic threads delhi13-rest-anirudh
ODP
Oredev 2009 JAX-RS
Did you know about blood??
bioinfolec_20070706 4th
Adding videos
REST in ( a mobile ) peace @ WHYMCA 05-21-2011
RESTful SOA - 中科院暑期讲座
JavaOne 2009 - TS-5276 - RESTful Protocol Buffers
Indic threads delhi13-rest-anirudh
Oredev 2009 JAX-RS

Similar to Building apis that don’t suck! (20)

PPTX
Day02 a pi.
ODP
Web Scraping with PHP
PDF
Multi Client Development with Spring for SpringOne 2GX 2013 with Roy Clarkson
PDF
Modelling RESTful applications – Why should I not use verbs in REST url
PDF
REST in Peace
PDF
Whatever it takes - Fixing SQLIA and XSS in the process
PDF
An introduction to Struts 2 and RESTful applications
PDF
Cqrs api v2
PPTX
Rest in practice
PPTX
Mtn view sql server nov 2014
PPTX
Spring Boot and REST API
PPTX
PPT
Internet Explorer 8 for Developers by Christian Thilmany
PDF
Data persistence using pouchdb and couchdb
PPTX
Testing ASP.NET - Progressive.NET
PDF
Rest And Rails
PDF
Android App Development 06 : Network & Web Services
PDF
05 status-codes
PPTX
Android and REST
PDF
Python RESTful webservices with Python: Flask and Django solutions
Day02 a pi.
Web Scraping with PHP
Multi Client Development with Spring for SpringOne 2GX 2013 with Roy Clarkson
Modelling RESTful applications – Why should I not use verbs in REST url
REST in Peace
Whatever it takes - Fixing SQLIA and XSS in the process
An introduction to Struts 2 and RESTful applications
Cqrs api v2
Rest in practice
Mtn view sql server nov 2014
Spring Boot and REST API
Internet Explorer 8 for Developers by Christian Thilmany
Data persistence using pouchdb and couchdb
Testing ASP.NET - Progressive.NET
Rest And Rails
Android App Development 06 : Network & Web Services
05 status-codes
Android and REST
Python RESTful webservices with Python: Flask and Django solutions
Ad

More from Bud Siddhisena (20)

PDF
JIT qa-docker
PDF
Why should you android (archived)
PDF
Virtualization, The future of computing (archived)
PDF
Building the Next big thing (archived)
PDF
GNU/Linux for a better home (archived)
PDF
Recipe of a linux Live CD (archived)
PDF
Gaming on linux (archived)
PDF
FOSS in Sri Lanka (archived)
PDF
Contributing to FOSS (archived)
PDF
Choosing your GNU/Linux distribution (archived)
PDF
Beyond desktop/server with GNU/Linux (archived)
PDF
PDF
Opensource opportunity
PDF
Remembering steve
PDF
Scale Apache with Nginx
PDF
Introduction to firewalls through Iptables
PPT
FOSS and Security
PDF
Secure your IT infrastructure with GNU/Linux
PDF
Kernel Configuration and Compilation
PDF
Foss Gadgematics
JIT qa-docker
Why should you android (archived)
Virtualization, The future of computing (archived)
Building the Next big thing (archived)
GNU/Linux for a better home (archived)
Recipe of a linux Live CD (archived)
Gaming on linux (archived)
FOSS in Sri Lanka (archived)
Contributing to FOSS (archived)
Choosing your GNU/Linux distribution (archived)
Beyond desktop/server with GNU/Linux (archived)
Opensource opportunity
Remembering steve
Scale Apache with Nginx
Introduction to firewalls through Iptables
FOSS and Security
Secure your IT infrastructure with GNU/Linux
Kernel Configuration and Compilation
Foss Gadgematics
Ad

Recently uploaded (20)

PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
How Creative Agencies Leverage Project Management Software.pdf
PPTX
Essential Infomation Tech presentation.pptx
PPTX
Odoo POS Development Services by CandidRoot Solutions
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
Understanding Forklifts - TECH EHS Solution
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PPTX
ai tools demonstartion for schools and inter college
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
CHAPTER 2 - PM Management and IT Context
How to Choose the Right IT Partner for Your Business in Malaysia
Odoo Companies in India – Driving Business Transformation.pdf
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Reimagine Home Health with the Power of Agentic AI​
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Design an Analysis of Algorithms II-SECS-1021-03
How Creative Agencies Leverage Project Management Software.pdf
Essential Infomation Tech presentation.pptx
Odoo POS Development Services by CandidRoot Solutions
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Understanding Forklifts - TECH EHS Solution
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
ai tools demonstartion for schools and inter college
Wondershare Filmora 15 Crack With Activation Key [2025
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf

Building apis that don’t suck!

  • 1. Building APIs that don’t suck! (To be taken with a grain of salt)
  • 3. Endpoint Theory Noun vs Verb POST /users POST /users/create
  • 4. Resources are Nouns Verbs can be made Nouns POST /users/123/checkin POST /users/123/checkins
  • 5. Endpoint Theory contd... Singular vs Plural GET /users/1,GET /users GET /user/1, GET /users
  • 6. Use HTTP Verbs appropriately GET Retrieve GET /users/123 POST Create POST /users PUT Replace PUT /users/123 PATCH Update PATCH /users/123 DELET E Delete DELETE /users/123
  • 7. Resource Relationships - keep it simple GET /users/1/checkins GET /users/1/checkins/123 GET /checkins/123
  • 8. Use HTTP Status Codes appropriately 2xx Success 200(OK), 202(Created) 3xx Redirect 301(Redirect), 303(Moved Permanently) 4xx Client Error 400(Bad Req), 401(Unauthorized), 404(Not Found), 422(Unprocessable) 5xx Server Error 500(Internal Err)
  • 9. Payload Design - think of the user { "data": { "type": "entity_type" "attributes": { .... } } } { "errors": { "status": 422, "title": "Bad api call", "detail": "Details...” } }
  • 10. HATEOAS & being RESTful 1. Content Negotiation Hypermedia As The Engine Of Application State GET /configs HTTP Header: Accept: application/x-yaml
  • 11. HATEOAS & being RESTful 2. Hypermedia Controls "data": { "type": "users" "attributes": { .... }, "links": [ { "rel": "self", "uri": "/users/1" }, { "rel": "checkins", "uri": "/users/1/checkins" }] }
  • 12. FAQ Versioning - Semantic Versioning (http://semver.org) Documentation - Slate or Swagger Testing - JSON-Schema validation Standards - JSON-API, but I can’t recommend it! UGLY Parts - Filtering, Foreign-Key relations, Sideloading GraphQL - Not a REST API, Infinite API
  • 13. Take Away API Be thoughtful when designing APIs Follow good practices Stay consistent Try not to break it (Semantic versioning) TLC
  • 14. Thank you “Life is short.. Work somewhere awesome” http://www.enova.com

Editor's Notes

  • #3: I wanted to get myself to read the book. So I signed up for an Enova tech tech talk, where I work.
  • #4: Prefer nouns to verbs to represent endpoints. Why? Because URLs represent a Resource which lives on the Internet. It’s a thing (noun)
  • #5: You can still make a verb into a noun if needed. Eg. checkin is an action but checkins a list of checkins. Like a verb but Likes a noun.
  • #6: Use Plural. Don’t use both. It’s more consistent and less ambiguous
  • #7: Verbs exist in the REST world. But use the HTTP built-ins to achieve it.
  • #8: Best not to go more than 1 level deep. If you need to do the 2nd example, do the last one instead
  • #9: Use HTTP status to convey how things went. Make a best effort to use the correct http status code (even though there are overlapping codes)
  • #10: Highly subjective, but try to come up with a payload design and try to be consistent. This design is inspired by json-api. Why not json-api? It can get too complex and ugly
  • #11: It ain’t RESTful if it doesn’t have HATEOAS. That’s what Roy Fielding, the inventor or REST says. Content negotiation not a big deal these days since it’s pretty much json.
  • #12: However supporting hypermedia links is important. It promotes organic API discoverability.
  • #13: Times almost up. The one I spent some time talking about is API testing via json-schema. I think it can be used to address most of API testing. If you want to be exact then use more exact matching of data against a golden file but IMHO that isn’t really needed here.
  • #14: Good API design is important. It imputes thoughtfulness into a well designed system (even if that is not the case :). Don’t think of APIs as web page replacements. Instead think of them as schemas and data. Thinking of good API designs may invite to re-evaluate current design decisions and set you on a path to simplicity nirvana.