19
DESIGN MOBILE APIs EFFICIENT

Design mobile efficient Apis

Embed Size (px)

Citation preview

Page 1: Design mobile efficient Apis

DESIGN MOBILE

APIs

EFFICIENT

Page 2: Design mobile efficient Apis

Mobile Is Present & Future

Page 3: Design mobile efficient Apis

Think About Mobile Data Traffic

Page 4: Design mobile efficient Apis

But What’s The Problem With Mobile?

A Mobile Device is Low Powered Low BandwidthRuns On Battery

Page 5: Design mobile efficient Apis

Bandwidth Matters….Desktop:

250 kb – Avg. Page Weight2.5 pages – Avg. number Per Visit

Total = 625 Kb Bandwidth Per Visit

Mobile: 100 kb – Avg. Page Weight10 pages- Avg. number per visit

Total = 1 Mb Bandwidth per visit

Page 6: Design mobile efficient Apis

We want to keep the best user experience at all time.Nobody wants an unresponsive app.

The efficient API make a huge Impact on Performance for Mobile App Specially.

When the API is too lazy or Incomplete the burden is put on the mobile App.

Any Workaround for it, put stress on the app which consumes too much resources.

Mobile Users are very Impatient…

Page 7: Design mobile efficient Apis

Where It Fails??

Too Slow Too Much Complicated to Parse Dependent on 3rd Party Data is not Cache DB is not efficient like Indexing DB Query is not Efficient like Join

Page 8: Design mobile efficient Apis

How To Solved??

Be Simple Be Fast Use of Caching Load Needed Data Only Think as Service not as Methods

Page 9: Design mobile efficient Apis

Version API from the beginning

Easy to maintain API Easy to make changes in API & Debugging Easy to add , remove or change Functionality Enable user for backward support API becomes more reliable

Page 10: Design mobile efficient Apis

Use Pagination

Use LIMIT & OFFSET Enable Flexibility for User Data is Less & API becomes FAST

E.g. GET /properties?offset=10&limit=5

Page 11: Design mobile efficient Apis

Avoid Unnecessary Steps…

E.g. For Login API

1) Passing Credential & Get Session Token2) Get User Data after passing Valid Session Token

Instead Of This

Check Credential & Pass Data with Session TokenSession Token will use by future API Calls

Page 12: Design mobile efficient Apis

Combine Requests & Responses

E.g. Application Start up

Think when multiple APIs calls on Application Start up

Hard to Maintain & Parse If some API calls fails

Instead Of This

Combine Multiple request into Single

Easy to Maintain & Parse Easy to Handle Failure

Page 13: Design mobile efficient Apis

Field Selection

Mobile shows very less attributes on the screen.It don’t require all the fields.Fields Selection gives ability to API consumer to get desire data

E.g.

GET /cars?fields=manufacturer,model,id,color

Page 14: Design mobile efficient Apis

Authentication

Secure Data Transit Secure your Data while changing by API Use Access Token Malicious data having unintended consequences

Page 15: Design mobile efficient Apis

Load Only Needed Data

Load Data which are need to Display Load Images,files Asynchronously It affects Latency Time of API It affects User Experience Avoids unnecessary condition checking saves User Time saves User Data charge Amount

Page 16: Design mobile efficient Apis

Error With Information Helps in Debug Error Use standard format that Self Explanatory Helps in Recovery from failure

E.g.

{                "http_code": "401",                “User_message" : “Email does not exits",                "internal_message" : “Authentication Failed"                }

Page 17: Design mobile efficient Apis

Status Code Value Meaning200 OK Working fine201 OK New resource

Created204 OK Successfully

Deleted

304 Not Modified Use Cache Data

400 Bad Request Invalid401 Unauthorized Authentication

Failed 403 Forbidden Refuse Request404 Not Found No resource

500 Internal Server Error

Server Error

Page 18: Design mobile efficient Apis

Awesome Documentation

Might be hardest job It should be precise, correct & easy to understand Update when API changes made Saves lots of time in implementation Show sample code Better for future

Page 19: Design mobile efficient Apis

Thank You…