SlideShare a Scribd company logo
Globalcode – Open4education
JSON API: não reinvente a roda
Pedro Cavalheiro
Trilha Web
Globalcode – Open4education
Pedro Cavalheiro
Desenvolvedor web há 6 anos, em sua
maioria trabalhando com Ruby e PHP.
Entusiasta por tecnologia como um todo,
adora estudar novas ferramentas,
linguagens e metodologias.
Atualmente no Me Salva!.
Infos em pecavalheiro.com
Globalcode – Open4education
Did I hear API?
Globalcode – Open4education
API
• Application Programming Interface
• Web Services (HTTP)
• SOAP
• REST
• JSON
Globalcode – Open4education
REST API
• O que é importante?
• Segurança/Autenticação
• Documentação
• Requisitos/Complexidade
• Design de requisições/respostas
• +
Globalcode – Open4education
Globalcode – Open4education
bikeshed (noun)
• (literally) An enclosed structure where bicycles
may be stored.
• (figuratively, technical jargon) A topic that is
attracting debate ad nauseam, out of all proportion
to its actual importance. Also bikeshedding, the
process of futile investment of time and energy in
discussion of marginal technical issues.
Globalcode – Open4education
Globalcode – Open4education
Did I hear API?
Globalcode – Open4education
Did I hear API?
Globalcode – Open4education
JSON API
• O que ele define?
Just kidding!
Globalcode – Open4education
• Como um cliente deve consultar, criar e/ou modificar
recursos.
• Verbos
• Formato da URL/Filtros
• Paginação
• +
• Como o servidor deve responder a estas requisições.
• Estrutura de resposta
• Status Code
• +
JSON API
• O que ele define?
Globalcode – Open4education
HTTP/1.1 200 OK
Content-Type: application/vnd.api+json
{
"data": [{
"type": "articles",
"id": "1",
"attributes": {
"title": "JSON API paints my bikeshed!",
"body": "The shortest article. Ever.",
"created": "2015-05-22T14:56:29.000Z",
"updated": "2015-05-22T14:56:28.000Z"
},
"relationships": {
"author": {
"data": {"id": "42", "type": "people"}
}
}
}],
"included": [
{
"type": "people",
"id": "42",
"attributes": {
"name": "John",
"age": 80,
"gender": "male"
}
}
]
}
GET /articles?include=author HTTP/1.1
Globalcode – Open4education
HTTP/1.1 200 OK
Content-Type: application/vnd.api+json
{
"meta": {
"total-pages": 13
},
"data": [
{
"type": "articles",
"id": "3",
"attributes": {
"title": "JSON API paints my bikeshed!",
"body": "The shortest article. Ever.",
"created": "2015-05-22T14:56:29.000Z",
"updated": "2015-05-22T14:56:28.000Z"
}
}
],
"links": {
"self": "http://example.com/articles?page[number]=3&page[size]=1",
"first": "http://example.com/articles?page[number]=1&page[size]=1",
"prev": "http://example.com/articles?page[number]=2&page[size]=1",
"next": "http://example.com/articles?page[number]=4&page[size]=1",
"last": "http://example.com/articles?page[number]=13&page[size]=1"
}
}
GET /articles?page[number]=3&page[size]=1 HTTP/1.1
Globalcode – Open4education
HTTP/1.1 422 Unprocessable Entity
Content-Type: application/vnd.api+json
{
"errors": [
{
"status": "422",
"source": { "pointer": "/data/attributes/first-name" },
"title": "Invalid Attribute",
"detail": "First name must contain at least three characters."
}
]
}
Globalcode – Open4education
JSON API
• Implementação
Globalcode – Open4education
• Client libraries
• JavaScript, iOS, Ruby, PHP, Dart, Perl, Java, Android, R, Elm, .NET
• Server libraries
• PHP, Node.js, Ruby, Python, Go, .NET, Java, Scala, Elixir, Haskell,
Perl, Vala
JSON API
• Implementação - jsonapi.org/implementations
Globalcode – Open4education
Resumão
• Calma! Ajuste uma parte de cada vez
• JSON API não é “lei”, existem outros padrões:
HAL, Siren, JSON-LD, Collection+JSON, etc
• Adote padrões, eles facilitam nossa vida :)
Globalcode – Open4education
Dúvidas?
jsonapi.org
pecavalheiro.com
OBRIGADO!

More Related Content

