HTTP APIs as first class procedures in your language: cutting out SDK complexity.
-
Upload
programmableweb -
Category
Technology
-
view
171 -
download
0
description
Transcript of HTTP APIs as first class procedures in your language: cutting out SDK complexity.
APIconUK 2014 2 / 1492014/09/24
[email protected]@databasescaling
HTTP APIs As First Class Procedures
Thursday, 25th September 2014
APIconUK 2014 3 / 1492014/09/24
HTTP APIs As First Class Procedures
[email protected]@databasescaling
Cutting out SDK Complexity
Thursday, 25th September 2014
APIconUK 2014 4 / 1492014/09/24
andyjpb
http://www.obsoletecomputermuseum.org/oliv_m24/m24.jpg
APIconUK 2014 5 / 1492014/09/24
GSM AT Command Set
cmd AT+CREG "Network Registration (ver.2)" set AT+CREG=[<creg_stat>],<creg_urc>,<ci> read AT+CREG? +CREG:<creg_urc>,<creg_stat>[,<lac>,<ci>] test AT+CREG=? +CREG
APIconUK 2014 6 / 1492014/09/24
GSM AT Command Set
cmd AT+CREG "Network Registration (ver.2)" set AT+CREG=[<creg_stat>],<creg_urc>,<ci> read AT+CREG? +CREG:<creg_urc>,<creg_stat>[,<lac>,<ci>] test AT+CREG=? +CREG
APIconUK 2014 7 / 1492014/09/24
GSM AT Command Set
cmd AT+CREG "Network Registration (ver.2)" set AT+CREG=[<creg_stat>],<creg_urc>,<ci> read AT+CREG? +CREG:<creg_urc>,<creg_stat>[,<lac>,<ci>] test AT+CREG=? +CREG
APIconUK 2014 8 / 1492014/09/24
GSM AT Command Set
cmd AT+CREG "Network Registration (ver.2)" set AT+CREG=[<creg_stat>],<creg_urc>,<ci> read AT+CREG? +CREG:<creg_urc>,<creg_stat>[,<lac>,<ci>] test AT+CREG=? +CREG
APIconUK 2014 9 / 1492014/09/24
GSM AT Command Set
cmd AT+CREG "Network Registration (ver.2)" set AT+CREG=[<creg_stat>],<creg_urc>,<ci> read AT+CREG? +CREG:<creg_urc>,<creg_stat>[,<lac>,<ci>] test AT+CREG=? +CREG
APIconUK 2014 10 / 1492014/09/24
GSM AT Command Set
cmd AT+CREG "Network Registration (ver.2)" set AT+CREG=[<creg_stat>],<creg_urc>,<ci> read AT+CREG? +CREG:<creg_urc>,<creg_stat>[,<lac>,<ci>] test AT+CREG=? +CREG
int AT_CREG_test(int port, struct AT_result* result) { int r = 0;
if ((r = sendcmd(port, "AT+CREG=?", result))) return r; return recvresp(port, result);}
APIconUK 2014 11 / 1492014/09/24
Execution Tracing
DBrow *CursorNext(DB *env, DBcursor* cursor, DBresult* result) {
/* Increment the cursor to the next row in the direction * that the cursor is travelling and return the row to * the caller. */
...
}
APIconUK 2014 12 / 1492014/09/24
Execution Tracing
DBrow *CursorNext(DB *env, DBcursor* cursor, DBresult* result);
APIconUK 2014 13 / 1492014/09/24
Execution Tracing
DBrow *CursorNext(DB *env, DBcursor* cursor, DBresult* result);
APIconUK 2014 14 / 1492014/09/24
Execution Tracing
DBrow *CursorNext(DB *env, DBcursor* cursor, DBresult* result);
APIconUK 2014 15 / 1492014/09/24
Execution TracingDBrow *CursorNext(DB *env, DBcursor* cursor, DBresult* result) { DBrow *(*original_proc)(DB*, DBcursor*, DBresult*); DBrow *original_result;
log(“Entering CursorNext”); DB_serialise(env); Cursor_serialise(cursor); Result_serialise(result);
original_proc = dlsym(RTLD_NEXT, “CursorNext”); original_result = (*original_proc)(env, cursor, result);
DB_serialise(env); Cursor_serialise(cursor); Result_serialise(result);
Log(“Leaving CursorNext”);
return (original_result);}
APIconUK 2014 16 / 1492014/09/24
Execution TracingDBrow *CursorNext(DB *env, DBcursor* cursor, DBresult* result) { DBrow *(*original_proc)(DB*, DBcursor*, DBresult*); DBrow *original_result;
log(“Entering CursorNext”); DB_serialise(env); Cursor_serialise(cursor); Result_serialise(result);
original_proc = dlsym(RTLD_NEXT, “CursorNext”); original_result = (*original_proc)(env, cursor, result);
DB_serialise(env); Cursor_serialise(cursor); Result_serialise(result);
Log(“Leaving CursorNext”);
return (original_result);}
APIconUK 2014 17 / 1492014/09/24
Execution TracingDBrow *CursorNext(DB *env, DBcursor* cursor, DBresult* result) { DBrow *(*original_proc)(DB*, DBcursor*, DBresult*); DBrow *original_result;
log(“Entering CursorNext”); DB_serialise(env); Cursor_serialise(cursor); Result_serialise(result);
original_proc = dlsym(RTLD_NEXT, “CursorNext”); original_result = (*original_proc)(env, cursor, result);
DB_serialise(env); Cursor_serialise(cursor); Result_serialise(result);
Log(“Leaving CursorNext”);
return (original_result);}
APIconUK 2014 18 / 1492014/09/24
Execution TracingDBrow *CursorNext(DB *env, DBcursor* cursor, DBresult* result) { DBrow *(*original_proc)(DB*, DBcursor*, DBresult*); DBrow *original_result;
log(“Entering CursorNext”); DB_serialise(env); Cursor_serialise(cursor); Result_serialise(result);
original_proc = dlsym(RTLD_NEXT, “CursorNext”); original_result = (*original_proc)(env, cursor, result);
DB_serialise(env); Cursor_serialise(cursor); Result_serialise(result);
Log(“Leaving CursorNext”);
return (original_result);}
APIconUK 2014 19 / 1492014/09/24
Execution TracingDBrow *CursorNext(DB *env, DBcursor* cursor, DBresult* result) { DBrow *(*original_proc)(DB*, DBcursor*, DBresult*); DBrow *original_result;
log(“Entering CursorNext”); DB_serialise(env); Cursor_serialise(cursor); Result_serialise(result);
original_proc = dlsym(RTLD_NEXT, “CursorNext”); original_result = (*original_proc)(env, cursor, result);
DB_serialise(env); Cursor_serialise(cursor); Result_serialise(result);
Log(“Leaving CursorNext”);
return (original_result);}
APIconUK 2014 20 / 1492014/09/24
Knodium
APIconUK 2014 21 / 1492014/09/24
Knodium
APIconUK 2014 22 / 1492014/09/24
Knodium
APIconUK 2014 23 / 1492014/09/24
Knodium
APIconUK 2014 24 / 1492014/09/24
Knodium
APIconUK 2014 25 / 1492014/09/24
Knodium
APIconUK 2014 26 / 1492014/09/24
Knodium
APIconUK 2014 27 / 1492014/09/24
Knodium
APIconUK 2014 28 / 1492014/09/24
Knodium
APIconUK 2014 29 / 1492014/09/24
Knodium
APIconUK 2014 30 / 1492014/09/24
Knodium
APIconUK 2014 31 / 1492014/09/24
Knodium
APIconUK 2014 32 / 1492014/09/24
Knodium
APIconUK 2014 33 / 1492014/09/24
Knodium
APIconUK 2014 34 / 1492014/09/24
Knodium
APIconUK 2014 35 / 1492014/09/24
Knodium
APIconUK 2014 36 / 1492014/09/24
Knodium
APIconUK 2014 37 / 1492014/09/24
Knodium
APIconUK 2014 38 / 1492014/09/24
Knodium
APIconUK 2014 39 / 1492014/09/24
Knodium
APIconUK 2014 40 / 1492014/09/24
Knodium
APIconUK 2014 41 / 1492014/09/24
Knodium
APIconUK 2014 42 / 1492014/09/24
Scheme
APIconUK 2014 43 / 1492014/09/24
REST
Read the HTTP spec!
APIconUK 2014 44 / 1492014/09/24
REST
"Finally, I describe the lessons learned from applying REST to the design of the Hypertext Transfer Protocol and Uniform Resource
Identifier standards, and from their subsequent deployment in Web
client and server software."
-- Roy Fielding
APIconUK 2014 45 / 1492014/09/24
GETRetrieves a representation of the requested resource (current state)
POSTCreate a new instance of a resource
PUTUpdate an existing instance of a resource
DELETERemove an existing instance of a resource
REST
APIconUK 2014 46 / 1492014/09/24
http://static.squarespace.com/static/518f5d62e4b075248d6a3f90/t/51bb91f3e4b0405092e56e27/1371247103965/not-restful.jpg
APIconUK 2014 47 / 1492014/09/24
DCE
"The Distributed Computing Environment (DCE) is a software
system developed in the early 1990s"
APIconUK 2014 48 / 1492014/09/24
"This system allows programmers to write distributed software as if it were
all working on the same computer, without having to worry about the
underlying network code."
DCE/RPC
APIconUK 2014 49 / 1492014/09/24
"This system allows programmers to write distributed software as if it were
all working on the same computer, without having to worry about the
underlying network code."
DCE/RPC
APIconUK 2014 50 / 1492014/09/24
Adhoc Binding
“I'm looking for a pretty generic, fully featured REST client/API in
python. Not bare bones, but plush, nice to use.”
http://stackoverflow.com/questions/4355997/is-there-a-generic-python-library-to-consume-rest-based-services
APIconUK 2014 51 / 1492014/09/24
Adhoc Binding
“...an HTTP resource kit for Python. It allows you to easily access to HTTP resource and build objects around it.”
APIconUK 2014 52 / 1492014/09/24
Adhoc Binding
“...an HTTP resource kit for Python. It allows you to easily access to HTTP resource and build objects around it.”
“[It] is a full HTTP client using pure socket calls and its own HTTP parser.”
APIconUK 2014 53 / 1492014/09/24
Adhoc Binding
api = API('http://myrestful/api/v1')
# GET /resourceapi.resource.get()# GET /resource (with accept header = application/json)api.resource.get(format='json')# GET /resource?attr=valueapi.resource.get(attr=value)
# POST /resourceapi.resource.post(attr=value, attr2=value2, ...)# GET /resource/id/resource_collectionapi.resoure(id).resource_collection().get()
APIconUK 2014 54 / 1492014/09/24
Adhoc Binding
api = API('http://myrestful/api/v1')
# GET /resourceapi.resource.get()# GET /resource (with accept header = application/json)api.resource.get(format='json')# GET /resource?attr=valueapi.resource.get(attr=value)
# POST /resourceapi.resource.post(attr=value, attr2=value2, ...)# GET /resource/id/resource_collectionapi.resoure(id).resource_collection().get()
☺
APIconUK 2014 55 / 1492014/09/24
Adhoc Binding
api = API('http://myrestful/api/v1')
# GET /resourceapi.resource.get()# GET /resource (with accept header = application/json)api.resource.get(format='json')# GET /resource?attr=valueapi.resource.get(attr=value)
# POST /resourceapi.resource.post(attr=value, attr2=value2, ...)# GET /resource/id/resource_collectionapi.resoure(id).resource_collection().get()
☺
APIconUK 2014 56 / 1492014/09/24
Adhoc Binding
api = API('http://myrestful/api/v1')
# GET /resourceapi.resource.get()# GET /resource (with accept header = application/json)api.resource.get(format='json')# GET /resource?attr=valueapi.resource.get(attr=value)
# POST /resourceapi.resource.post(attr=value, attr2=value2, ...)# GET /resource/id/resource_collectionapi.resoure(id).resource_collection().get()
☺
☹
☹
APIconUK 2014 57 / 1492014/09/24
Adhoc Binding
api = API('http://myrestful/api/v1')
# GET /resourceapi.resource.get()# GET /resource (with accept header = application/json)api.resource.get(format='json')# GET /resource?attr=valueapi.resource.get(attr=value)
# POST /resourceapi.resource.post(attr=value, attr2=value2, ...)# GET /resource/id/resource_collectionapi.resoure(id).resource_collection().get()
☺
APIconUK 2014 58 / 1492014/09/24
Adhoc Binding
api = API('http://myrestful/api/v1')
# GET /resourceapi.resource.get()# GET /resource (with accept header = application/json)api.resource.get(format='json')# GET /resource?attr=valueapi.resource.get(attr=value)
# POST /resourceapi.resource.post(attr=value, attr2=value2, ...)# GET /resource/id/resource_collectionapi.resoure(id).resource_collection().get()
☺
☹
APIconUK 2014 59 / 1492014/09/24
SDKs
APIconUK 2014 60 / 1492014/09/24
SDKs
● HTTP Clients
APIconUK 2014 61 / 1492014/09/24
SDKs
● HTTP Clients● REST Clients
APIconUK 2014 62 / 1492014/09/24
SDKs
● HTTP Clients● REST Clients● Socket Pools
APIconUK 2014 63 / 1492014/09/24
SDKs
● HTTP Clients● REST Clients● Socket Pools● Request Builders
APIconUK 2014 64 / 1492014/09/24
SDKs
● HTTP Clients● REST Clients● Socket Pools● Request Builders● URI Concatenators
APIconUK 2014 65 / 1492014/09/24
SDKs
● HTTP Clients● REST Clients● Socket Pools● Request Builders● URI Concatenators● OAuth Implementations
APIconUK 2014 66 / 1492014/09/24
SDKs
APIconUK 2014 67 / 1492014/09/24
SDKs● PHP● Python● Ruby● .NET● Java● C, C++● Perl● Android, iOS, Windows Mobile, Blackberry● Javascript
APIconUK 2014 68 / 1492014/09/24
ctypes
https://docs.python.org/2/library/ctypes.html
APIconUK 2014 69 / 1492014/09/24
ctypes
>>> from ctypes import *>>> cdll.LoadLibrary("libc.so.6")<CDLL 'libc.so.6', handle 7f408bf8a000 at 21eb8d0>>>> libc = CDLL("libc.so.6")
>>> my_printf = libc.printf
>>> my_printf("Hello World")Hello World11
>>> my_printf("Hello %s", "Andy")Hello Andy10
APIconUK 2014 70 / 1492014/09/24
ctypes
>>> from ctypes import *>>> cdll.LoadLibrary("libc.so.6")<CDLL 'libc.so.6', handle 7f408bf8a000 at 21eb8d0>>>> libc = CDLL("libc.so.6")
>>> my_printf = libc.printf
>>> my_printf("Hello World")Hello World11
>>> my_printf("Hello %s", "Andy")Hello Andy10
APIconUK 2014 71 / 1492014/09/24
ctypes
>>> from ctypes import *>>> cdll.LoadLibrary("libc.so.6")<CDLL 'libc.so.6', handle 7f408bf8a000 at 21eb8d0>>>> libc = CDLL("libc.so.6")
>>> my_printf = libc.printf
>>> my_printf("Hello World")Hello World11
>>> my_printf("Hello %s", "Andy")Hello Andy10
APIconUK 2014 72 / 1492014/09/24
ctypes
>>> from ctypes import *>>> cdll.LoadLibrary("libc.so.6")<CDLL 'libc.so.6', handle 7f408bf8a000 at 21eb8d0>>>> libc = CDLL("libc.so.6")
>>> my_printf = libc.printf
>>> my_printf("Hello World")Hello World11
>>> my_printf("Hello %s", "Andy")Hello Andy10
APIconUK 2014 73 / 1492014/09/24
ctypes
● Code Loading● Calling Conventions● Marshalling● Memory Models
APIconUK 2014 74 / 1492014/09/24
● HTTP Implementation● HTTP Client● URI / URL Library● Media Format Libraries
APIconUK 2014 75 / 1492014/09/24
● HTTP Implementation● HTTP Client● URI / URL Library● Media Format Libraries
● A Way To Put It All Together
APIconUK 2014 76 / 1492014/09/24
Calling Conventions
https://api-content.dropbox.com/1/files/auto/<path>
APIconUK 2014 77 / 1492014/09/24
Calling Conventions
https://api-content.dropbox.com/1/files/auto/<path>
https://example.com/price/<date>/<€>/<£>
APIconUK 2014 78 / 1492014/09/24
Calling Conventions
https://api-content.dropbox.com/1/files/auto/<path>
https://example.com/price/<date>/<€>/<£>
APIconUK 2014 79 / 1492014/09/24
Calling Conventions
files(<path>)
price(<date>, <€>, <£>)
APIconUK 2014 80 / 1492014/09/24
Calling Conventions
https://example.com/trades?tick=<n>
https://api.dropbox.com/1/delta?cursor=<x>
APIconUK 2014 81 / 1492014/09/24
Calling Conventions
trades(tick=<n>)
delta(cursor=<x>)
APIconUK 2014 82 / 1492014/09/24
https://.../1/revisions/auto/<path>?rev_limit=<y>
Calling Conventions
https://example.com/trades/<stock>?tick=<y>
APIconUK 2014 83 / 1492014/09/24
revisions(<path>, rev_limit=<y>)
Calling Conventions
trades(<stock>, tick=<y>)
APIconUK 2014 84 / 1492014/09/24
Calling Conventions
(define (name pos-arg-1 pos-arg-2 #!key key-arg-1) … result)
APIconUK 2014 85 / 1492014/09/24
Calling Conventions
(define (add a b) (+ a b))
APIconUK 2014 86 / 1492014/09/24
Calling Conventions
(define (add a b) (+ a b))
(add 19 47)
APIconUK 2014 87 / 1492014/09/24
Calling Conventions
(define (add a b) (+ a b))
(add 19 47)
66
APIconUK 2014 88 / 1492014/09/24
Calling Conventions
(define (add a b) (+ a b))
(add 19 47)
66
(define (raise n #!key power) (expt n power))
APIconUK 2014 89 / 1492014/09/24
Calling Conventions
(define (add a b) (+ a b))
(add 19 47)
66
(define (raise n #!key power) (expt n power))
(raise 2 power: 4)
APIconUK 2014 90 / 1492014/09/24
Calling Conventions
(define (add a b) (+ a b))
(add 19 47)
66
(define (raise n #!key power) (expt n power))
(raise 2 power: 4)
16
APIconUK 2014 91 / 1492014/09/24
Putting It All Together
(use rest-bind)
(define-method
(procedure-name path-arg... #!key query-arg...)
uri-or-request
body-writer
body-reader
#!optional header-reader)
APIconUK 2014 92 / 1492014/09/24
Putting It All Together
(use rest-bind)
(define-method
(procedure-name path-arg... #!key query-arg...)
uri-or-request
body-writer
body-reader
#!optional header-reader)
APIconUK 2014 93 / 1492014/09/24
Putting It All Together
(use rest-bind)
(define-method
(procedure-name path-arg... #!key query-arg...)
uri-or-request
body-writer
body-reader
#!optional header-reader)
APIconUK 2014 94 / 1492014/09/24
Putting It All Together
(use rest-bind)
(define-method
(procedure-name path-arg... #!key query-arg...)
uri-or-request
body-writer
body-reader
#!optional header-reader)
APIconUK 2014 95 / 1492014/09/24
Putting It All Together
(use rest-bind)
(define-method
(procedure-name path-arg... #!key query-arg...)
uri-or-request
body-writer
body-reader
#!optional header-reader)
APIconUK 2014 96 / 1492014/09/24
Putting It All Together
(use rest-bind)
(define-method
(procedure-name path-arg... #!key query-arg...)
uri-or-request
body-writer
body-reader
#!optional header-reader)
APIconUK 2014 97 / 1492014/09/24
Putting It All Together
(use rest-bind)
(define-method
(procedure-name path-arg... #!key query-arg...)
uri-or-request
body-writer
body-reader
#!optional header-reader)
APIconUK 2014 98 / 1492014/09/24
Putting It All Together
(use rest-bind)
(define-method
(procedure-name path-arg... #!key query-arg...)
uri-or-request
body-writer
body-reader
#!optional header-reader)
APIconUK 2014 99 / 1492014/09/24
https://api.dropbox.com/1/account/info
Putting It All Together
APIconUK 2014 100 / 1492014/09/24
https://api.dropbox.com/1/account/info
Putting It All Together
(define-method (account/info #!key locale) "https://api.dropbox.com/1/account/info" #f read-json)
APIconUK 2014 101 / 1492014/09/24
https://api.dropbox.com/1/account/info
Putting It All Together
(define-method (account/info #!key locale) "https://api.dropbox.com/1/account/info" #f read-json)
#;> account/info#<procedure (? #!key locale)
APIconUK 2014 102 / 1492014/09/24
https://api.dropbox.com/1/account/info
Marshalling / Unmarshalling
(define-method (account/info #!key locale) "https://api.dropbox.com/1/account/info" #f read-json)
#;> account/info#<procedure (? #!key locale)
APIconUK 2014 103 / 1492014/09/24
https://api.dropbox.com/1/account/info
Marshalling / Unmarshalling
APIconUK 2014 104 / 1492014/09/24
https://api.dropbox.com/1/account/info
Marshalling / Unmarshalling
{ "referral_link": "https://www.dropbox.com/referrals/r1a2n3d4m5s6t7", "display_name": "John P. User", "uid": 12345678, "team": { "name": "Acme Inc." }, "country": "US", "quota_info": { "shared": 253738410565, "quota": 107374182400000, "normal": 680031877871 }}
APIconUK 2014 105 / 1492014/09/24
https://api.dropbox.com/1/account/info
Marshalling / Unmarshalling
((referral_link . "https://www.dropbox.com/referrals/r1a2n3d4m5s6t7") (display_name . "John P. User") (uid . 12345678) (country . "US") (quota_info (shared . 253738410565) (quota . 107374182400000) (normal . 680031877871)))
APIconUK 2014 106 / 1492014/09/24
Marshalling / Unmarshalling
(account/info)
APIconUK 2014 107 / 1492014/09/24
{ "referral_link": "https://www.dropbox.com/referrals/r1a2n3d4m5s6t7", "display_name": "John P. User", "uid": 12345678, "team": { "name": "Acme Inc." }, "country": "US", "quota_info": { "shared": 253738410565, "quota": 107374182400000, "normal": 680031877871 }}
Marshalling / Unmarshalling
(account/info)
read-string
APIconUK 2014 108 / 1492014/09/24
Marshalling / Unmarshalling
(account/info)
((referral_link . "https://www.dropbox.com/referrals/r1a2n3d4m5s6t7") (display_name . "John P. User") (uid . 12345678) (country . "US") (quota_info (shared . 253738410565) (quota . 107374182400000) (normal . 680031877871)))
read-json
APIconUK 2014 109 / 1492014/09/24
(define-method (trades stock #!key tick) "https://examples.com/trades")
#f read-json)
https://example.com/trades/<stock>?tick=<y>
Calling Conventions
APIconUK 2014 110 / 1492014/09/24
Calling Conventions
(use rest-bind)
(define-method
(procedure-name path-arg... #!key query-arg...)
uri-or-request
body-writer
body-reader
#!optional header-reader)
APIconUK 2014 111 / 1492014/09/24
Calling Conventions
(use rest-bind)
(define-method
(procedure-name path-arg... #!key query-arg...)
uri-or-request
body-writer
body-reader
#!optional header-reader)
APIconUK 2014 112 / 1492014/09/24
https://example.com/trades/<stock>?tick=<y>
Calling Conventions
(define-method (trades stock #!key tick) "https://examples.com/trades")
#f read-json)
APIconUK 2014 113 / 1492014/09/24
https://example.com/trades/<stock>?tick=<y>
Calling Conventions
(define-method (trades stock #!key tick) "https://examples.com/trades")
#f read-json)
APIconUK 2014 114 / 1492014/09/24
https://example.com/trades/<stock>?tick=<y>
Calling Conventions
(define-method (trades stock #!key tick) (make-request method: 'PUT uri: (uri-reference: "https://examples.com/trades") #f read-json)
APIconUK 2014 115 / 1492014/09/24
https://example.com/trades/<stock>?tick=<y>
Calling Conventions
(define-method (trades stock #!key tick) (make-request method: 'PUT uri: (uri-reference: "https://examples.com/trades") headers: '(accept #(application/json ((q . 0.5))))) #f read-json)
APIconUK 2014 116 / 1492014/09/24
Putting It All Together
(trades 'LON:TSCO tick: 3)
APIconUK 2014 117 / 1492014/09/24
Putting It All Together
(trades 'LON:TSCO tick: 3)
((1411602130 . 19490 1411602133 . +6 1411602136 . +1 1411602139 . -2 1411602142 . +3 1411602145 . +1 1411602148 . -2 1411602151 . -1 1411602154 . 0 1411602157 . +1))
APIconUK 2014 118 / 1492014/09/24
● HTTP Implementation● HTTP Client● URI / URL Library● Media Format Libraries
● A Way To Put It All Together
APIconUK 2014 119 / 1492014/09/24
● HTTP Implementation● HTTP Client● URI / URL Library● Media Format Libraries
● A Way To Put It All Together
APIconUK 2014 120 / 1492014/09/24
● HTTP Implementation● HTTP Client● URI / URL Library● Media Format Libraries
● A Way To Put It All Together
66 lines
APIconUK 2014 121 / 1492014/09/24
Putting It All Together(module dropbox-lolevel (dropbox make-dropbox-app account/info files:get files:put files:post metadata delta revisions restore search shares media copy-ref thumbnails chunked_upload commit_chunked_upload fileops/copy fileops/create_folder fileops/delete fileops/move callback old-output-port)
APIconUK 2014 122 / 1492014/09/24
oauth
Dropbox
APIconUK 2014 123 / 1492014/09/24
oauth
Dropbox
A User
APIconUK 2014 124 / 1492014/09/24
oauth
Dropbox
A User
Knodium
APIconUK 2014 125 / 1492014/09/24
oauth
Dropbox
A User
Knodium
APIconUK 2014 126 / 1492014/09/24
oauth
Dropbox
A User
Knodium
APIconUK 2014 127 / 1492014/09/24
oauth
Dropbox
A User
Knodium
APIconUK 2014 128 / 1492014/09/24
oauth
Dropbox
A User
Knodium
APIconUK 2014 129 / 1492014/09/24
oauth
Dropbox
A User
Knodium
APIconUK 2014 130 / 1492014/09/24
oauth
Dropbox
A User
Knodium
APIconUK 2014 131 / 1492014/09/24
oauth
Dropbox
A User
Knodium
APIconUK 2014 132 / 1492014/09/24
oauth
Dropbox
A User
Knodium
APIconUK 2014 133 / 1492014/09/24
oauth
Dropbox
A User
Knodium
APIconUK 2014 134 / 1492014/09/24
oauth
Dropbox
A User
Knodium
APIconUK 2014 135 / 1492014/09/24
oauth
Dropbox
A User
Knodium
APIconUK 2014 136 / 1492014/09/24
oauth
Dropbox
A User
Knodium
APIconUK 2014 137 / 1492014/09/24
oauth
(define dropbox (make-oauth-service-provider protocol-version: 1.0 credential-request-url: "https://api.dropbox.com/1/oauth/request_token" owner-auth-url: "https://www.dropbox.com/1/oauth/authorize" token-request-url: "https://api.dropbox.com/1/oauth/access_token" signature-method: 'plaintext))
(use oauth-client)
APIconUK 2014 138 / 1492014/09/24
(define dropbox-app (make-oauth-service service: dropbox client-credential: (make-oauth-credential "<token>" "<secret>")))
oauth
(use oauth-client)
APIconUK 2014 139 / 1492014/09/24
oauth
Dropbox
A User
Knodium
APIconUK 2014 140 / 1492014/09/24
Putting it all together
(with-oauth <app> <credential> ...)
APIconUK 2014 141 / 1492014/09/24
Putting it all together
(account/info)
APIconUK 2014 142 / 1492014/09/24
Putting it all together
(with-oauth <app> <credential> (account/info))
APIconUK 2014 143 / 1492014/09/24
Putting it all together
(account/info)
APIconUK 2014 144 / 1492014/09/24
Putting it all together
(account/info)
APIconUK 2014 145 / 1492014/09/24
Putting it all together
(account/info)
(display-name)
APIconUK 2014 146 / 1492014/09/24
Putting it all together
(account/info)
(display-name)
(web-page-logic)
APIconUK 2014 147 / 1492014/09/24
Putting it all together
(account/info)
(display-name)
(web-page-logic)
(request-routing)
APIconUK 2014 148 / 1492014/09/24
Putting it all together
(account/info)
(display-name)
(web-page-logic)
(request-routing)
(with-oauth <app> <credential>)
APIconUK 2014 149 / 1492014/09/24
?
APIconUK 2014 150 / 1492014/09/24
APIconUK 2014 151 / 1492014/09/24
URIs & URLs Are Not Strings
https://example.com/price/<x>
APIconUK 2014 152 / 1492014/09/24
URIs & URLs Are Not Strings
https://example.com/price/<x>?tick=<n>
APIconUK 2014 153 / 1492014/09/24
URIs & URLs Are Not Strings
https://example.com/price/<x>?tick=<n>
APIconUK 2014 154 / 1492014/09/24
URIs & URLs Are Not Strings
https://example.com/price/<x>?tick=<n>
APIconUK 2014 155 / 1492014/09/24
URIs & URLs Are Not Strings
https://example.com/price/<x>?tick=<n>
https://example.com/price/<x>/<y>
APIconUK 2014 156 / 1492014/09/24
URIs & URLs Are Not Strings
https://example.com/price/<x>/<y>?tick=<n>
APIconUK 2014 157 / 1492014/09/24
URIs & URLs Are Not Strings
https://user:[email protected]/price?tick=3#appendix
APIconUK 2014 158 / 1492014/09/24
URIs & URLs Are Not Strings
https://user:[email protected]/price?tick=3#appendix
APIconUK 2014 159 / 1492014/09/24
URIs & URLs Are Not Strings
https://user:[email protected]/price?tick=3#appendix
APIconUK 2014 160 / 1492014/09/24
URIs & URLs Are Not Strings
https://user:[email protected]/price?tick=3#appendix
APIconUK 2014 161 / 1492014/09/24
URIs & URLs Are Not Strings
https://user:[email protected]/price?tick=3#appendix
APIconUK 2014 162 / 1492014/09/24
URIs & URLs Are Not Strings
https://user:[email protected]/price?tick=3#appendix
APIconUK 2014 163 / 1492014/09/24
URIs & URLs Are Not Strings
https://user:[email protected]/price?tick=3#appendix
APIconUK 2014 164 / 1492014/09/24
URIs & URLs Are Not Strings
https://user:[email protected]/price?tick=3#appendix
APIconUK 2014 165 / 1492014/09/24
URIs & URLs Are Not Strings
https://user:[email protected]/price?tick=3#appendix
ftp://example.com
//example.com/resource
//example.com
/book
?length=17;width=19
?depth=21&height=29#glossary
#chapter1
APIconUK 2014 166 / 1492014/09/24
URIs & URLs Are Not Strings
https://user:[email protected]/price?tick=3#appendix
ftp://example.com
//example.com/resource
//example.com
/book
?length=17;width=19
?depth=21&height=29#glossary
#chapter1