SlideShare a Scribd company logo
1 of 43
Download to read offline
Creating Rich 

Server API’s for 

your Mobile Apps
Jonathan Guthrie
PerfectlySoft Inc.

www.perfect.org

@iamjono
Best Practices
& Guidelines
Meta-Themes
• authentication

• analytics

• structure

• deployment

• documentation
Creating Rich Server API’s for your Mobile Apps
Authentication
• Local authentication

• OAuth2

• And the others like SPENGO, LDAP
Creating Rich Server API’s for your Mobile Apps
Local Authentication
Creating Rich Server API’s for your Mobile Apps
{
“user”: “me”,
“pwd”: “iHeartSwift”
}
{
“token”: “qwerty123”
}
Initial interaction
Local Authentication
Creating Rich Server API’s for your Mobile Apps
Header:
Authorization: Bearer qwerty123
Ongoing interaction
OAuth2 Authentication
Creating Rich Server API’s for your Mobile Apps
Allow me please?
{“token”:“qwerty123”}
Initial interaction (simplified)
OAuth2

Provider
{“token”:“qwerty123”}
user
info
Authentication
Local
Creating Rich Server API’s for your Mobile Apps
Easy to implement

Control over user info

User maintains many accounts

Password Fatigue
OAuth2
Low barrier to usage

User maintains fewer accounts

Harder to implement

Almost no control over content

Hard to deactivate a user
Better in corporate
environments
Better in user-first
environments
Authentication
always authenticate.
Creating Rich Server API’s for your Mobile Apps
If all else fails, use “fingerprinting”
“appid”: “mygreatapp”,
“deviceid”: “somethingrandom”,
“appversion”: 1.3.6
Add to API headers:
Authentication
Creating Rich Server API’s for your Mobile Apps
Analytics
• Local logging

• Google Server API
Creating Rich Server API’s for your Mobile Apps
Local Logging
Creating Rich Server API’s for your Mobile Apps
All interactions contain these headers:
“appid”: “mygreatapp”,
“deviceid”: “somethingrandom”,
“appversion”: 1.3.6
Log to DB
Google Analytics
Creating Rich Server API’s for your Mobile Apps
All interactions contain these headers:
“appid”: “mygreatapp”,
“deviceid”: “somethingrandom”,
“appversion”: 1.3.6
Google Analytics
Measurement Protocol
https://github.com/PerfectlySoft/Perfect-GoogleAnalytics-MeasurementProtocol
Structure
• Simplicity is King 

• Routing

• Code structure
Creating Rich Server API’s for your Mobile Apps
Simplicity is King
Creating Rich Server API’s for your Mobile Apps
• Minimize HTTP calls from the client

• Balance minimizing calls with
premature optimization

• Plan, and spend more time planning.
Routing
Creating Rich Server API’s for your Mobile Apps
Routing
Creating Rich Server API’s for your Mobile Apps
// Docs
routes.append([
"method":"post", "uri":"/api/v1/docs/create", 

“handler":WebHandlers.docCreate
])
routes.append([
"method":"post", "uri":"/api/v1/docs/save/doc", 

“handler":WebHandlers.docSaveDoc
])
routes.append([
"method":"get", "uri":"/api/v1/docs/XAR0fzvSvImUwderQSJvFg",
“handler":WebHandlers.docGet
])
API version 1
Routing
Creating Rich Server API’s for your Mobile Apps
// Docs
routes.append([
"method":"post", "uri":"/api/v1/docs/create", 

“handler":WebHandlers.docCreate
])
routes.append([
"method":"post", "uri":"/api/v1/docs/save/doc", 

“handler":WebHandlers.docSaveDoc
])
routes.append([
"method":"get", "uri":"/api/v1/docs/XAR0fzvSvImUwderQSJvFg",
“handler":WebHandlers.docGet
])
POST
GET
Routing: HTTP Verbs
Creating Rich Server API’s for your Mobile Apps
GET
POST
PATCH
PUT
DELETE
Retrieve resources
Create resource
Update resource
Upload resource (aka file)
Delete resource
Routing: HTTP Verbs
Creating Rich Server API’s for your Mobile Apps
GET
POST
PATCH
PUT
DELETE
/v1/user/{id}
/v1/user
/v1/user
/v1/user/{id}/avatar
/v1/user/{id}
Routing: ID’s
Creating Rich Server API’s for your Mobile Apps
// Docs
routes.append([
"method":"post", "uri":"/api/v1/docs/create", 

“handler":WebHandlers.docCreate
])
routes.append([
"method":"post", "uri":"/api/v1/docs/save/doc", 

“handler":WebHandlers.docSaveDoc
])
routes.append([
"method":"get", "uri":"/api/v1/docs/XAR0fzvSvImUwderQSJvFg",
“handler":WebHandlers.docGet
])
Resource ID
Routing: ID’s
Creating Rich Server API’s for your Mobile Apps
• Never expose integer ID’s

