Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
API Design
Search
azisaka
March 04, 2013
Technology
190
7
Share
API Design
A keynote made for Papaya Ventures explaining the main points when developing an API.
azisaka
March 04, 2013
More Decks by azisaka
See All by azisaka
SASS for fun and profit
azisaka
3
150
Omniauth - Basic and principles
azisaka
1
83
Other Decks in Technology
See All in Technology
名刺メーカーDevグループ 紹介資料
sansan33
PRO
0
1.1k
NOSTR, réseau social et espace de liberté décentralisé
rlifchitz
0
200
非エンジニア職からZOZOへ 〜登壇がキャリアに与えた影響〜
penpeen
0
500
Do Ruby::Box dream of Modular Monolith?
joker1007
1
300
AIペネトレーションテスト・ セキュリティ検証「AgenticSec」ご紹介資料
laysakura
0
3.9k
ハーネスエンジニアリングをやりすぎた話 ~そのハーネスは解体された~
gotalab555
0
390
生成AI時代のエンジニア育成 変わる時代と変わらないコト
starfish719
0
9k
Claude Code を安全に使おう勉強会 / Claude Code Security Basics
masahirokawahara
2
14k
システムは「動く」だけでは足りない 実装編 - 非機能要件・分散システム・トレードオフをコードで見る
nwiizo
4
410
ARIA Notifyについて
ryokatsuse
1
120
新メンバーのために、シニアエンジニアが環境を作る時代
puku0x
0
1.1k
Introduction to Sansan Meishi Maker Development Engineer
sansan33
PRO
0
390
Featured
See All Featured
Mind Mapping
helmedeiros
PRO
1
150
Designing Powerful Visuals for Engaging Learning
tmiket
1
340
How to Think Like a Performance Engineer
csswizardry
28
2.5k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
240
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
0
270
VelocityConf: Rendering Performance Case Studies
addyosmani
333
25k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
810
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
770
Color Theory Basics | Prateek | Gurzu
gurzu
0
290
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.3k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
130
The Spectacular Lies of Maps
axbom
PRO
1
690
Transcript
por que você deveria se importar? API design
Como enviar dados para a nuvem?
API Application Programming Interface Fácil de usar Rápida Leve JSON
Construindo uma API
Representational State Transfer REST
Arquitetura DISTRIBUÍDA
Representação de Entidades /posts/1.json /posts/1/comments.json /posts/1/likes.json
HTTP METHOD ACTION VERBO SUBSTANTIVO GET DELETE POST PUT /posts
/posts /posts/1 /posts/1
USE Substantivos ao inves de verbos
verbos criam uma API prolixa GET /listarPosts.json POST /criarPost.json GET
/visualizarPost.json?id=1
Se aproveite dos HTTP methods GET /posts.json POST /posts.json GET
/posts/1.json PUT /posts/1.json DELETE /posts/1.json
Sempre plural, nunca singular
ENdpoints no plural são intuitivos GET /posts GET /posts/1 PUT
/posts/1 POST /posts
Substantivos concretos, nunca abstratos
Endpoints devem ter significado GET /items GET /products GET /users
GET /assets Ruim Bom
RELACIONE RECURSOS DE FORMA SIMPLES
Endpoints auto-explicativos Foto Likes POST /photos/1/likes Categoria Estabelecimentos GET /categories/restaurant/venues
Coloque a complexidade DEPOIS da “?”
filtros e buscas GET /posts?status=draft GET /posts/1/comments?user_id=1 GET /posts?q=something
Resultados devem ser paginados
Indiquem onde o resultado está GET /posts { “posts”: [
{ “id”: 1, title: “Post #1” }, { “id”: 2, title: “Post #2” } ], “page”: 1, “total”: 10, “perPage”: 2 } GET /posts?page=2&perPage=1 { “posts”: [ { “id”: 3, title: “Post #3” }, ], “page”: 2, “total”: 10, “perPage”: 1 }
Retorne dados parcialmente
Reduza o payload GET /posts/1 { “post”: { “id”: 1,
“title”: “Post #1”, “body”: “Post’s body”, “tags”: [“api”, “web”, “http”], “category”: { “name”: “Development” } } } GET /posts/1?fields=id,title { “post”: { “id”: 1, “title”: “Post #1” } }
Retorne erros com significado
Seja claro! POST /posts { “status”: 400, “message”: “O título
não pode ficar em branco” }
Versione sua API
E mantenha ao menos 1 versão GET /v1/posts/1 GET /v2/posts/1
{ “post”: { “id”: 1, “title”: “Post #1”, “content”: “Post’s body” } } } { “post”: { “id”: 1, “title”: “Post #1”, “body”: “Post’s body” } } }
Use um subdomínio
api.seuprojeto.com Escalabilidade independente Controle de cache e CDN independente Organização
Wrap up
APIs podem fazer a diferença durante o desenvolvimento Cuidado com
o Design
A mesma API pode ser core de aplicativos iPhone, Android,
Web e Desktop Colha os frutos
Outros aplicativos podem aumentar o valor do seu produto expandindo
o seu uso Aumente seu evaluation
O caso “Instragram”
None
None
None
None
None
Obrigado :)