PDF
It is easy contributing to Open Source - ECLIPSE CON 2020
PDF
Code decoupling from Symfony (and others frameworks) - PHP Conference Brasil ...
PPTX
TDC 2016 SP - Testes em API REST
PPTX
SPS Québec - Votre intranet "Client-Side" en SharePoint Online/O365 avec PnP,...
PDF
Cross Site Publishing Solution for corporate news in SP 2013
PPTX
Integrating SharePoint with Exchange-2013
PPTX
Gouvernance des projets SharePoint 2013
PDF
Exchange Server 2013 and SharePoint Server 2013 Integration
It is easy contributing to Open Source - ECLIPSE CON 2020
Code decoupling from Symfony (and others frameworks) - PHP Conference Brasil ...
TDC 2016 SP - Testes em API REST
SPS Québec - Votre intranet "Client-Side" en SharePoint Online/O365 avec PnP,...
Cross Site Publishing Solution for corporate news in SP 2013
Integrating SharePoint with Exchange-2013
Gouvernance des projets SharePoint 2013
Exchange Server 2013 and SharePoint Server 2013 Integration

Viewers also liked (20)

PDF
Backup & Restore SharePoint 2013 Farm
PDF
TDC 2016 SP - 5 libs de teste JavaScript que você deveria conhecer
PPTX
Chris O'Brien - Customizing the SharePoint/Office 365 UI with JavaScript (ESP...
PDF
Cool Dashboards and Visualizations for SharePoint Power Users
PPTX
2013 SPFest - Customizing Sites and Pages in SharePoint 2013
PDF
Les 10 strategies d'adoption de SharePoint 2013
PDF
inext café #03 - Automatiser ses processus métier avec SharePoint et Nintex
PPTX
Presentation Backup & Restore SharePoint 2013 Farm
PDF
Build Killer Visuals with SharePoint 2013 Search & Display Templates
PDF
TDC2016POA | Trilha Web - Garanta a segurança de suas aplicações Web com Keyc...
PDF
TDC2016POA | Trilha Web - A essência do CSS
PDF
Agilizando o desenvolvimento web com SASS
PDF
Levando seu app do iOS para o macOS
PPTX
Transform SharePoint default list forms with HTML, CSS and JavaScript
PDF
TDC 2016 - Sass: CSS com super-poderes.
PDF
TDC 2016 - Garantindo a qualidade da sua infraestrutura
PPTX
The A to Z of Building a Responsive SharePoint Site with Bootstrap
PPTX
TDC POA 2016 - Robotium + Cucumber + Gradle, misture com spoon e tenha uma ex...
PDF
Como ensinei mais de 1000 testadores
PDF
TDC2016POA | Trilha Web - Realtime applications com Socket.io
Backup & Restore SharePoint 2013 Farm
TDC 2016 SP - 5 libs de teste JavaScript que você deveria conhecer
Chris O'Brien - Customizing the SharePoint/Office 365 UI with JavaScript (ESP...
Cool Dashboards and Visualizations for SharePoint Power Users
2013 SPFest - Customizing Sites and Pages in SharePoint 2013
Les 10 strategies d'adoption de SharePoint 2013
inext café #03 - Automatiser ses processus métier avec SharePoint et Nintex
Presentation Backup & Restore SharePoint 2013 Farm
Build Killer Visuals with SharePoint 2013 Search & Display Templates
TDC2016POA | Trilha Web - Garanta a segurança de suas aplicações Web com Keyc...
TDC2016POA | Trilha Web - A essência do CSS
Agilizando o desenvolvimento web com SASS
Levando seu app do iOS para o macOS
Transform SharePoint default list forms with HTML, CSS and JavaScript
TDC 2016 - Sass: CSS com super-poderes.
TDC 2016 - Garantindo a qualidade da sua infraestrutura
The A to Z of Building a Responsive SharePoint Site with Bootstrap
TDC POA 2016 - Robotium + Cucumber + Gradle, misture com spoon e tenha uma ex...
Como ensinei mais de 1000 testadores
TDC2016POA | Trilha Web - Realtime applications com Socket.io
Ad

Similar to TDC2016POA | Trilha Web - JSON API: não reinvente a roda (20)