• Sequential ID’s are guessable

• Use [A-Za-z0-9] ID’s

• Encrypt or abstract if needed
Code Structure
Creating Rich Server API’s for your Mobile Apps
• Clearly organize your code structure

• Maximize code re-use

• Employ sensible functional programming
Clear Organization
Creating Rich Server API’s for your Mobile Apps
Use folder / groups
Clear Organization
Creating Rich Server API’s for your Mobile Apps
Separate handlers
into digestible and
identifiable chunks
Maximize code-reuse
Creating Rich Server API’s for your Mobile Apps
Every request
var context: [String : Any] = [
"accountID": contextAccountID,
"authenticated": contextAuthenticated,
"userlist?":"true",
"msg": msg,
"configTitle": configTitle,
"configLogo": configLogo,
"configLogoSrcSet": configLogoSrcSet
]
Maximize code-reuse
Creating Rich Server API’s for your Mobile Apps
extension WebHandlers {
static func appExtras() -> [String : Any] {
return [
"configTitle": configTitle,
"configLogo": configLogo,
"configLogoSrcSet": configLogoSrcSet
]
}
}
Maximize code-reuse
Creating Rich Server API’s for your Mobile Apps
var context: [String : Any] = [
"accountID": contextAccountID,
"authenticated": contextAuthenticated,
"userlist?":"true",
"msg": msg
]
// add app config vars
for i in WebHandlers.appExtras() {
context[i.0] = i.1
}
Sensible functional
programming
Creating Rich Server API’s for your Mobile Apps
Thursday, June 8
this.
Deployment
Horizontal vs vertical scaling
Creating Rich Server API’s for your Mobile Apps
Vertical Scaling
Creating Rich Server API’s for your Mobile Apps
bigger, better, faster, more
Vertical Scaling
Creating Rich Server API’s for your Mobile Apps
bigger,
better,
faster,
more $$$
aka: Single Point of Failure
Horizontal Scaling
Creating Rich Server API’s for your Mobile Apps
lots & lots & lots of bricks
Horizontal Scaling
Creating Rich Server API’s for your Mobile Apps
lots & lots & lots of bricks
API Documentation
Creating Rich Server API’s for your Mobile Apps
crickets, anyone?
API Documentation
Creating Rich Server API’s for your Mobile Apps
Be kind to your API users:

Document your API
API Doc Engines
Creating Rich Server API’s for your Mobile Apps
crickets, anyone?
• readme.io

• Slate

• Perfect API Doc Server

• Raw HTML
API Documentation
Creating Rich Server API’s for your Mobile Apps
API Documentation
Creating Rich Server API’s for your Mobile Apps
Document first?

or

Code first?
API Documentation
Creating Rich Server API’s for your Mobile Apps
Plan first
API Documentation
Creating Rich Server API’s for your Mobile Apps
Plan first

then document

then code, and document
API Documentation
Creating Rich Server API’s for your Mobile Apps
Be kind to those who come later:

Document your code
API Documentation
Creating Rich Server API’s for your Mobile Apps
Questions?
Creating Rich Server API’s for your Mobile Apps
Jono Guthrie
PerfectlySoft Inc.

www.perfect.org

@iamjono

Slack: http://www.perfect.ly

More Related Content

What's hot

(MBL401) Social Logins for Mobile Apps with Amazon Cognito | AWS re:Invent 2014
(MBL401) Social Logins for Mobile Apps with Amazon Cognito | AWS re:Invent 2014(MBL401) Social Logins for Mobile Apps with Amazon Cognito | AWS re:Invent 2014
(MBL401) Social Logins for Mobile Apps with Amazon Cognito | AWS re:Invent 2014Amazon Web Services
 
