Turbocharge your API strategy with SDK

Post on 14-Apr-2017

102 views 1 download

Transcript of Turbocharge your API strategy with SDK

RameshElaiyavalli– ChiefOperatingOfficer– Phone.com

TurbochargeyourAPIStrategywithSDK

TurbochargeyourAPIStrategywithSDK

• WhatisanSDK?

• SDK=SoftwareDevelopmentKit

• Afile/librarythatprovidesstructuredaccesstoAPIfunctions.

DesignConsiderationsforSDK• APIcomplexity• CostconsiderationforSDK• Concurrency,scalability,errortrackinganddebugging,levelofcompleteness,performanceandlatency.

• Customerbaseandcustomerretention• Intendeduserbasesizeandsophistication• Homeorcommunitymade• Customersupportaspects

TropoSDK<?php/***AsampleapplicationthatdemonstratestheuseoftheTropoPHP package.*@copyright2010MarkJ.Head(http://www.voiceingov.org)*///IncludeTropoclasses.

require('tropo.class.php');//<- LoadSDK

$tropo=newTropo();//<- Initialization$tropo->Say("HelloWorld!");// <- simplecalltoAPIviaanobjectmethod$tropo->RenderJson();?>

Phone.comAPINoSDK

<?php

//UsingaGenericHTTPLibrary– NOTANSDK

$client=new\GuzzleHttp\Client(['base_uri'=>'https://api.phone.com/v4', //<-InitializeAPIlocation'headers'=>['Authorization' =>"Bearer$token"]//<- ProvideAuthentication

]);

//CallAPIFunction toListAllAddressBookContacts$response=$client->get(’/accounts/123/extensions/456/contacts');

OrThisWayMicroservices

<?php$url="https://v1.api.phone.com/contacts/?limit=5&offset=0";

$ch=curl_init();//<- InitializeCURLandsetHTTPOptionscurl_setopt($ch, CURLOPT_URL,$url);curl_setopt($ch, CURLOPT_HTTPAUTH,CURLAUTH_BASIC);curl_setopt($ch, CURLOPT_USERPWD,"username:password"); //<- Authenticationcurl_setopt($ch, CURLOPT_HEADER,true);curl_setopt($ch, CURLOPT_HTTPHEADER,array('Content-Type:application/json'));curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);

$result=curl_exec($ch);// <- SendAPIRequest$info=curl_getinfo($ch);//<- Getresponse fromAPIvendorcurl_close($ch);

if($info['http_code'] ==200){echo$result;}

SowhySDK?• HideComplexities&reducefrictiontoadopt.• AbstractionLayer– Canhelpkeepcodeintegrityifyouswitchvendors

• MightrequireyetanotherabstractionlayerontopofvendorSDK

• SimplertochangeAPIversion• Providehigherlevel• FunctionalitybusinesslogicinsteadofmicrolevelAPI.

• MobileAppscanleverageSDKdirectly.

WhyNOTSDK?

• BadSDKmaketheuseoftheAPImorecomplicated.

• LessvisibilitytowhatAPIfunctionsareused• Morecodemorebugs• NeedforongoingmaintenanceforSDKontopofAPIforallthelanguagesandplatforms.

• NotallSDKsareofficiallycreatedorsupportedbytheAPIvendoritself

• Maintaindocumentationandusageexamples.

EdgeCases

• ComplexAPIstargetinglargelowproficiencydeveloperaudience.– SureitisbettertoprovideSDK.

• SimpleAPItargetinghighproficiencysmalldeveloperaudience– Probablyawasteoftime.

CommunityorHomeBuilt

• Community– Nicetime&costsaver– ifbuiltnicely– Quickdeveloperswouldlikethechallenge– Makesuretocontributeandhelpfindbugs– KeepupdatingwhenreleasingnewAPIversions

• Home– Higherinvestment– mayreducewithautomation.– Fullcontroloverfunctionalityandstructure– KeepupdatingwhenreleasingnewAPIversions

ToSDKornot?

• Pros– CanhelpinhidingsomeAPIcomplexities– Createdanabstractionlayer– Canhelpcustomersupport– Hidecomplexitiesinlargeprojects

• Cons– Mighthidetoomuch– Hardertosupportifnotcreatedbyvendor

Othertools

• Samplecodeindifferentlanguagesiskey• Makesitrealeasytostart

Dashboard

ControlPanel