SlideShare a Scribd company logo
Crafting APIs
Thoughts and tips
Tatiana Al-Chueyr
@tati_alchueyr
We need to build an API for
UFC API
/getAllFighters
/playMatches
/createChallenge
/addFightToSchedule
/saveFight
/getPhotosOfRhonda
/listLast20News
/showMachida
/fights_by_jose_aldo
After all… UFC world is huge!
Keep the simple things simple.
UFC API
We only need base URLs as resources
/fighters
/fighters/JoseAldo
/events
/events/162
UFC API
What about actions?
UFC API
What about actions?
POST
GET
PUT
DELETE
UFC API
What about actions?
CREATE: POST
RETRIEVE: GET
UPDATE: PUT
DELETE: DELETE
UFC API
POST GET PUT DELETE
/figthers create a new
fighter
list fighters replace all fighters delete all fighters
/fighters/JoseAldo - show José Aldo update José Aldo
info
delete José Aldo
REST APIs
Don’t use verbs in resources identifiers
Use nouns
REST?
● Architectural style
● REpresentational State Transfer
● Response to the complexity of SOAP based
web services and many other standards
● Took off with Web 2.0
● Way to create easy to use web services
“A RESTifarian is a zealous proponent of
the REST software architectural style as
defined by Roy T. Fielding in Chapter 5 of
his PhD. dissertation at UCIrvine. You can
find RESTifarians in the wild on the
REST-discuss mailing list. But be careful,
RESTifarians can be extremely meticulous
when discussing the finer points of REST, as
I learned recently while participating on the
list. :)” by Mike Schinkel
http://mikeschinkel.com/blog/whatisarestafarian/
REST Principles
1. Client-server
2. Stateless server
3. Cache
4. Uniform interface
a. Identification of resources
b. Manipulation of resources through representations
c. Self-descriptive messages
d. Hypermedia as the engine of application state
5. Layered System
https://blog.apigee.com/detail/hateoas_101_introduction_to_a_rest_api_style_video_slides
REST Principles
Client-cache-stateless-server web
architecture…
which let us scale the web :)
REST Principles
1. Client-server
2. Stateless server
3. Cache
4. Uniform interface
a. Identification of resources
b. Manipulation of resources through representations
c. Self-descriptive messages
d. Hypermedia as the engine of application state
5. Layered System
https://blog.apigee.com/detail/hateoas_101_introduction_to_a_rest_api_style_video_slides
REST Principles
Layered system: let us add feature like a
gateway, load balancer and firewall
REST Principles
1. Client-server
2. Stateless server
3. Cache
4. Uniform interface
a. Identification of resources
b. Manipulation of resources through representations
c. Self-descriptive messages
d. Hypermedia as the engine of application state
5. Layered System
https://blog.apigee.com/detail/hateoas_101_introduction_to_a_rest_api_style_video_slides
REST Principles
4.a. Identification
http://urls.api.twitter.com/1/urls/count.json?url=http://g1.globo.com
4.b. Representation
{"count":39285,
"url":"http://g1.globo.com/"}
4.c. Messages and errors
http://urls.api.twitter.com/1/urls/counte.json?url=http://g1.globo.com
twttr.receiveCount({"errors":[{"code":48,"message":"Unable to access URL
counting services"}]})
REST Principles
4.d. Hypermedia as the engine of application
state (HATEOAS)
● In each response message include the links
for the next request message.
● And navigate your way through every state
of the entire application
HATEOAS
"The name 'Representational State Transfer' is intended to evoke an
image of how a well-designed Web application behaves: a network of
web pages (a virtual state-machine), where the user progresses
through the application by selecting links (state transitions), resulting in
the next page (representing the next state of the application) being
transferred to the user and rendered for their use."
Roy Fielding
Architectural styles and the Design of Network-based Software
Architectures, Chapter 6
HATEOAS
"If the engine of application state (and hence the API) is not being
driven by hypertext, then it cannot be RESTful and cannot be a REST
API. Period. Is there some broken manual somwhere that needs to be
fixed?"
Roy Fielding
"REST APIs must be hypertext-driven"
Untangled: Musings of Roy T. Fielding
HATEOAS in Practice
Install JSONBrowser plugin
And navigate:
http://brainiak.dev.semantica.globo.com/
HATEOAS +
● Good for browsing
● Good for indexing
● Good for generic applications (e.g. CMAaS)
● Kind of auto-documentation
● Can help when contracts change
HATEOAS -
● Too much work
● No established standard (JSON Schema is
progressing every day)
● Does it really help when contracts change?
● How pragmatic is it to use it?
RESTlike but not RESTfull
Is CloudStack API RESTfull?
"The short answer is that the CloudStack API is
RESTlike but not RESTfull since it is only
based on the GET method. Being an http
based API that can return JSON does not make
it a RESTfull API. This should not be seen as
negative criticism but just a clarification."
http://sebgoa.blogspot.com.br/2013/04/to-rest-or-not-to-rest.html
To REST or not to REST
Don't design any API to conform to REST just
for the REST's sake
Define which principles and practices are "best"
for a given application
RESTafarian or a Pragmatist
API Flamewars
Some discussions that showed off while we
were developing Brainiak API and some other
interesting points.
https://blog.apigee.com/detail/slides_for_restful_api_design_second_edition_w
ebinar/
Plurals x singulars
Foursquare
/checkins
GroupOn
/deals
Zappos
/Product
Plurals x singulars
Usually plurals are better….
But not always (e.g. Brainiak)
http://www.restapitutorial.com/lessons/restfulresourcenaming.html
http://stackoverflow.com/questions/6845772/rest-uri-convention-singular-or-plur
al-name-of-resource-while-creating-it
Abstract or concrete naming?
Super High
/things
High
/people
Medium
/fighters
Low
/brazilianFighers
Abstract or concrete naming?
Concrete is better than abstract:
/fighters
Errors
Facebook satus code: 200
{"type": "OAuthException", "message": "(#803) Some of the aliases you
requested do not exist: foo.bar"}
Twilio status code: 401
{"status": 401, "message": "Authenticate", "code":"20003", "more_info":
"http://www.twilio.com/docs/errors/20003"}
SimpleGeo status code: 401
{"code": 401, "message": "Authentication Required"}
Errors
Code for code
200 - OK
401 - Unauthorized
http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
Errors
Message for people
{"message": "verbose, plain language description of the
problem with hints about how to fix it",
"more_info": "http://link.to/more_info_about/errorx"}
Versioning
Twilio
/2010-04-01/Accounts/
salesforce.com
/services/data/v20.0/sobjects/Account
Facebook
?v=1.0
Versioning
This far, we used this for Semantic APIs at Globo.com:
/v1/fighters/
JSON attributes naming
Twitter
"created_at": "Thu Nov 03 05:19:38 +0000 2011"
Bing
"DateTime": "2011-10-29T09:35:00Z"
Foursquare
"createdAt": 13450391
JSON attributes naming
Use JavaScript Convention
Pagination
Facebook
offset
limit
Twitter
page
rpp
LinkedIn
start
count
Pagination
Globo.com
page
per_page
Idempotence
http://www.restapitutorial.com/lessons/idempot
ency.html
Other flamewars
What if the pagination has no results?
● Inexistent resource (404)
● Empty resource (200)
Other flamewars
How to provide optional parameters to a GET?
● Query string
● Payload
Other flamewars
In a pagination, should we return item_count
even if it slows down the performance in 50%?
Good REST API Example
Github
http://developer.github.com/v3/
https://api.github.com/orgs/globocom/repos
https://api.github.com/repos/globocom/tsuru/iss
ues?state=closed
Technology that fits your needs
What do you expect for…
● number of access per day..?
● number of updates..?
● number of reads..?
● need of database to store data..?
Technology that fits your needs
Depending on your needs, different python
libraries could help you:
● Django
● Flask
● Gevent
● Tornado
Asynchronous x Synchronous
"A simple approach to I/O would be to start the access and
then wait for it to complete. But such an approach (called
synchronous I/O or blocking I/O) would block the progress
of a program while the communication is in progress,
leaving system resources idle. When a program makes
many I/O operations, this means that the processor can
spend almost all of its time idle waiting for I/O operations to
complete."
http://en.wikipedia.org/wiki/Asynchronous_I/O
Who will access your API?
Will your API support cross origin access using
AJAX requests?
● CORS W3C working draft:
http://www.w3.org/TR/cors
● HTML 5 Security Guide:
http://code.google.com/p/html5security/wiki/
CrossOriginRequestSecurity
Final thoughts
● What problem are you solving?
● For whom is your API?
● What are the performance needs?
● Is an HTTP API the best solution? (e.g. have
a look at protocol buffers)
● Think about how to model your API before
implementing it
Final thoughts
Keep an eye on good reputation APIs
● Github
● ElasticSearch
Final thoughts
Be pragmatic.
For the benefit of application developers.
Keep your documentation up-to-date.
More tips on crafting APIs
http://www.restapitutorial.com/lessons/restquicktips.html
http://www.vinaysahni.com/best-practices-for-a-pragmatic-restful-api#hateoas
http://mark-kirby.co.uk/2013/creating-a-true-rest-api/
http://www.slideshare.net/mario_cardinal/best-practices-for-designing-pragmati
c-restful-api
http://blog.luisrei.com/articles/rest.html
Thanks!
Tati Al-Chueyr
tatiana.martins@corp.globo.com
@tati_alchueyr

More Related Content

What's hot

H2O 3 REST API Overview
H2O 3 REST API OverviewH2O 3 REST API Overview
H2O 3 REST API Overview
Raymond Peck
 
Apache Airflow in the Cloud: Programmatically orchestrating workloads with Py...
Apache Airflow in the Cloud: Programmatically orchestrating workloads with Py...Apache Airflow in the Cloud: Programmatically orchestrating workloads with Py...
Apache Airflow in the Cloud: Programmatically orchestrating workloads with Py...
Kaxil Naik
 
Capacity Planning Infrastructure for Web Applications (Drupal)
Capacity Planning Infrastructure for Web Applications (Drupal)Capacity Planning Infrastructure for Web Applications (Drupal)
Capacity Planning Infrastructure for Web Applications (Drupal)
Ricardo Amaro
 
Asynchronous Hyperparameter Optimization with Apache Spark
Asynchronous Hyperparameter Optimization with Apache SparkAsynchronous Hyperparameter Optimization with Apache Spark
Asynchronous Hyperparameter Optimization with Apache Spark
Databricks
 
Hacking Web Performance
Hacking Web Performance Hacking Web Performance
Hacking Web Performance
Maximiliano Firtman
 
Validating Big Data Jobs—Stopping Failures Before Production on Apache Spark...
 Validating Big Data Jobs—Stopping Failures Before Production on Apache Spark... Validating Big Data Jobs—Stopping Failures Before Production on Apache Spark...
Validating Big Data Jobs—Stopping Failures Before Production on Apache Spark...
Databricks
 
Unified Batch and Real-Time Stream Processing Using Apache Flink
Unified Batch and Real-Time Stream Processing Using Apache FlinkUnified Batch and Real-Time Stream Processing Using Apache Flink
Unified Batch and Real-Time Stream Processing Using Apache Flink
Slim Baltagi
 
Automatic and Interpretable Machine Learning with H2O and LIME
Automatic and Interpretable Machine Learning with H2O and LIMEAutomatic and Interpretable Machine Learning with H2O and LIME
Automatic and Interpretable Machine Learning with H2O and LIME
Jo-fai Chow
 
Why apache Flink is the 4G of Big Data Analytics Frameworks
Why apache Flink is the 4G of Big Data Analytics FrameworksWhy apache Flink is the 4G of Big Data Analytics Frameworks
Why apache Flink is the 4G of Big Data Analytics Frameworks
Slim Baltagi
 
Airflow at lyft
Airflow at lyftAirflow at lyft
Airflow at lyft
Tao Feng
 
Workflow Engines + Luigi
Workflow Engines + LuigiWorkflow Engines + Luigi
Workflow Engines + Luigi
Vladislav Supalov
 
Simplify and Boost Spark 3 Deployments with Hypervisor-Native Kubernetes
Simplify and Boost Spark 3 Deployments with Hypervisor-Native KubernetesSimplify and Boost Spark 3 Deployments with Hypervisor-Native Kubernetes
Simplify and Boost Spark 3 Deployments with Hypervisor-Native Kubernetes
Databricks
 
Powering tensor flow with big data using apache beam, flink, and spark cern...
Powering tensor flow with big data using apache beam, flink, and spark   cern...Powering tensor flow with big data using apache beam, flink, and spark   cern...
Powering tensor flow with big data using apache beam, flink, and spark cern...
Holden Karau
 
data.table and H2O at LondonR with Matt Dowle
data.table and H2O at LondonR with Matt Dowledata.table and H2O at LondonR with Matt Dowle
data.table and H2O at LondonR with Matt Dowle
Sri Ambati
 
H2O World - PySparkling Water - Nidhi Mehta
H2O World - PySparkling Water - Nidhi MehtaH2O World - PySparkling Water - Nidhi Mehta
H2O World - PySparkling Water - Nidhi Mehta
Sri Ambati
 
Apache Storm and Oracle Event Processing for Real-time Analytics
Apache Storm and Oracle Event Processing for Real-time AnalyticsApache Storm and Oracle Event Processing for Real-time Analytics
Apache Storm and Oracle Event Processing for Real-time Analytics
Prabhu Thukkaram
 
Managing data workflows with Luigi
Managing data workflows with LuigiManaging data workflows with Luigi
Managing data workflows with Luigi
Teemu Kurppa
 
Hydrosphere.io for ODSC: Webinar on Kubeflow
Hydrosphere.io for ODSC: Webinar on KubeflowHydrosphere.io for ODSC: Webinar on Kubeflow
Hydrosphere.io for ODSC: Webinar on Kubeflow
Rustem Zakiev
 
XSEDE14 SciGaP-Apache Airavata Tutorial
XSEDE14 SciGaP-Apache Airavata TutorialXSEDE14 SciGaP-Apache Airavata Tutorial
XSEDE14 SciGaP-Apache Airavata Tutorial
marpierc
 

What's hot (20)

H2O 3 REST API Overview
H2O 3 REST API OverviewH2O 3 REST API Overview
H2O 3 REST API Overview
 
Apache Airflow in the Cloud: Programmatically orchestrating workloads with Py...
Apache Airflow in the Cloud: Programmatically orchestrating workloads with Py...Apache Airflow in the Cloud: Programmatically orchestrating workloads with Py...
Apache Airflow in the Cloud: Programmatically orchestrating workloads with Py...
 
Capacity Planning Infrastructure for Web Applications (Drupal)
Capacity Planning Infrastructure for Web Applications (Drupal)Capacity Planning Infrastructure for Web Applications (Drupal)
Capacity Planning Infrastructure for Web Applications (Drupal)
 
Asynchronous Hyperparameter Optimization with Apache Spark
Asynchronous Hyperparameter Optimization with Apache SparkAsynchronous Hyperparameter Optimization with Apache Spark
Asynchronous Hyperparameter Optimization with Apache Spark
 
Hacking Web Performance
Hacking Web Performance Hacking Web Performance
Hacking Web Performance
 
Validating Big Data Jobs—Stopping Failures Before Production on Apache Spark...
 Validating Big Data Jobs—Stopping Failures Before Production on Apache Spark... Validating Big Data Jobs—Stopping Failures Before Production on Apache Spark...
Validating Big Data Jobs—Stopping Failures Before Production on Apache Spark...
 
Unified Batch and Real-Time Stream Processing Using Apache Flink
Unified Batch and Real-Time Stream Processing Using Apache FlinkUnified Batch and Real-Time Stream Processing Using Apache Flink
Unified Batch and Real-Time Stream Processing Using Apache Flink
 
Automatic and Interpretable Machine Learning with H2O and LIME
Automatic and Interpretable Machine Learning with H2O and LIMEAutomatic and Interpretable Machine Learning with H2O and LIME
Automatic and Interpretable Machine Learning with H2O and LIME
 
Why apache Flink is the 4G of Big Data Analytics Frameworks
Why apache Flink is the 4G of Big Data Analytics FrameworksWhy apache Flink is the 4G of Big Data Analytics Frameworks
Why apache Flink is the 4G of Big Data Analytics Frameworks
 
Airflow at lyft
Airflow at lyftAirflow at lyft
Airflow at lyft
 
NYC_2016_slides
NYC_2016_slidesNYC_2016_slides
NYC_2016_slides
 
Workflow Engines + Luigi
Workflow Engines + LuigiWorkflow Engines + Luigi
Workflow Engines + Luigi
 
Simplify and Boost Spark 3 Deployments with Hypervisor-Native Kubernetes
Simplify and Boost Spark 3 Deployments with Hypervisor-Native KubernetesSimplify and Boost Spark 3 Deployments with Hypervisor-Native Kubernetes
Simplify and Boost Spark 3 Deployments with Hypervisor-Native Kubernetes
 
Powering tensor flow with big data using apache beam, flink, and spark cern...
Powering tensor flow with big data using apache beam, flink, and spark   cern...Powering tensor flow with big data using apache beam, flink, and spark   cern...
Powering tensor flow with big data using apache beam, flink, and spark cern...
 
data.table and H2O at LondonR with Matt Dowle
data.table and H2O at LondonR with Matt Dowledata.table and H2O at LondonR with Matt Dowle
data.table and H2O at LondonR with Matt Dowle
 
H2O World - PySparkling Water - Nidhi Mehta
H2O World - PySparkling Water - Nidhi MehtaH2O World - PySparkling Water - Nidhi Mehta
H2O World - PySparkling Water - Nidhi Mehta
 
Apache Storm and Oracle Event Processing for Real-time Analytics
Apache Storm and Oracle Event Processing for Real-time AnalyticsApache Storm and Oracle Event Processing for Real-time Analytics
Apache Storm and Oracle Event Processing for Real-time Analytics
 
Managing data workflows with Luigi
Managing data workflows with LuigiManaging data workflows with Luigi
Managing data workflows with Luigi
 
Hydrosphere.io for ODSC: Webinar on Kubeflow
Hydrosphere.io for ODSC: Webinar on KubeflowHydrosphere.io for ODSC: Webinar on Kubeflow
Hydrosphere.io for ODSC: Webinar on Kubeflow
 
XSEDE14 SciGaP-Apache Airavata Tutorial
XSEDE14 SciGaP-Apache Airavata TutorialXSEDE14 SciGaP-Apache Airavata Tutorial
XSEDE14 SciGaP-Apache Airavata Tutorial
 

Similar to Crafting APIs

REST API Basics
REST API BasicsREST API Basics
REST API Basics
Tharindu Weerasinghe
 
API Workshop: Deep dive into REST APIs
API Workshop: Deep dive into REST APIsAPI Workshop: Deep dive into REST APIs
API Workshop: Deep dive into REST APIs
Tom Johnson
 
ASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiASP.NET Mvc 4 web api
ASP.NET Mvc 4 web api
Tiago Knoch
 
Best Practices for Architecting a Pragmatic Web API.
Best Practices for Architecting a Pragmatic Web API.Best Practices for Architecting a Pragmatic Web API.
Best Practices for Architecting a Pragmatic Web API.
Mario Cardinal
 
Web Dev 21-01-2024.pptx
Web Dev 21-01-2024.pptxWeb Dev 21-01-2024.pptx
Web Dev 21-01-2024.pptx
PARDHIVANNABATTULA
 
Schema-First API Design
Schema-First API DesignSchema-First API Design
Schema-First API Design
Yos Riady
 
Introduction to Apigility
Introduction to ApigilityIntroduction to Apigility
Introduction to Apigility
Engineor
 
Apigility introduction v2 (glasgow php)
Apigility introduction v2 (glasgow php)Apigility introduction v2 (glasgow php)
Apigility introduction v2 (glasgow php)
Engineor
 
Node.js Course 2 of 2 - Advanced techniques
Node.js Course 2 of 2 - Advanced techniquesNode.js Course 2 of 2 - Advanced techniques
Node.js Course 2 of 2 - Advanced techniques
Manuel Eusebio de Paz Carmona
 
apidays LIVE Paris - Potential of API integrations, common traps and advices ...
apidays LIVE Paris - Potential of API integrations, common traps and advices ...apidays LIVE Paris - Potential of API integrations, common traps and advices ...
apidays LIVE Paris - Potential of API integrations, common traps and advices ...
apidays
 
The ultimate api checklist by Blendr.io
The ultimate api checklist by Blendr.ioThe ultimate api checklist by Blendr.io
The ultimate api checklist by Blendr.io
Blendr.io
 
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
 
JOSA TechTalks - RESTful API Concepts and Best Practices
JOSA TechTalks - RESTful API Concepts and Best PracticesJOSA TechTalks - RESTful API Concepts and Best Practices
JOSA TechTalks - RESTful API Concepts and Best Practices
Jordan Open Source Association
 
Itb 2021 - Bulding Quick APIs by Gavin Pickin
Itb 2021 - Bulding Quick APIs by Gavin PickinItb 2021 - Bulding Quick APIs by Gavin Pickin
Itb 2021 - Bulding Quick APIs by Gavin Pickin
Gavin Pickin
 
Talking to Web Services
Talking to Web ServicesTalking to Web Services
Talking to Web Services
DrupalcampAtlanta2012
 
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
Evan Mullins
 
Cqrs api
Cqrs apiCqrs api
Cqrs api
Brandon Mueller
 
API Services: Building State-of-the-Art APIs
API Services: Building State-of-the-Art APIsAPI Services: Building State-of-the-Art APIs
API Services: Building State-of-the-Art APIs
Apigee | Google Cloud
 
Gohan
GohanGohan
Gohan
Nachi Ueno
 

Similar to Crafting APIs (20)

REST API Basics
REST API BasicsREST API Basics
REST API Basics
 
API Workshop: Deep dive into REST APIs
API Workshop: Deep dive into REST APIsAPI Workshop: Deep dive into REST APIs
API Workshop: Deep dive into REST APIs
 
ASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiASP.NET Mvc 4 web api
ASP.NET Mvc 4 web api
 
Best Practices for Architecting a Pragmatic Web API.
Best Practices for Architecting a Pragmatic Web API.Best Practices for Architecting a Pragmatic Web API.
Best Practices for Architecting a Pragmatic Web API.
 
Web Dev 21-01-2024.pptx
Web Dev 21-01-2024.pptxWeb Dev 21-01-2024.pptx
Web Dev 21-01-2024.pptx
 
Schema-First API Design
Schema-First API DesignSchema-First API Design
Schema-First API Design
 
Introduction to Apigility
Introduction to ApigilityIntroduction to Apigility
Introduction to Apigility
 
Apigility introduction v2 (glasgow php)
Apigility introduction v2 (glasgow php)Apigility introduction v2 (glasgow php)
Apigility introduction v2 (glasgow php)
 
Node.js Course 2 of 2 - Advanced techniques
Node.js Course 2 of 2 - Advanced techniquesNode.js Course 2 of 2 - Advanced techniques
Node.js Course 2 of 2 - Advanced techniques
 
apidays LIVE Paris - Potential of API integrations, common traps and advices ...
apidays LIVE Paris - Potential of API integrations, common traps and advices ...apidays LIVE Paris - Potential of API integrations, common traps and advices ...
apidays LIVE Paris - Potential of API integrations, common traps and advices ...
 
The ultimate api checklist by Blendr.io
The ultimate api checklist by Blendr.ioThe ultimate api checklist by Blendr.io
The ultimate api checklist by Blendr.io
 
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...
 
Codeigniter
CodeigniterCodeigniter
Codeigniter
 
JOSA TechTalks - RESTful API Concepts and Best Practices
JOSA TechTalks - RESTful API Concepts and Best PracticesJOSA TechTalks - RESTful API Concepts and Best Practices
JOSA TechTalks - RESTful API Concepts and Best Practices
 
Itb 2021 - Bulding Quick APIs by Gavin Pickin
Itb 2021 - Bulding Quick APIs by Gavin PickinItb 2021 - Bulding Quick APIs by Gavin Pickin
Itb 2021 - Bulding Quick APIs by Gavin Pickin
 
Talking to Web Services
Talking to Web ServicesTalking to Web Services
Talking to Web Services
 
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
 
Cqrs api
Cqrs apiCqrs api
Cqrs api
 
API Services: Building State-of-the-Art APIs
API Services: Building State-of-the-Art APIsAPI Services: Building State-of-the-Art APIs
API Services: Building State-of-the-Art APIs
 
Gohan
GohanGohan
Gohan
 

More from Tatiana Al-Chueyr

Integrating ChatGPT with Apache Airflow
Integrating ChatGPT with Apache AirflowIntegrating ChatGPT with Apache Airflow
Integrating ChatGPT with Apache Airflow
Tatiana Al-Chueyr
 
Contributing to Apache Airflow
Contributing to Apache AirflowContributing to Apache Airflow
Contributing to Apache Airflow
Tatiana Al-Chueyr
 
Scaling machine learning workflows with Apache Beam
Scaling machine learning workflows with Apache BeamScaling machine learning workflows with Apache Beam
Scaling machine learning workflows with Apache Beam
Tatiana Al-Chueyr
 
Responsible machine learning at the BBC
Responsible machine learning at the BBCResponsible machine learning at the BBC
Responsible machine learning at the BBC
Tatiana Al-Chueyr
 
Responsible Machine Learning at the BBC
Responsible Machine Learning at the BBCResponsible Machine Learning at the BBC
Responsible Machine Learning at the BBC
Tatiana Al-Chueyr
 
Sprint cPython at Globo.com
Sprint cPython at Globo.comSprint cPython at Globo.com
Sprint cPython at Globo.com
Tatiana Al-Chueyr
 
PyConUK 2016 - Writing English Right
PyConUK 2016  - Writing English RightPyConUK 2016  - Writing English Right
PyConUK 2016 - Writing English Right
Tatiana Al-Chueyr
 
InVesalius: 3D medical imaging software
InVesalius: 3D medical imaging softwareInVesalius: 3D medical imaging software
InVesalius: 3D medical imaging software
Tatiana Al-Chueyr
 
Automatic English text correction
Automatic English text correctionAutomatic English text correction
Automatic English text correction
Tatiana Al-Chueyr
 
Python packaging and dependency resolution
Python packaging and dependency resolutionPython packaging and dependency resolution
Python packaging and dependency resolution
Tatiana Al-Chueyr
 
Rio info 2013 - Linked Data at Globo.com
Rio info 2013 - Linked Data at Globo.comRio info 2013 - Linked Data at Globo.com
Rio info 2013 - Linked Data at Globo.com
Tatiana Al-Chueyr
 
PythonBrasil[8] closing
PythonBrasil[8] closingPythonBrasil[8] closing
PythonBrasil[8] closing
Tatiana Al-Chueyr
 
Linking the world with Python and Semantics
Linking the world with Python and SemanticsLinking the world with Python and Semantics
Linking the world with Python and Semantics
Tatiana Al-Chueyr
 
Desarollando aplicaciones web en python con pruebas
Desarollando aplicaciones web en python con pruebasDesarollando aplicaciones web en python con pruebas
Desarollando aplicaciones web en python con pruebasTatiana Al-Chueyr
 
Desarollando aplicaciones móviles con Python y Android
Desarollando aplicaciones móviles con Python y AndroidDesarollando aplicaciones móviles con Python y Android
Desarollando aplicaciones móviles con Python y Android
Tatiana Al-Chueyr
 
Transifex: Ensinando o seu Software Público a falar novos idiomas
Transifex: Ensinando o seu Software Público a falar novos idiomasTransifex: Ensinando o seu Software Público a falar novos idiomas
Transifex: Ensinando o seu Software Público a falar novos idiomas
Tatiana Al-Chueyr
 

More from Tatiana Al-Chueyr (16)

Integrating ChatGPT with Apache Airflow
Integrating ChatGPT with Apache AirflowIntegrating ChatGPT with Apache Airflow
Integrating ChatGPT with Apache Airflow
 
Contributing to Apache Airflow
Contributing to Apache AirflowContributing to Apache Airflow
Contributing to Apache Airflow
 
Scaling machine learning workflows with Apache Beam
Scaling machine learning workflows with Apache BeamScaling machine learning workflows with Apache Beam
Scaling machine learning workflows with Apache Beam
 
Responsible machine learning at the BBC
Responsible machine learning at the BBCResponsible machine learning at the BBC
Responsible machine learning at the BBC
 
Responsible Machine Learning at the BBC
Responsible Machine Learning at the BBCResponsible Machine Learning at the BBC
Responsible Machine Learning at the BBC
 
Sprint cPython at Globo.com
Sprint cPython at Globo.comSprint cPython at Globo.com
Sprint cPython at Globo.com
 
PyConUK 2016 - Writing English Right
PyConUK 2016  - Writing English RightPyConUK 2016  - Writing English Right
PyConUK 2016 - Writing English Right
 
InVesalius: 3D medical imaging software
InVesalius: 3D medical imaging softwareInVesalius: 3D medical imaging software
InVesalius: 3D medical imaging software
 
Automatic English text correction
Automatic English text correctionAutomatic English text correction
Automatic English text correction
 
Python packaging and dependency resolution
Python packaging and dependency resolutionPython packaging and dependency resolution
Python packaging and dependency resolution
 
Rio info 2013 - Linked Data at Globo.com
Rio info 2013 - Linked Data at Globo.comRio info 2013 - Linked Data at Globo.com
Rio info 2013 - Linked Data at Globo.com
 
PythonBrasil[8] closing
PythonBrasil[8] closingPythonBrasil[8] closing
PythonBrasil[8] closing
 
Linking the world with Python and Semantics
Linking the world with Python and SemanticsLinking the world with Python and Semantics
Linking the world with Python and Semantics
 
Desarollando aplicaciones web en python con pruebas
Desarollando aplicaciones web en python con pruebasDesarollando aplicaciones web en python con pruebas
Desarollando aplicaciones web en python con pruebas
 
Desarollando aplicaciones móviles con Python y Android
Desarollando aplicaciones móviles con Python y AndroidDesarollando aplicaciones móviles con Python y Android
Desarollando aplicaciones móviles con Python y Android
 
Transifex: Ensinando o seu Software Público a falar novos idiomas
Transifex: Ensinando o seu Software Público a falar novos idiomasTransifex: Ensinando o seu Software Público a falar novos idiomas
Transifex: Ensinando o seu Software Público a falar novos idiomas
 

Recently uploaded

State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
Abida Shariff
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 

Recently uploaded (20)

State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 

Crafting APIs

  • 1. Crafting APIs Thoughts and tips Tatiana Al-Chueyr @tati_alchueyr
  • 2. We need to build an API for
  • 4. After all… UFC world is huge!
  • 5. Keep the simple things simple.
  • 6. UFC API We only need base URLs as resources /fighters /fighters/JoseAldo /events /events/162
  • 8. UFC API What about actions? POST GET PUT DELETE
  • 9. UFC API What about actions? CREATE: POST RETRIEVE: GET UPDATE: PUT DELETE: DELETE
  • 10. UFC API POST GET PUT DELETE /figthers create a new fighter list fighters replace all fighters delete all fighters /fighters/JoseAldo - show José Aldo update José Aldo info delete José Aldo
  • 11. REST APIs Don’t use verbs in resources identifiers Use nouns
  • 12. REST? ● Architectural style ● REpresentational State Transfer ● Response to the complexity of SOAP based web services and many other standards ● Took off with Web 2.0 ● Way to create easy to use web services
  • 13. “A RESTifarian is a zealous proponent of the REST software architectural style as defined by Roy T. Fielding in Chapter 5 of his PhD. dissertation at UCIrvine. You can find RESTifarians in the wild on the REST-discuss mailing list. But be careful, RESTifarians can be extremely meticulous when discussing the finer points of REST, as I learned recently while participating on the list. :)” by Mike Schinkel http://mikeschinkel.com/blog/whatisarestafarian/
  • 14. REST Principles 1. Client-server 2. Stateless server 3. Cache 4. Uniform interface a. Identification of resources b. Manipulation of resources through representations c. Self-descriptive messages d. Hypermedia as the engine of application state 5. Layered System https://blog.apigee.com/detail/hateoas_101_introduction_to_a_rest_api_style_video_slides
  • 16.
  • 17. REST Principles 1. Client-server 2. Stateless server 3. Cache 4. Uniform interface a. Identification of resources b. Manipulation of resources through representations c. Self-descriptive messages d. Hypermedia as the engine of application state 5. Layered System https://blog.apigee.com/detail/hateoas_101_introduction_to_a_rest_api_style_video_slides
  • 18. REST Principles Layered system: let us add feature like a gateway, load balancer and firewall
  • 19.
  • 20. REST Principles 1. Client-server 2. Stateless server 3. Cache 4. Uniform interface a. Identification of resources b. Manipulation of resources through representations c. Self-descriptive messages d. Hypermedia as the engine of application state 5. Layered System https://blog.apigee.com/detail/hateoas_101_introduction_to_a_rest_api_style_video_slides
  • 21. REST Principles 4.a. Identification http://urls.api.twitter.com/1/urls/count.json?url=http://g1.globo.com 4.b. Representation {"count":39285, "url":"http://g1.globo.com/"} 4.c. Messages and errors http://urls.api.twitter.com/1/urls/counte.json?url=http://g1.globo.com twttr.receiveCount({"errors":[{"code":48,"message":"Unable to access URL counting services"}]})
  • 22. REST Principles 4.d. Hypermedia as the engine of application state (HATEOAS) ● In each response message include the links for the next request message. ● And navigate your way through every state of the entire application
  • 23.
  • 24. HATEOAS "The name 'Representational State Transfer' is intended to evoke an image of how a well-designed Web application behaves: a network of web pages (a virtual state-machine), where the user progresses through the application by selecting links (state transitions), resulting in the next page (representing the next state of the application) being transferred to the user and rendered for their use." Roy Fielding Architectural styles and the Design of Network-based Software Architectures, Chapter 6
  • 25. HATEOAS "If the engine of application state (and hence the API) is not being driven by hypertext, then it cannot be RESTful and cannot be a REST API. Period. Is there some broken manual somwhere that needs to be fixed?" Roy Fielding "REST APIs must be hypertext-driven" Untangled: Musings of Roy T. Fielding
  • 26. HATEOAS in Practice Install JSONBrowser plugin And navigate: http://brainiak.dev.semantica.globo.com/
  • 27. HATEOAS + ● Good for browsing ● Good for indexing ● Good for generic applications (e.g. CMAaS) ● Kind of auto-documentation ● Can help when contracts change
  • 28. HATEOAS - ● Too much work ● No established standard (JSON Schema is progressing every day) ● Does it really help when contracts change? ● How pragmatic is it to use it?
  • 29. RESTlike but not RESTfull Is CloudStack API RESTfull? "The short answer is that the CloudStack API is RESTlike but not RESTfull since it is only based on the GET method. Being an http based API that can return JSON does not make it a RESTfull API. This should not be seen as negative criticism but just a clarification." http://sebgoa.blogspot.com.br/2013/04/to-rest-or-not-to-rest.html
  • 30. To REST or not to REST Don't design any API to conform to REST just for the REST's sake Define which principles and practices are "best" for a given application
  • 31. RESTafarian or a Pragmatist
  • 32. API Flamewars Some discussions that showed off while we were developing Brainiak API and some other interesting points. https://blog.apigee.com/detail/slides_for_restful_api_design_second_edition_w ebinar/
  • 34. Plurals x singulars Usually plurals are better…. But not always (e.g. Brainiak) http://www.restapitutorial.com/lessons/restfulresourcenaming.html http://stackoverflow.com/questions/6845772/rest-uri-convention-singular-or-plur al-name-of-resource-while-creating-it
  • 35. Abstract or concrete naming? Super High /things High /people Medium /fighters Low /brazilianFighers
  • 36. Abstract or concrete naming? Concrete is better than abstract: /fighters
  • 37. Errors Facebook satus code: 200 {"type": "OAuthException", "message": "(#803) Some of the aliases you requested do not exist: foo.bar"} Twilio status code: 401 {"status": 401, "message": "Authenticate", "code":"20003", "more_info": "http://www.twilio.com/docs/errors/20003"} SimpleGeo status code: 401 {"code": 401, "message": "Authentication Required"}
  • 38. Errors Code for code 200 - OK 401 - Unauthorized http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
  • 39. Errors Message for people {"message": "verbose, plain language description of the problem with hints about how to fix it", "more_info": "http://link.to/more_info_about/errorx"}
  • 41. Versioning This far, we used this for Semantic APIs at Globo.com: /v1/fighters/
  • 42. JSON attributes naming Twitter "created_at": "Thu Nov 03 05:19:38 +0000 2011" Bing "DateTime": "2011-10-29T09:35:00Z" Foursquare "createdAt": 13450391
  • 43. JSON attributes naming Use JavaScript Convention
  • 47. Other flamewars What if the pagination has no results? ● Inexistent resource (404) ● Empty resource (200)
  • 48. Other flamewars How to provide optional parameters to a GET? ● Query string ● Payload
  • 49. Other flamewars In a pagination, should we return item_count even if it slows down the performance in 50%?
  • 50. Good REST API Example Github http://developer.github.com/v3/ https://api.github.com/orgs/globocom/repos https://api.github.com/repos/globocom/tsuru/iss ues?state=closed
  • 51. Technology that fits your needs What do you expect for… ● number of access per day..? ● number of updates..? ● number of reads..? ● need of database to store data..?
  • 52. Technology that fits your needs Depending on your needs, different python libraries could help you: ● Django ● Flask ● Gevent ● Tornado
  • 53. Asynchronous x Synchronous "A simple approach to I/O would be to start the access and then wait for it to complete. But such an approach (called synchronous I/O or blocking I/O) would block the progress of a program while the communication is in progress, leaving system resources idle. When a program makes many I/O operations, this means that the processor can spend almost all of its time idle waiting for I/O operations to complete." http://en.wikipedia.org/wiki/Asynchronous_I/O
  • 54. Who will access your API? Will your API support cross origin access using AJAX requests? ● CORS W3C working draft: http://www.w3.org/TR/cors ● HTML 5 Security Guide: http://code.google.com/p/html5security/wiki/ CrossOriginRequestSecurity
  • 55. Final thoughts ● What problem are you solving? ● For whom is your API? ● What are the performance needs? ● Is an HTTP API the best solution? (e.g. have a look at protocol buffers) ● Think about how to model your API before implementing it
  • 56. Final thoughts Keep an eye on good reputation APIs ● Github ● ElasticSearch
  • 57. Final thoughts Be pragmatic. For the benefit of application developers. Keep your documentation up-to-date.
  • 58. More tips on crafting APIs http://www.restapitutorial.com/lessons/restquicktips.html http://www.vinaysahni.com/best-practices-for-a-pragmatic-restful-api#hateoas http://mark-kirby.co.uk/2013/creating-a-true-rest-api/ http://www.slideshare.net/mario_cardinal/best-practices-for-designing-pragmati c-restful-api http://blog.luisrei.com/articles/rest.html