Building APIs That Last for Decades - Irakli Nadareishvili, Director of API S...
Building APIs That Last for Decades - Irakli Nadareishvili, Director of API S...Building APIs That Last for Decades - Irakli Nadareishvili, Director of API S...
Building APIs That Last for Decades - Irakli Nadareishvili, Director of API S...CA API Management
 
善用分析與推播訊息增加及留住用戶
善用分析與推播訊息增加及留住用戶善用分析與推播訊息增加及留住用戶
善用分析與推播訊息增加及留住用戶Amazon Web Services
 
AnDevCon - A Primer to Sync Adapters
AnDevCon - A Primer to Sync AdaptersAnDevCon - A Primer to Sync Adapters
AnDevCon - A Primer to Sync AdaptersKiana Tennyson
 
Offline progressive web apps with NodeJS and React
Offline progressive web apps with NodeJS and ReactOffline progressive web apps with NodeJS and React
Offline progressive web apps with NodeJS and ReactIlia Idakiev
 
SharePoint and Office Development Workshop
SharePoint and Office Development WorkshopSharePoint and Office Development Workshop
SharePoint and Office Development WorkshopEric Shupps
 
Usergrid Overview
Usergrid OverviewUsergrid Overview
Usergrid Overviewusergrid
 
Creating Cloud-Ready Enterprise Applications with the SharePoint 2013 Add-In ...
Creating Cloud-Ready Enterprise Applications with the SharePoint 2013 Add-In ...Creating Cloud-Ready Enterprise Applications with the SharePoint 2013 Add-In ...
Creating Cloud-Ready Enterprise Applications with the SharePoint 2013 Add-In ...Eric Shupps
 
Add End User Sign-in, User Management, and Security to Your Mobile and Web Ap...
Add End User Sign-in, User Management, and Security to Your Mobile and Web Ap...Add End User Sign-in, User Management, and Security to Your Mobile and Web Ap...
Add End User Sign-in, User Management, and Security to Your Mobile and Web Ap...Amazon Web Services
 
What is new in Firebase?
What is new in Firebase?What is new in Firebase?
What is new in Firebase?Sinan Yılmaz
 
O365Con18 - Introduction to Azure Web Applications - Eric Shupps
O365Con18 - Introduction to Azure Web Applications  - Eric ShuppsO365Con18 - Introduction to Azure Web Applications  - Eric Shupps
O365Con18 - Introduction to Azure Web Applications - Eric ShuppsNCCOMMS
 
Developing Android Client Apps via SyncAdapter
Developing Android Client Apps via SyncAdapterDeveloping Android Client Apps via SyncAdapter
Developing Android Client Apps via SyncAdapterAnatoliy Kaverin
 
The API Facade Pattern: Common Patterns - Episode 2
The API Facade Pattern: Common Patterns - Episode 2The API Facade Pattern: Common Patterns - Episode 2
The API Facade Pattern: Common Patterns - Episode 2Apigee | Google Cloud
 
Best Practices for API Security
Best Practices for API SecurityBest Practices for API Security
Best Practices for API SecurityMuleSoft
 
Building Mobile Apps with Apache UserGrid, the Open Source Baas
Building Mobile Apps with Apache UserGrid, the Open Source BaasBuilding Mobile Apps with Apache UserGrid, the Open Source Baas
Building Mobile Apps with Apache UserGrid, the Open Source BaasAll Things Open
 

What's hot (20)

(MBL401) Social Logins for Mobile Apps with Amazon Cognito | AWS re:Invent 2014
(MBL401) Social Logins for Mobile Apps with Amazon Cognito | AWS re:Invent 2014(MBL401) Social Logins for Mobile Apps with Amazon Cognito | AWS re:Invent 2014
(MBL401) Social Logins for Mobile Apps with Amazon Cognito | AWS re:Invent 2014
 
Building APIs That Last for Decades - Irakli Nadareishvili, Director of API S...
Building APIs That Last for Decades - Irakli Nadareishvili, Director of API S...Building APIs That Last for Decades - Irakli Nadareishvili, Director of API S...
Building APIs That Last for Decades - Irakli Nadareishvili, Director of API S...
 
善用分析與推播訊息增加及留住用戶
善用分析與推播訊息增加及留住用戶善用分析與推播訊息增加及留住用戶
善用分析與推播訊息增加及留住用戶
 
AnDevCon - A Primer to Sync Adapters
AnDevCon - A Primer to Sync AdaptersAnDevCon - A Primer to Sync Adapters
AnDevCon - A Primer to Sync Adapters
 
