designing api for mobile apps (mobilewarsaw 19.01.2015)
TRANSCRIPT
![Page 1: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/1.jpg)
Designing mobile APIWojtek Erbetowski
MobileWarsaw #21, 19.01.2015t: @erbetowski
![Page 2: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/2.jpg)
About me?You all know me already, right?
![Page 3: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/3.jpg)
Why not simply 'design an API'?
![Page 4: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/4.jpg)
Good mobile API≠
Good API
![Page 5: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/5.jpg)
![Page 6: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/6.jpg)
REST & HATEOAS
![Page 7: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/7.jpg)
GET /users/123{ "name": "John Doe", "age": 25, "links": [ { "rel": "self", "href": "/users/123" }, { "rel": "account", "href": "/accounts/987" }, { "rel": "address", "href": "/addresses/555" } ]}
![Page 8: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/8.jpg)
GET /addresses/555{ "street": "Sesame", "no": 25, "zipCode": "12-321", "state": "NY", "country": "US"}
![Page 9: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/9.jpg)
HATEOAS is great!
![Page 10: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/10.jpg)
there's a thing called latency
![Page 11: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/11.jpg)
Latency
![Page 12: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/12.jpg)
Latency
![Page 13: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/13.jpg)
It can get crazy
![Page 14: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/14.jpg)
Merging responses
![Page 15: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/15.jpg)
GET /user/123{ "name": "John Doe", "age": 25, "country": "US"}
![Page 16: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/16.jpg)
And if it ain't yours?
![Page 17: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/17.jpg)
Expansion FTW!
![Page 18: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/18.jpg)
GET /users/123?fields=[name,age,address[country]]
{ "name": "John Doe", "age": 25, "country": "US"}
![Page 19: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/19.jpg)
but most of all
![Page 20: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/20.jpg)
CONNECTION: KEEP-ALIVE
![Page 21: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/21.jpg)
Docs
![Page 22: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/22.jpg)
![Page 23: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/23.jpg)
THROUGHPUT
![Page 24: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/24.jpg)
![Page 25: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/25.jpg)
Do you get only what you need?
![Page 26: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/26.jpg)
{ "person": { "id": 12345, "firstName": "John", "lastName": "Doe", "age": 25, "phones": { "home": "800-123-4567", "work": "888-555-0000", "cell": "877-123-1234" }, "email": [ "[email protected]", "[email protected]" ], "dateOfBirth": "1980-01-02T00:00:00.000Z", "registered": true, "emergencyContacts": [ { "name": "", "phone": "", "email": "", "relationship": "spouse|parent|child|other" } ], "address": { "street": "Sesame", "no": 25, "zipCode": "12-321", "state": "NY", "country": "US" } }}
![Page 27: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/27.jpg)
{ "firstName": "John", "lastName": "Doe", "age": 25, "country": "US"}
![Page 28: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/28.jpg)
And if it ain't yours?
![Page 29: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/29.jpg)
Expansion FTW!
![Page 30: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/30.jpg)
GET /users/123?fields=[name,age,address[country]]
{ "name": "John Doe", "age": 25, "country": "US"}
![Page 31: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/31.jpg)
DATA COMPRESSION
![Page 32: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/32.jpg)
{"people": [ { "firstName": "Jason", "lastName": "Page", "username": "jasonp", "isMale": true, "phone": "142-808-3743", "nid": "12252671714" ...
![Page 33: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/33.jpg)
Full222910 bytes
GZipped32128 bytes (14%)
![Page 34: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/34.jpg)
Domain complexity
![Page 35: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/35.jpg)
Usually automated testing sucks(on mobile)
![Page 36: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/36.jpg)
So if UI differs fromDATA MODEL
![Page 37: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/37.jpg)
... let the backend guys worry
![Page 38: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/38.jpg)
POST /relation{ "type": "follower", "from": 123, "to": 456}
![Page 39: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/39.jpg)
POST /follow/456
![Page 40: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/40.jpg)
HTTP Cache
![Page 41: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/41.jpg)
Expires: Sat, 21 Feb 2015 05:00 GMT
iOS (AFNetworking + NSURLCache)
Android (Retrofit + OkHttp + HttpResponseCache)
![Page 42: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/42.jpg)
GET /users?page=1[ "Arthur", "Bob", "Celine", "Daniel", "Eve", "Fred", "George"]
![Page 43: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/43.jpg)
GET /users?since=185328145127
![Page 44: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/44.jpg)
{ "items": [ ... ], "next": "/users?since=185328145127"}
![Page 45: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/45.jpg)
Case study
![Page 46: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/46.jpg)
Endpoints overallfrom 36 to 20
![Page 47: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/47.jpg)
Endpoints usage(full application flow)
from 86 to 20
![Page 48: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/48.jpg)
96% data size reduction(84% without GZIP)
![Page 49: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/49.jpg)
In the endit's all about usability
![Page 50: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/50.jpg)
Starring
![Page 51: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/51.jpg)
AkamaiState of the Internethttp://www.akamai.com/stateo!heinternet/
![Page 52: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/52.jpg)
Swaggerhttp://swagger.io/
![Page 53: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/53.jpg)
Applause(Former uTest)
https://itunes.apple.com/us/app/utest/id411486493
![Page 54: Designing API for mobile apps (MobileWarsaw 19.01.2015)](https://reader030.vdocument.in/reader030/viewer/2022020218/55a5f3a21a28abd53d8b47ce/html5/thumbnails/54.jpg)
Any thoughts?