SlideShare a Scribd company logo
1 of 67
Download to read offline
Data to Go
Mobile API Design
Matt Smollinger
CTO & Co-Founder, Skaffl
@mattsmollinger
Chuck Greb
Sr. Software Engineer, Mapzen
@ecgreb
#SXSW
#DataToGo
About us
Chief Technology Officer of Skaffl.
com, Mobile Dev, and general geek.
Mobile software craftsman, test-
driven evangelist, and clean code
connoisseur.
Matt Smollinger
CTO & Co-Founder, Skaffl
@mattsmollinger
Chuck Greb
Sr. Software Engineer, Mapzen
@ecgreb
Agenda
● Overview
● 3 Principles of (good) mobile API design
● Looking to the future
What is an API?
An application programming interface (API) is a
specification of how software components
should interact with each other. In most cases
an API is a library that includes specification for
routines, data structures, object classes, and
variables.
http://en.wikipedia.org/wiki/Application_programming_interface
Remote Service API
● Web service
● Desktop, laptop, or mobile client
● Communication and protocol
HTTP + JSON = <3
Web API Request
Mobile API Request
Mobile API requests are
generally slower and more
prone to timeouts and other
failures!
Yo ho ho and a few
billion pageviews of
RUM
Josh Fraser, Torbit, 2012
How speed affects bounce rate
(Fraser, 2012, p. 30)
How speed affects bounce rate (mobile)
(Fraser, 2012, p. 34)
How speed affects user engagement
(Fraser, 2012, p. 35)
How speed affects user engagement (mobile)
(Fraser, 2012, p. 37)
The Three Little APIs
Once upon a time...
Things users care about
● Speed
● Battery life
● Privacy
Public vs. Private APIs
Is your API open to 3rd party developers?
3 Principles of Mobile API Design
1. Reduce round trips to the server
2. Control verbosity
3. Restrict access
Catomatic
● Node.js server (Express)
● iOS client
● Android client
Catomatic
Node Instance: http://mostlygeeks.com:5000/
https://github.com/msmollin/sxsw_node
https://github.com/msmollin/catomatic_ios
https://github.com/ecgreb/catomatic
Reduce round trips
to the server
Principle #1
Resource constrained environment
● CPU
● memory
● bandwidth
● battery
Hardware comparison
Moto X
● Snapdragon S4 Pro
● Dual-core
● 1.7 GHz
● 2GB RAM
Apple iMac
● Intel Core i7
● Quad-core + HT
● 3.4 GHz
● 8GB RAM (standard)
● Up to 32GB
Users are impatient
● Reduce network overhead
● Brevity trumps discoverability
● RESTful vs. RESTish
Mobile Performance
from Radio Up
Ilya Grigorik, Google, 2013
The (short) life of a web request
(Grigorik, 2013, p. 20)
Watch those energy tails!
(Grigorik, 2013, p. 23)
HSPA vs LTE (U.S.)
(Grigorik, 2013, p. 37)
HSPA vs LTE (World)
(Grigorik, 2013, p. 37)
Show me the cache
● Memory
● Disk
● Invalidation
Chiu-Ki Chan
Caching Strategies for Mobile Apps
Philly ETE 2012
http://chiuki.github.io/mobile-caching-strategies/
- Phil Karlton
"There are two hard things in
computer science:
cache invalidation, naming
things, and off-by-1 errors."
Reduce round trips
to the server
Example #1 (Login)
Verify Password
POST http://mostlygeeks.com:5000/api/verify_password
Input
{ "email": "chuck@example.com", "password": "buddy" }
Output
{ "user_id": 1 }
Profile
GET http://mostlygeeks.com:5000/api/users/1
{
"user_id": 1,
"name": "Chuck Greb",
"email": "chuck@example.com"
}
Cats
GET http://mostlygeeks.com:5000/cats
[
{
"cat_id": 1,
"name": "Kaze",
"age": 2,
"small_photo_url": "http://example.com/images/kaze_small.jpg",
"short_description": "Kaze is an energetic and playful cat."
},
...
]
Login (input)
POST http://mostlygeeks.com:5000/login
{ "email": "chuck@example.com", "password": "buddy" }
Login (output)
{
"user": {
"user_id": 1,
"name": "Chuck Greb",
"email": "chuck@example.com"
},
"cats": [
{
"cat_id": 1,
"name": "Kaze",
"age": 2
},
...
]
}
Control verbosity
Principle #2
Low hanging fruit
● Remove empty data
● Remove irrelevant data
● GZIP compression
Time
Data
is
Money
- Benjamin Franklin
Sip, don’t chug.
● Less data is faster
● Less data is less expensive
Knobs and dials
● Pagination
● Sort
● Search
● Filter
Object Expansion
Specify verbosity level on per request basis
● Abstract verbosity level
● Custom media type
● Specify response fields in the request
● Collection vs. resource
Abstract verbosity level
http://example.com/api/cats?verbosity=3
Custom media type
Accept: application/cat.simple+json
http://developer.github.com/v3/media/
Specify response fields
http://example.com/api/cats?fields=[cat_id,name,age]
Collection vs. resource
http://example.com/api/cats
http://example.com/api/cats/1
Control verbosity
Example #2 (Master/detail)
Cats (collection)
GET http://mostlygeeks.com:5000/cats
Output
[
{
"cat_id": 1,
"name": "Kaze",
"age": 2,
"photo_url": "http://example.com/images/kaze.jpg",
"short_description": "Kaze is an energetic and playful cat."
},
...
]
Cat (resource)
GET http://mostlygeeks.com:5000/cats/1
Output
{
"cat_id": 1,
"name": "Kaze",
"age": 2,
"small_photo_url": "http://example.com/images/kaze_small.jpg",
"short_description": "Kaze is an energetic and playful cat.",
"large_photo_url": "http://example.com/images/kaze_large.jpg",
"long_description": "Kaze is an energetic and playful cat who likes to..."
}
Restrict access
Principle #3
Identify the origin of all requests
● Application version
● User account
● Device type
● Operating system
● Network (IP) address
● etc.
Deny unauthorized requests
● Invalid credentials
● Rate limit
● Unsupported operating system
● Obsolete application version
● Blacklisted IP address
Protect sensitive data
● Personal data
● Proprietary data
● Critical URL Resources
Keep it secret. Keep it safe.
Mobile-friendly security
Do
● HTTPS/SSL
● Access token
header
● 2-step verification
Don’t
● Session
● Cookies
● CSRF tokens
● OAuth*
● HMAC*
*Unless your API is public
Wait... I thought OAuth was good?
● Which implementation?
● Designed for 3-legged communication over
un-encrypted connections.
● Apps can be decompiled to determine
hashing algorithm if done client-side.
● Introduces significant overhead.
● OAuth2 = Security Sadness
Restrict access
Example #3 (Access token)
Login
POST http://mostlygeeks.com:5000/login
Input
{ "email": "chuck@example.com", "password": "buddy" }
Output
{
"access_token": "Y2h1Y2tAZXhhbXBsZS5jb20",
"cats": [ ... ]
}
Looking to the
future...
The Future...
...is now
● SPDY
● Binary Transfer Formats
○ Protobuf
○ BSON
○ Thrift
● Websockets
● HTTP 2.0
How was the session?
FeedbackSXSW App Session Feedback
1. Express yourself
2. Help us get better
3.Earn rewards
{Daily SXSW Posters + Grand Prizes}
In 1 minute
done.
Matt Smollinger
CTO & Co-Founder, Skaffl
@mattsmollinger
Chuck Greb
Sr. Software Engineer, Mapzen
@ecgreb
#SXSW
#DataToGo