Offline progressive web apps with NodeJS and React
Offline progressive web apps with NodeJS and ReactOffline progressive web apps with NodeJS and React
Offline progressive web apps with NodeJS and React
 
SharePoint and Office Development Workshop
SharePoint and Office Development WorkshopSharePoint and Office Development Workshop
SharePoint and Office Development Workshop
 
Hotel api integration
Hotel api integrationHotel api integration
Hotel api integration
 
Usergrid Overview
Usergrid OverviewUsergrid Overview
Usergrid Overview
 
Creating Cloud-Ready Enterprise Applications with the SharePoint 2013 Add-In ...
Creating Cloud-Ready Enterprise Applications with the SharePoint 2013 Add-In ...Creating Cloud-Ready Enterprise Applications with the SharePoint 2013 Add-In ...
Creating Cloud-Ready Enterprise Applications with the SharePoint 2013 Add-In ...
 
Add End User Sign-in, User Management, and Security to Your Mobile and Web Ap...
Add End User Sign-in, User Management, and Security to Your Mobile and Web Ap...Add End User Sign-in, User Management, and Security to Your Mobile and Web Ap...
Add End User Sign-in, User Management, and Security to Your Mobile and Web Ap...
 
What is new in Firebase?
What is new in Firebase?What is new in Firebase?
What is new in Firebase?
 
Firebase
FirebaseFirebase
Firebase
 
O365Con18 - Introduction to Azure Web Applications - Eric Shupps
O365Con18 - Introduction to Azure Web Applications  - Eric ShuppsO365Con18 - Introduction to Azure Web Applications  - Eric Shupps
O365Con18 - Introduction to Azure Web Applications - Eric Shupps
 
Developing Android Client Apps via SyncAdapter
Developing Android Client Apps via SyncAdapterDeveloping Android Client Apps via SyncAdapter
Developing Android Client Apps via SyncAdapter
 
The API Facade Pattern: Common Patterns - Episode 2
The API Facade Pattern: Common Patterns - Episode 2The API Facade Pattern: Common Patterns - Episode 2
The API Facade Pattern: Common Patterns - Episode 2
 
Firebase
FirebaseFirebase
Firebase
 
Best Practices for API Security
Best Practices for API SecurityBest Practices for API Security
Best Practices for API Security
 
Wso2 Api Manager
Wso2 Api ManagerWso2 Api Manager
Wso2 Api Manager
 
Building Mobile Apps with Apache UserGrid, the Open Source Baas
Building Mobile Apps with Apache UserGrid, the Open Source BaasBuilding Mobile Apps with Apache UserGrid, the Open Source Baas
Building Mobile Apps with Apache UserGrid, the Open Source Baas
 
如何快速開發與測試App
如何快速開發與測試App如何快速開發與測試App
如何快速開發與測試App
 

Similar to Creating Rich Server API’s for your Mobile Apps - Best Practices and Guidelines

Application Server-less Web Applications - Serverless Toronto Meetup
Application Server-less Web Applications - Serverless Toronto Meetup Application Server-less Web Applications - Serverless Toronto Meetup
Application Server-less Web Applications - Serverless Toronto Meetup Daniel Zivkovic
 
Rapid App Development with AWS Amplify
Rapid App Development with AWS AmplifyRapid App Development with AWS Amplify
Rapid App Development with AWS AmplifyRiza Fahmi
 
Introducing amplify and full stack demo app built with vue.js, graph ql, auth...
Introducing amplify and full stack demo app built with vue.js, graph ql, auth...Introducing amplify and full stack demo app built with vue.js, graph ql, auth...
Introducing amplify and full stack demo app built with vue.js, graph ql, auth...Serdal Kepil
 
WSO2Con Asia 2014 - Building the API-Centric Enterprise
WSO2Con Asia 2014 - Building the API-Centric EnterpriseWSO2Con Asia 2014 - Building the API-Centric Enterprise
WSO2Con Asia 2014 - Building the API-Centric EnterpriseWSO2
 
IBM Integration Bus and REST APIs - Sanjay Nagchowdhury
IBM Integration Bus and REST APIs - Sanjay NagchowdhuryIBM Integration Bus and REST APIs - Sanjay Nagchowdhury
IBM Integration Bus and REST APIs - Sanjay NagchowdhuryKaren Broughton-Mabbitt
 
