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
RESTful API @ Front-End Developers Taiwan 2014-...
Search
Poga Po
April 24, 2014
Programming
3
150
RESTful API @ Front-End Developers Taiwan 2014-04-23
Poga Po
April 24, 2014
Tweet
Share
More Decks by Poga Po
See All by Poga Po
Spacer - iThome Serverless All-Star
poga
2
260
civic-notebook
poga
0
97
Fuzz Testing and go-fuzz
poga
0
330
everything is log
poga
12
1.8k
g0v intro
poga
0
86
新聞產生器
poga
0
610
Dependency Management in Go
poga
4
610
Redis: based on real story
poga
16
1.3k
Other Decks in Programming
See All in Programming
CQRS/ESのクラスとシステムフロー ~ RailsでフルスクラッチでCQRSESを組んで みたことから得た学び~
suzukimar
0
190
RubyKaigiで得られる10の価値 〜Ruby話を聞くことだけが RubyKaigiじゃない〜
tomohiko9090
0
100
RubyKaigi Hack Space in Tokyo & 函館最速 "予習" 会 / RubyKaigi Hack Space in Tokyo & The Fastest Briefing of RubyKaigi 2026 in Hakodate
moznion
1
120
PT AI без купюр
v0lka
0
200
primeNumberでのRBS導入の現在 && RBS::Traceでinline RBSを拡充してみた
mnmandahalf
0
250
Javaに鉄道指向プログラミング (Railway Oriented Pro gramming) のエッセンスを取り入れる/Bringing the Essence of Railway-Oriented Programming to Java
cocet33000
1
100
【TSkaigi 2025】これは型破り?型安全? 真実はいつもひとつ!(じゃないかもしれない)TypeScript クイズ〜〜〜〜!!!!!
kimitashoichi
1
300
漸進。
ssssota
0
1.2k
DevTalks 25 - Create your own AI-infused Java apps with ease
kdubois
2
120
少数精鋭エンジニアがフルスタック力を磨く理由 -そしてAI時代へ-
rebase_engineering
0
130
Devinで実践する!AIエージェントと協働する開発組織の作り方
masahiro_nishimi
6
2.6k
List Unfolding - 'unfold' as the Computational Dual of 'fold', and how 'unfold' relates to 'iterate'"
philipschwarz
PRO
0
130
Featured
See All Featured
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.5k
Rails Girls Zürich Keynote
gr2m
94
13k
Six Lessons from altMBA
skipperchong
28
3.8k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
48
5.4k
Stop Working from a Prison Cell
hatefulcrawdad
269
20k
The Cost Of JavaScript in 2023
addyosmani
49
8.1k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
Testing 201, or: Great Expectations
jmmastey
42
7.5k
Rebuilding a faster, lazier Slack
samanthasiow
81
9k
Writing Fast Ruby
sferik
628
61k
YesSQL, Process and Tooling at Scale
rocio
172
14k
Building Applications with DynamoDB
mza
95
6.4k
Transcript
REST Open Data, URI, and REST API @devpoga Front-End Developers
Taiwan 2014.04.23
@devpoga
REpresentational State Transfer • Resource and Representation • Manipulation through
Representation • Self-Descriptive • Links between Resources
先別管 REST API 了 ! 你有聽過 鄉⺠民 OCR 嗎
陽光法案 • 陽光法案 • 公職⼈人員財產申報法 • 政治獻⾦金法 • 遊說法 •
… • 2005 年
政治獻金數位化 • 《政治獻⾦金會計報告書查閱收費標準》 • 可以前往監察院查閱會計報告 • …需要事前預約 • …查詢⼀一個專⼾戶 20
元 • …不能以電⼦子檔格式攜出 • …影印⼀一張 2 元
反核四五六運動++
ronnywang++
鄉民 OCR
cells.1100.json
Let’s make a REST API
1. Thinking in Resources 2. HTTP Verb 3. Links between
Resources
Resource • 提供的資料名稱 • 政治獻⾦金表
gov.tw/campaign-finances/ /政府/政治獻⾦金/ { 8: {“張慶忠”: […]}, {“林鴻池”:[…]},…], 7: […], …}
Resource
gov.tw/campaign-finances/張慶忠/ /政府/政治獻⾦金/張慶忠/ [ { ⽇日期 :”100/12/03”, 捐贈者:”匿名”, 種類 :”個⼈人捐贈收⼊入”, ⾦金額
:12345 }, { … }, …] Resource Entry
gov.tw/legislators/ /政府/⽴立法委員/ { 8: { KMT: [“張慶忠”, “林鴻池”,…] }, {
DPP: […] }, … } Resource
gov.tw/legislators/張慶忠/ /政府/⽴立法委員/張慶忠/ { 姓名: “張慶忠” 黨籍: “KMT”, 選區: “新北市”, 參與院會紀錄:
{…}, 聯絡⽅方式: { TEL: ‘…’, 地址: ‘…’ }, 經歷: [ … ] } Resource Entry
gov.tw/財產申報紀錄/張慶忠/ /政府/財產申報紀錄/張慶忠/ { 股票⾯面額總額: “兩億多很多”, ⼟土地持有總⾯面積: “8245.5坪”, … } Resource
Entry
gov.tw/投票紀錄/張慶忠/ /政府/投票紀錄/張慶忠/ { 沒有投票: 7, 贊成: 79, 反對: 271, 紀錄:
[ { 表決內容: 交通資訊雲端blahblah, 個⼈人投票: 贊成, 表決結果: 通過, ⽇日期: 2014-01-27 }, … ] } Resource Entry
蔡正元:「我違反黨紀第三名」
gov.tw/脫黨表決紀錄/蔡正元/ /政府/脫黨表決紀錄/蔡正元/ { 脫黨投票紀錄: [] } Resource Entry
gov.tw/legislators gov.tw/legislators/張慶忠/ gov.tw/campaign-fianaces/ gov.tw/campaign-fianaces/林鴻池
gov.tw/legislators gov.tw/legislators/張慶忠/ gov.tw/campaign-fianaces/ gov.tw/campaign-fianaces/林鴻池 http:// http:// http:// http://
None
None
Q?
1. Thinking in Resources 2. HTTP Verb 3. Links between
Resources
gov.tw/legislators gov.tw/legislators/張慶忠/ gov.tw/campaign-fianaces/ gov.tw/campaign-fianaces/林鴻池 http:// http:// http:// http://
Create Read Update Delete
Create Read Update Delete gov.tw/legislators/張慶忠/
Create Read Update Delete POST GET PUT DELETE HTTP Verb
POST GET PUT DELETE gov.tw/legislators/張慶忠/
POST GET PUT DELETE gov.tw/legislators/張慶忠/ gov.tw/legislators/張慶忠/ gov.tw/legislators/張慶忠/ gov.tw/legislators/
Z > B • 設計好 URL,新增/修改/刪除的介⾯面也⾃自動定義好了 • 更新介⾯面⼀一致 • http://gov.tw/create_legislator.php?name=…
• http://gov.tw/legislator_delete.php?name=…
Q?
1. Thinking in Resources 2. HTTP Verb 3. Links between
Resources
gov.tw/legislators/張慶忠/ { 姓名: “張慶忠” 黨籍: “KMT”, 選區: “新北市”, 參與院會紀錄: {…},
聯絡⽅方式: { TEL: ‘…’, 地址: ‘…’ }, 經歷: [ … ] } 投票紀錄? 財產紀錄? 選舉得票紀錄? GET
超連結
gov.tw/legislators/張慶忠/ { 姓名: “張慶忠” 黨籍: “KMT”, 選區: “新北市”, 參與院會紀錄: {…},
聯絡⽅方式: { TEL: ‘…’, 地址: ‘…’ }, 經歷: [ … ], 投票紀錄: “/投票紀錄/張慶忠/”, 財產紀錄: “/財產紀錄/張慶忠/” }
HATEOAS • Hypermedia as the Engine of Application State •
直接在 Representation 中建⽴立 Resource 之間的連 結,⽽而不是透過外部⽂文件 • Decoupling Server and Client.
gov.tw/legislators/張慶忠/ { 姓名: “張慶忠” 黨籍: “KMT”, 選區: “新北市”, 參與院會紀錄: {…},
聯絡⽅方式: { TEL: ‘…’, 地址: ‘…’ }, 經歷: [ … ], 投票紀錄: “/投票紀錄/張慶忠/”, 財產紀錄: “/財產紀錄/張慶忠/”, 罷免: “/recalls/張慶忠” }
RESTful • 從資源的⾓角度思考 • 套上 HTTP Verb 就有標準的操作介⾯面 • 透過
link 建⽴立資料間的關聯 RECAP
Q?
PgREST Javascript and REST API in your DB http://pgre.st
PgREST is… • … a JSON document store • …
running inside PostgreSQL • … working with existing relational data • … capable of loading Node.js modules • … compatible with MongoLab’s REST API • … compatible with Firebase API (new)
From Data… 姓名 電話 黨籍 0 張慶忠 02-123-4567 KMT 1
林鴻池 02-123-4567 KMT 2 ⺩王⾦金平 02-123-4567 KMT 3 柯建銘 02-123-4567 DPP Table: legislators
… to REST API http://localhost:3000/collections/legislators [ { id: 0, 姓名:
柯建銘 … }, { … }, … ] > pgrest —db mydb
… with query http://localhost:3000/collections/legislators?q={id:0} … RESTful http://localhost:3000/collections/legislators GET POST PUT
DELETE
http://pgre.st
Thank you!