More Related Content

Similar to Data to Go: Mobile API Design (SXSW)

Data To Go: Mobile API Design (Lightning Talk)
Data To Go: Mobile API Design (Lightning Talk)Data To Go: Mobile API Design (Lightning Talk)
Data To Go: Mobile API Design (Lightning Talk)
Chuck Greb
 
Is your mobile app up to speed softwaresymposium
Is your mobile app up to speed softwaresymposiumIs your mobile app up to speed softwaresymposium
Is your mobile app up to speed softwaresymposium
Doug Sillars
 
Googleappengineintro 110410190620-phpapp01
Googleappengineintro 110410190620-phpapp01Googleappengineintro 110410190620-phpapp01
Googleappengineintro 110410190620-phpapp01
Tony Frame
 
Data to Go: Mobile API Design
Data to Go: Mobile API DesignData to Go: Mobile API Design
Data to Go: Mobile API Design
Chuck Greb
 
«Что такое serverless-архитектура и как с ней жить?» Николай Марков, Aligned ...
«Что такое serverless-архитектура и как с ней жить?» Николай Марков, Aligned ...«Что такое serverless-архитектура и как с ней жить?» Николай Марков, Aligned ...
«Что такое serverless-архитектура и как с ней жить?» Николай Марков, Aligned ...
it-people
 

Similar to Data to Go: Mobile API Design (SXSW) (20)

gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20
gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20
gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20
 
Kono.IntelCraft.Weekly.AI.LLM.Landscape.2024.02.28.pdf
Kono.IntelCraft.Weekly.AI.LLM.Landscape.2024.02.28.pdfKono.IntelCraft.Weekly.AI.LLM.Landscape.2024.02.28.pdf
Kono.IntelCraft.Weekly.AI.LLM.Landscape.2024.02.28.pdf
 
Ten practical ways to improve front-end performance
Ten practical ways to improve front-end performanceTen practical ways to improve front-end performance
Ten practical ways to improve front-end performance
 
ALT-F1 Techtalk 3 - Google AppEngine
ALT-F1 Techtalk 3 - Google AppEngineALT-F1 Techtalk 3 - Google AppEngine
ALT-F1 Techtalk 3 - Google AppEngine
 