SRV421 Deep Dive with AWS Mobile Services
SRV421 Deep Dive with AWS Mobile ServicesSRV421 Deep Dive with AWS Mobile Services
SRV421 Deep Dive with AWS Mobile ServicesAmazon Web Services
 
PowerApps, the Developer Story: Build an API to Integrate Corporate Data
PowerApps, the Developer Story: Build an API to Integrate Corporate DataPowerApps, the Developer Story: Build an API to Integrate Corporate Data
PowerApps, the Developer Story: Build an API to Integrate Corporate DataBram de Jager
 
A Community-based, Graph API Framework to Integrate and Orchestrate Cloud-Bas...
A Community-based, Graph API Framework to Integrate and Orchestrate Cloud-Bas...A Community-based, Graph API Framework to Integrate and Orchestrate Cloud-Bas...
A Community-based, Graph API Framework to Integrate and Orchestrate Cloud-Bas...Michael Petychakis
 
Connecting Xamarin Apps with IBM Worklight in Bluemix
Connecting Xamarin Apps with IBM Worklight in BluemixConnecting Xamarin Apps with IBM Worklight in Bluemix
Connecting Xamarin Apps with IBM Worklight in BluemixIBM
 
Serverless Geospatial Mobile Apps with AWS
Serverless Geospatial Mobile Apps with AWSServerless Geospatial Mobile Apps with AWS
Serverless Geospatial Mobile Apps with AWSAmazon Web Services
 
SRV411 Deep Dive on Mobile Application Development with AWS
SRV411 Deep Dive on Mobile Application Development with AWSSRV411 Deep Dive on Mobile Application Development with AWS
SRV411 Deep Dive on Mobile Application Development with AWSAmazon Web Services
 
Global Azure Bootcamp Montreal 2017
Global Azure Bootcamp Montreal 2017Global Azure Bootcamp Montreal 2017
Global Azure Bootcamp Montreal 2017Guy Barrette
 
Serverless Geospatial Mobile Apps with AWS
Serverless Geospatial Mobile Apps with AWSServerless Geospatial Mobile Apps with AWS
Serverless Geospatial Mobile Apps with AWSAmazon Web Services
 
Securely expose protected resources as ap is with app42 api gateway
Securely expose protected resources as ap is with app42 api gatewaySecurely expose protected resources as ap is with app42 api gateway
Securely expose protected resources as ap is with app42 api gatewayZuaib
 
Progetta, crea e gestisci Modern Application per web e mobile su AWS
Progetta, crea e gestisci Modern Application per web e mobile su AWSProgetta, crea e gestisci Modern Application per web e mobile su AWS
Progetta, crea e gestisci Modern Application per web e mobile su AWSAmazon Web Services
 
RefCard API Architecture Strategy
RefCard API Architecture StrategyRefCard API Architecture Strategy
RefCard API Architecture StrategyOCTO Technology
 
Everything You Need to Develop Apps Faster and Scale to Millions of Users
Everything You Need to Develop Apps Faster and Scale to Millions of UsersEverything You Need to Develop Apps Faster and Scale to Millions of Users
Everything You Need to Develop Apps Faster and Scale to Millions of UsersAmazon Web Services
 
Api development with rails
Api development with railsApi development with rails
Api development with railsEdwin Cruz
 
MongoDB.local Berlin: App development in a Serverless World
MongoDB.local Berlin: App development in a Serverless WorldMongoDB.local Berlin: App development in a Serverless World
MongoDB.local Berlin: App development in a Serverless WorldMongoDB
 
(MBL310) Workshop: Build iOS Apps Using AWS Mobile Services | AWS re:Invent 2014
(MBL310) Workshop: Build iOS Apps Using AWS Mobile Services | AWS re:Invent 2014(MBL310) Workshop: Build iOS Apps Using AWS Mobile Services | AWS re:Invent 2014
(MBL310) Workshop: Build iOS Apps Using AWS Mobile Services | AWS re:Invent 2014Amazon Web Services
 

Similar to Creating Rich Server API’s for your Mobile Apps - Best Practices and Guidelines (20)

Application Server-less Web Applications - Serverless Toronto Meetup
Application Server-less Web Applications - Serverless Toronto Meetup Application Server-less Web Applications - Serverless Toronto Meetup
Application Server-less Web Applications - Serverless Toronto Meetup
 