PDF
JSON API: Não reinvente a roda
PDF
Building RESTful APIs
PDF
JSON REST API for WordPress
PDF
The liferay case: lessons learned evolving from RPC to Hypermedia REST APIs
PPTX
曾勇 Elastic search-intro
PPTX
Austin Day of Rest - Introduction
PDF
JSON REST API for WordPress
PPT
Introduction to PHP - SDPHP
PDF
Generating Unified APIs with Protocol Buffers and gRPC
PPTX
Elastic search intro-@lamper
PDF
Developing Brilliant and Powerful APIs in Ruby & Python
PDF
Building APIs in an easy way using API Platform
PDF
Champaign-Urbana Javascript Meetup Talk (Jan 2020)
PDF
Unlock dependency between client teams and API team with API mock and proxy
PDF
API Design in the Modern Era - Architecture Next 2020
PDF
Eran Stiller: API design in the modern era - architecture next 2020
PPTX
Crafting Evolvable Api Responses
PPTX
How to get along with HATEOAS without letting the bad guys steal your lunch -...
PDF
web2py:Web development like a boss
PPTX
Survival Strategies for API Documentation: Presentation to Southwestern Ontar...
JSON API: Não reinvente a roda
Building RESTful APIs
JSON REST API for WordPress
The liferay case: lessons learned evolving from RPC to Hypermedia REST APIs
曾勇 Elastic search-intro
Austin Day of Rest - Introduction
JSON REST API for WordPress
Introduction to PHP - SDPHP
Generating Unified APIs with Protocol Buffers and gRPC
Elastic search intro-@lamper
Developing Brilliant and Powerful APIs in Ruby & Python
Building APIs in an easy way using API Platform
Champaign-Urbana Javascript Meetup Talk (Jan 2020)
Unlock dependency between client teams and API team with API mock and proxy
API Design in the Modern Era - Architecture Next 2020
Eran Stiller: API design in the modern era - architecture next 2020
Crafting Evolvable Api Responses
How to get along with HATEOAS without letting the bad guys steal your lunch -...
web2py:Web development like a boss
Survival Strategies for API Documentation: Presentation to Southwestern Ontar...
Ad

More from tdc-globalcode (20)

PDF
TDC2019 Intel Software Day - Visao Computacional e IA a servico da humanidade
PDF
TDC2019 Intel Software Day - Tecnicas de Programacao Paralela em Machine Lear...
PDF
TDC2019 Intel Software Day - ACATE - Cases de Sucesso
PDF
TDC2019 Intel Software Day - Otimizacao grafica com o Intel GPA
PDF
TDC2019 Intel Software Day - Deteccao de objetos em tempo real com OpenVino
PDF
TDC2019 Intel Software Day - OpenCV: Inteligencia artificial e Visao Computac...
PDF
TDC2019 Intel Software Day - Inferencia de IA em edge devices
PDF
Trilha BigData - Banco de Dados Orientado a Grafos na Seguranca Publica
PPT
Trilha .Net - Programacao funcional usando f#
PDF
TDC2018SP | Trilha Go - Case Easylocus
PDF
TDC2018SP | Trilha Modern Web - Para onde caminha a Web?
PDF
TDC2018SP | Trilha Go - Clean architecture em Golang
PDF
TDC2018SP | Trilha Go - "Go" tambem e linguagem de QA
PDF
TDC2018SP | Trilha Mobile - Digital Wallets - Seguranca, inovacao e tendencia
PDF
TDC2018SP | Trilha .Net - Real Time apps com Azure SignalR Service
PDF
TDC2018SP | Trilha .Net - Passado, Presente e Futuro do .NET
PDF
TDC2018SP | Trilha .Net - Novidades do C# 7 e 8
PDF
TDC2018SP | Trilha .Net - Obtendo metricas com TDD utilizando build automatiz...
PDF
TDC2018SP | Trilha .Net - .NET funcional com F#
PDF
TDC2018SP | Trilha .Net - Crie SPAs com Razor e C# usando Blazor em .Net Core
TDC2019 Intel Software Day - Visao Computacional e IA a servico da humanidade
TDC2019 Intel Software Day - Tecnicas de Programacao Paralela em Machine Lear...
TDC2019 Intel Software Day - ACATE - Cases de Sucesso
TDC2019 Intel Software Day - Otimizacao grafica com o Intel GPA
TDC2019 Intel Software Day - Deteccao de objetos em tempo real com OpenVino
TDC2019 Intel Software Day - OpenCV: Inteligencia artificial e Visao Computac...
TDC2019 Intel Software Day - Inferencia de IA em edge devices
Trilha BigData - Banco de Dados Orientado a Grafos na Seguranca Publica
Trilha .Net - Programacao funcional usando f#
TDC2018SP | Trilha Go - Case Easylocus
TDC2018SP | Trilha Modern Web - Para onde caminha a Web?
TDC2018SP | Trilha Go - Clean architecture em Golang
TDC2018SP | Trilha Go - "Go" tambem e linguagem de QA
TDC2018SP | Trilha Mobile - Digital Wallets - Seguranca, inovacao e tendencia
TDC2018SP | Trilha .Net - Real Time apps com Azure SignalR Service
TDC2018SP | Trilha .Net - Passado, Presente e Futuro do .NET
TDC2018SP | Trilha .Net - Novidades do C# 7 e 8
TDC2018SP | Trilha .Net - Obtendo metricas com TDD utilizando build automatiz...
TDC2018SP | Trilha .Net - .NET funcional com F#
TDC2018SP | Trilha .Net - Crie SPAs com Razor e C# usando Blazor em .Net Core

Recently uploaded (20)

PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
Sports Quiz easy sports quiz sports quiz
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Complications of Minimal Access Surgery at WLH
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
Pharma ospi slides which help in ospi learning
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
Basic Mud Logging Guide for educational purpose
PPTX
Cell Structure & Organelles in detailed.
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Pharmacology of Heart Failure /Pharmacotherapy of CHF
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Sports Quiz easy sports quiz sports quiz
2.FourierTransform-ShortQuestionswithAnswers.pdf
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
102 student loan defaulters named and shamed – Is someone you know on the list?
Module 4: Burden of Disease Tutorial Slides S2 2025
Complications of Minimal Access Surgery at WLH
STATICS OF THE RIGID BODIES Hibbelers.pdf
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Pharma ospi slides which help in ospi learning
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Supply Chain Operations Speaking Notes -ICLT Program
O5-L3 Freight Transport Ops (International) V1.pdf
FourierSeries-QuestionsWithAnswers(Part-A).pdf
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Basic Mud Logging Guide for educational purpose
Cell Structure & Organelles in detailed.

TDC2016POA | Trilha Web - JSON API: não reinvente a roda

  • 1. Globalcode – Open4education JSON API: não reinvente a roda Pedro Cavalheiro Trilha Web
  • 2. Globalcode – Open4education Pedro Cavalheiro Desenvolvedor web há 6 anos, em sua maioria trabalhando com Ruby e PHP. Entusiasta por tecnologia como um todo, adora estudar novas ferramentas, linguagens e metodologias. Atualmente no Me Salva!. Infos em pecavalheiro.com
  • 4. Globalcode – Open4education API • Application Programming Interface • Web Services (HTTP) • SOAP • REST • JSON
  • 5. Globalcode – Open4education REST API • O que é importante? • Segurança/Autenticação • Documentação • Requisitos/Complexidade • Design de requisições/respostas • +
  • 7. Globalcode – Open4education bikeshed (noun) • (literally) An enclosed structure where bicycles may be stored. • (figuratively, technical jargon) A topic that is attracting debate ad nauseam, out of all proportion to its actual importance. Also bikeshedding, the process of futile investment of time and energy in discussion of marginal technical issues.
  • 11. Globalcode – Open4education JSON API • O que ele define? Just kidding!
  • 12. Globalcode – Open4education • Como um cliente deve consultar, criar e/ou modificar recursos. • Verbos • Formato da URL/Filtros • Paginação • + • Como o servidor deve responder a estas requisições. • Estrutura de resposta • Status Code • + JSON API • O que ele define?
  • 13. Globalcode – Open4education HTTP/1.1 200 OK Content-Type: application/vnd.api+json { "data": [{ "type": "articles", "id": "1", "attributes": { "title": "JSON API paints my bikeshed!", "body": "The shortest article. Ever.", "created": "2015-05-22T14:56:29.000Z", "updated": "2015-05-22T14:56:28.000Z" }, "relationships": { "author": { "data": {"id": "42", "type": "people"} } } }], "included": [ { "type": "people", "id": "42", "attributes": { "name": "John", "age": 80, "gender": "male" } } ] } GET /articles?include=author HTTP/1.1
  • 14. Globalcode – Open4education HTTP/1.1 200 OK Content-Type: application/vnd.api+json { "meta": { "total-pages": 13 }, "data": [ { "type": "articles", "id": "3", "attributes": { "title": "JSON API paints my bikeshed!", "body": "The shortest article. Ever.", "created": "2015-05-22T14:56:29.000Z", "updated": "2015-05-22T14:56:28.000Z" } } ], "links": { "self": "http://example.com/articles?page[number]=3&page[size]=1", "first": "http://example.com/articles?page[number]=1&page[size]=1", "prev": "http://example.com/articles?page[number]=2&page[size]=1", "next": "http://example.com/articles?page[number]=4&page[size]=1", "last": "http://example.com/articles?page[number]=13&page[size]=1" } } GET /articles?page[number]=3&page[size]=1 HTTP/1.1
  • 15. Globalcode – Open4education HTTP/1.1 422 Unprocessable Entity Content-Type: application/vnd.api+json { "errors": [ { "status": "422", "source": { "pointer": "/data/attributes/first-name" }, "title": "Invalid Attribute", "detail": "First name must contain at least three characters." } ] }
  • 16. Globalcode – Open4education JSON API • Implementação
  • 17. Globalcode – Open4education • Client libraries • JavaScript, iOS, Ruby, PHP, Dart, Perl, Java, Android, R, Elm, .NET • Server libraries • PHP, Node.js, Ruby, Python, Go, .NET, Java, Scala, Elixir, Haskell, Perl, Vala JSON API • Implementação - jsonapi.org/implementations
  • 18. Globalcode – Open4education Resumão • Calma! Ajuste uma parte de cada vez • JSON API não é “lei”, existem outros padrões: HAL, Siren, JSON-LD, Collection+JSON, etc • Adote padrões, eles facilitam nossa vida :)