Data To Go: Mobile API Design (Lightning Talk)
Data To Go: Mobile API Design (Lightning Talk)Data To Go: Mobile API Design (Lightning Talk)
Data To Go: Mobile API Design (Lightning Talk)
 
Is your mobile app up to speed softwaresymposium
Is your mobile app up to speed softwaresymposiumIs your mobile app up to speed softwaresymposium
Is your mobile app up to speed softwaresymposium
 
Googleappengineintro 110410190620-phpapp01
Googleappengineintro 110410190620-phpapp01Googleappengineintro 110410190620-phpapp01
Googleappengineintro 110410190620-phpapp01
 
Data to Go: Mobile API Design
Data to Go: Mobile API DesignData to Go: Mobile API Design
Data to Go: Mobile API Design
 
Building Web Mobile App that don’t suck - FITC Web Unleashed - 2014-09-18
Building Web Mobile App that don’t suck - FITC Web Unleashed - 2014-09-18Building Web Mobile App that don’t suck - FITC Web Unleashed - 2014-09-18
Building Web Mobile App that don’t suck - FITC Web Unleashed - 2014-09-18
 
File Repository on GAE
File Repository on GAEFile Repository on GAE
File Repository on GAE
 
Intro to the ArcGIS Geotrigger Service
Intro to the ArcGIS Geotrigger ServiceIntro to the ArcGIS Geotrigger Service
Intro to the ArcGIS Geotrigger Service
 
mitra_resume-2
mitra_resume-2mitra_resume-2
mitra_resume-2
 
OGCE TeraGrid 2010 Science Gateway Tutorial Intro
OGCE TeraGrid 2010 Science Gateway Tutorial IntroOGCE TeraGrid 2010 Science Gateway Tutorial Intro
OGCE TeraGrid 2010 Science Gateway Tutorial Intro
 
Complex realtime event analytics using BigQuery @Crunch Warmup
Complex realtime event analytics using BigQuery @Crunch WarmupComplex realtime event analytics using BigQuery @Crunch Warmup
Complex realtime event analytics using BigQuery @Crunch Warmup
 
«Что такое serverless-архитектура и как с ней жить?» Николай Марков, Aligned ...
«Что такое serverless-архитектура и как с ней жить?» Николай Марков, Aligned ...«Что такое serverless-архитектура и как с ней жить?» Николай Марков, Aligned ...
«Что такое serverless-архитектура и как с ней жить?» Николай Марков, Aligned ...
 
Doug Sillars on App Optimization
Doug Sillars on App OptimizationDoug Sillars on App Optimization
Doug Sillars on App Optimization
 
Reactive data analysis with vert.x
Reactive data analysis with vert.xReactive data analysis with vert.x
Reactive data analysis with vert.x
 
Open source for customer analytics
Open source for customer analyticsOpen source for customer analytics
Open source for customer analytics
 
Big Data Meetup #7
Big Data Meetup #7Big Data Meetup #7
Big Data Meetup #7
 
Big data made easy with a Spark
Big data made easy with a SparkBig data made easy with a Spark
Big data made easy with a Spark
 

More from Chuck Greb

HowAboutWe... Build an Android App
HowAboutWe... Build an Android AppHowAboutWe... Build an Android App
HowAboutWe... Build an Android App
Chuck Greb
 

More from Chuck Greb (10)

Testable Android Architecture
Testable Android ArchitectureTestable Android Architecture
Testable Android Architecture
 
Bu
BuBu
Bu
 
What's the deal with Android maps?
What's the deal with Android maps?What's the deal with Android maps?
What's the deal with Android maps?
 
Building Location-Aware Apps using Open Source (AnDevCon SF 2014)
Building Location-Aware Apps using Open Source (AnDevCon SF 2014)Building Location-Aware Apps using Open Source (AnDevCon SF 2014)
Building Location-Aware Apps using Open Source (AnDevCon SF 2014)
 
Building Location-Aware Apps with Open Source & Open Data
Building Location-Aware Apps with Open Source & Open DataBuilding Location-Aware Apps with Open Source & Open Data
Building Location-Aware Apps with Open Source & Open Data
 
Notifunk
NotifunkNotifunk
Notifunk
 
AnDevCon 2013 Roundup
AnDevCon 2013 RoundupAnDevCon 2013 Roundup
AnDevCon 2013 Roundup
 
Android TDD
Android TDDAndroid TDD
Android TDD
 
Google Charts for native Android apps
Google Charts for native Android appsGoogle Charts for native Android apps
Google Charts for native Android apps
 
HowAboutWe... Build an Android App
HowAboutWe... Build an Android AppHowAboutWe... Build an Android App
HowAboutWe... Build an Android App
 

Recently uploaded

Recently uploaded (20)

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 

Data to Go: Mobile API Design (SXSW)