Rapid App Development with AWS Amplify
Rapid App Development with AWS AmplifyRapid App Development with AWS Amplify
Rapid App Development with AWS Amplify
 
Introducing amplify and full stack demo app built with vue.js, graph ql, auth...
Introducing amplify and full stack demo app built with vue.js, graph ql, auth...Introducing amplify and full stack demo app built with vue.js, graph ql, auth...
Introducing amplify and full stack demo app built with vue.js, graph ql, auth...
 
WSO2Con Asia 2014 - Building the API-Centric Enterprise
WSO2Con Asia 2014 - Building the API-Centric EnterpriseWSO2Con Asia 2014 - Building the API-Centric Enterprise
WSO2Con Asia 2014 - Building the API-Centric Enterprise
 
IBM Integration Bus and REST APIs - Sanjay Nagchowdhury
IBM Integration Bus and REST APIs - Sanjay NagchowdhuryIBM Integration Bus and REST APIs - Sanjay Nagchowdhury
IBM Integration Bus and REST APIs - Sanjay Nagchowdhury
 
SRV421 Deep Dive with AWS Mobile Services
SRV421 Deep Dive with AWS Mobile ServicesSRV421 Deep Dive with AWS Mobile Services
SRV421 Deep Dive with AWS Mobile Services
 
PowerApps, the Developer Story: Build an API to Integrate Corporate Data
PowerApps, the Developer Story: Build an API to Integrate Corporate DataPowerApps, the Developer Story: Build an API to Integrate Corporate Data
PowerApps, the Developer Story: Build an API to Integrate Corporate Data
 
A Community-based, Graph API Framework to Integrate and Orchestrate Cloud-Bas...
A Community-based, Graph API Framework to Integrate and Orchestrate Cloud-Bas...A Community-based, Graph API Framework to Integrate and Orchestrate Cloud-Bas...
A Community-based, Graph API Framework to Integrate and Orchestrate Cloud-Bas...
 
Connecting Xamarin Apps with IBM Worklight in Bluemix
Connecting Xamarin Apps with IBM Worklight in BluemixConnecting Xamarin Apps with IBM Worklight in Bluemix
Connecting Xamarin Apps with IBM Worklight in Bluemix
 
Serverless Geospatial Mobile Apps with AWS
Serverless Geospatial Mobile Apps with AWSServerless Geospatial Mobile Apps with AWS
Serverless Geospatial Mobile Apps with AWS
 
SRV411 Deep Dive on Mobile Application Development with AWS
SRV411 Deep Dive on Mobile Application Development with AWSSRV411 Deep Dive on Mobile Application Development with AWS
SRV411 Deep Dive on Mobile Application Development with AWS
 
Global Azure Bootcamp Montreal 2017
Global Azure Bootcamp Montreal 2017Global Azure Bootcamp Montreal 2017
Global Azure Bootcamp Montreal 2017
 
Serverless Geospatial Mobile Apps with AWS
Serverless Geospatial Mobile Apps with AWSServerless Geospatial Mobile Apps with AWS
Serverless Geospatial Mobile Apps with AWS
 
Securely expose protected resources as ap is with app42 api gateway
Securely expose protected resources as ap is with app42 api gatewaySecurely expose protected resources as ap is with app42 api gateway
Securely expose protected resources as ap is with app42 api gateway
 
Progetta, crea e gestisci Modern Application per web e mobile su AWS
Progetta, crea e gestisci Modern Application per web e mobile su AWSProgetta, crea e gestisci Modern Application per web e mobile su AWS
Progetta, crea e gestisci Modern Application per web e mobile su AWS
 
RefCard API Architecture Strategy
RefCard API Architecture StrategyRefCard API Architecture Strategy
RefCard API Architecture Strategy
 
Everything You Need to Develop Apps Faster and Scale to Millions of Users
Everything You Need to Develop Apps Faster and Scale to Millions of UsersEverything You Need to Develop Apps Faster and Scale to Millions of Users
Everything You Need to Develop Apps Faster and Scale to Millions of Users
 
Api development with rails
Api development with railsApi development with rails
Api development with rails
 
MongoDB.local Berlin: App development in a Serverless World
MongoDB.local Berlin: App development in a Serverless WorldMongoDB.local Berlin: App development in a Serverless World
MongoDB.local Berlin: App development in a Serverless World
 
(MBL310) Workshop: Build iOS Apps Using AWS Mobile Services | AWS re:Invent 2014
(MBL310) Workshop: Build iOS Apps Using AWS Mobile Services | AWS re:Invent 2014(MBL310) Workshop: Build iOS Apps Using AWS Mobile Services | AWS re:Invent 2014
(MBL310) Workshop: Build iOS Apps Using AWS Mobile Services | AWS re:Invent 2014
 

Recently uploaded

ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
software engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxsoftware engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxnada99848
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 

Recently uploaded (20)

ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
software engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxsoftware engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptx
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 

Creating Rich Server API’s for your Mobile Apps - Best Practices and Guidelines

  • 1. Creating Rich 
 Server API’s for 
 your Mobile Apps Jonathan Guthrie PerfectlySoft Inc. www.perfect.org @iamjono Best Practices & Guidelines
  • 2. Meta-Themes • authentication • analytics • structure • deployment • documentation Creating Rich Server API’s for your Mobile Apps
  • 3. Authentication • Local authentication • OAuth2 • And the others like SPENGO, LDAP Creating Rich Server API’s for your Mobile Apps
  • 4. Local Authentication Creating Rich Server API’s for your Mobile Apps { “user”: “me”, “pwd”: “iHeartSwift” } { “token”: “qwerty123” } Initial interaction
  • 5. Local Authentication Creating Rich Server API’s for your Mobile Apps Header: Authorization: Bearer qwerty123 Ongoing interaction
  • 6. OAuth2 Authentication Creating Rich Server API’s for your Mobile Apps Allow me please? {“token”:“qwerty123”} Initial interaction (simplified) OAuth2 Provider {“token”:“qwerty123”} user info
  • 7. Authentication Local Creating Rich Server API’s for your Mobile Apps Easy to implement Control over user info User maintains many accounts Password Fatigue OAuth2 Low barrier to usage User maintains fewer accounts Harder to implement Almost no control over content Hard to deactivate a user Better in corporate environments Better in user-first environments
  • 8. Authentication always authenticate. Creating Rich Server API’s for your Mobile Apps If all else fails, use “fingerprinting” “appid”: “mygreatapp”, “deviceid”: “somethingrandom”, “appversion”: 1.3.6 Add to API headers:
  • 9. Authentication Creating Rich Server API’s for your Mobile Apps
  • 10. Analytics • Local logging • Google Server API Creating Rich Server API’s for your Mobile Apps
  • 11. Local Logging Creating Rich Server API’s for your Mobile Apps All interactions contain these headers: “appid”: “mygreatapp”, “deviceid”: “somethingrandom”, “appversion”: 1.3.6 Log to DB
  • 12. Google Analytics Creating Rich Server API’s for your Mobile Apps All interactions contain these headers: “appid”: “mygreatapp”, “deviceid”: “somethingrandom”, “appversion”: 1.3.6 Google Analytics Measurement Protocol https://github.com/PerfectlySoft/Perfect-GoogleAnalytics-MeasurementProtocol
  • 13. Structure • Simplicity is King • Routing • Code structure Creating Rich Server API’s for your Mobile Apps
  • 14. Simplicity is King Creating Rich Server API’s for your Mobile Apps • Minimize HTTP calls from the client • Balance minimizing calls with premature optimization • Plan, and spend more time planning.
  • 15. Routing Creating Rich Server API’s for your Mobile Apps
  • 16. Routing Creating Rich Server API’s for your Mobile Apps // Docs routes.append([ "method":"post", "uri":"/api/v1/docs/create", 
 “handler":WebHandlers.docCreate ]) routes.append([ "method":"post", "uri":"/api/v1/docs/save/doc", 
 “handler":WebHandlers.docSaveDoc ]) routes.append([ "method":"get", "uri":"/api/v1/docs/XAR0fzvSvImUwderQSJvFg", “handler":WebHandlers.docGet ]) API version 1
  • 17. Routing Creating Rich Server API’s for your Mobile Apps // Docs routes.append([ "method":"post", "uri":"/api/v1/docs/create", 
 “handler":WebHandlers.docCreate ]) routes.append([ "method":"post", "uri":"/api/v1/docs/save/doc", 
 “handler":WebHandlers.docSaveDoc ]) routes.append([ "method":"get", "uri":"/api/v1/docs/XAR0fzvSvImUwderQSJvFg", “handler":WebHandlers.docGet ]) POST GET
  • 18. Routing: HTTP Verbs Creating Rich Server API’s for your Mobile Apps GET POST PATCH PUT DELETE Retrieve resources Create resource Update resource Upload resource (aka file) Delete resource
  • 19. Routing: HTTP Verbs Creating Rich Server API’s for your Mobile Apps GET POST PATCH PUT DELETE /v1/user/{id} /v1/user /v1/user /v1/user/{id}/avatar /v1/user/{id}
  • 20. Routing: ID’s Creating Rich Server API’s for your Mobile Apps // Docs routes.append([ "method":"post", "uri":"/api/v1/docs/create", 
 “handler":WebHandlers.docCreate ]) routes.append([ "method":"post", "uri":"/api/v1/docs/save/doc", 
 “handler":WebHandlers.docSaveDoc ]) routes.append([ "method":"get", "uri":"/api/v1/docs/XAR0fzvSvImUwderQSJvFg", “handler":WebHandlers.docGet ]) Resource ID
  • 21. Routing: ID’s Creating Rich Server API’s for your Mobile Apps • Never expose integer ID’s • Sequential ID’s are guessable • Use [A-Za-z0-9] ID’s • Encrypt or abstract if needed
  • 22. Code Structure Creating Rich Server API’s for your Mobile Apps • Clearly organize your code structure • Maximize code re-use • Employ sensible functional programming
  • 23. Clear Organization Creating Rich Server API’s for your Mobile Apps Use folder / groups
  • 24. Clear Organization Creating Rich Server API’s for your Mobile Apps Separate handlers into digestible and identifiable chunks
  • 25. Maximize code-reuse Creating Rich Server API’s for your Mobile Apps Every request var context: [String : Any] = [ "accountID": contextAccountID, "authenticated": contextAuthenticated, "userlist?":"true", "msg": msg, "configTitle": configTitle, "configLogo": configLogo, "configLogoSrcSet": configLogoSrcSet ]
  • 26. Maximize code-reuse Creating Rich Server API’s for your Mobile Apps extension WebHandlers { static func appExtras() -> [String : Any] { return [ "configTitle": configTitle, "configLogo": configLogo, "configLogoSrcSet": configLogoSrcSet ] } }
  • 27. Maximize code-reuse Creating Rich Server API’s for your Mobile Apps var context: [String : Any] = [ "accountID": contextAccountID, "authenticated": contextAuthenticated, "userlist?":"true", "msg": msg ] // add app config vars for i in WebHandlers.appExtras() { context[i.0] = i.1 }
  • 28. Sensible functional programming Creating Rich Server API’s for your Mobile Apps Thursday, June 8 this.
  • 29. Deployment Horizontal vs vertical scaling Creating Rich Server API’s for your Mobile Apps
  • 30. Vertical Scaling Creating Rich Server API’s for your Mobile Apps bigger, better, faster, more
  • 31. Vertical Scaling Creating Rich Server API’s for your Mobile Apps bigger, better, faster, more $$$ aka: Single Point of Failure
  • 32. Horizontal Scaling Creating Rich Server API’s for your Mobile Apps lots & lots & lots of bricks
  • 33. Horizontal Scaling Creating Rich Server API’s for your Mobile Apps lots & lots & lots of bricks
  • 34. API Documentation Creating Rich Server API’s for your Mobile Apps crickets, anyone?
  • 35. API Documentation Creating Rich Server API’s for your Mobile Apps Be kind to your API users: Document your API
  • 36. API Doc Engines Creating Rich Server API’s for your Mobile Apps crickets, anyone? • readme.io • Slate • Perfect API Doc Server • Raw HTML
  • 37. API Documentation Creating Rich Server API’s for your Mobile Apps
  • 38. API Documentation Creating Rich Server API’s for your Mobile Apps Document first? or Code first?
  • 39. API Documentation Creating Rich Server API’s for your Mobile Apps Plan first
  • 40. API Documentation Creating Rich Server API’s for your Mobile Apps Plan first then document then code, and document
  • 41. API Documentation Creating Rich Server API’s for your Mobile Apps Be kind to those who come later: Document your code
  • 42. API Documentation Creating Rich Server API’s for your Mobile Apps
  • 43. Questions? Creating Rich Server API’s for your Mobile Apps Jono Guthrie PerfectlySoft Inc. www.perfect.org @iamjono Slack: http://www.perfect.ly