You are on page 1of 2

SearchSOA.

com
ChooseJSONforbuildingAPIs
Bynull
Moreandmore,developerswhoareusedtoworkingintheWebandmobileworldsnaturallyturntoAPIsasthemosteffectivewaytoconnectclientsandservers,accordingto
GregBrail.Asthesedevelopersencounterapplicationtoapplicationproblemslikebusinesstobusinessconnectionsbetweenenterprises,theirfirstreactionis,"Whycan'twejustuseanAPIhere?"
BrailanswersthatAPIversusmiddlewarequestionandcomparesAPIbasedintegrationtoSOAandenterpriseservicebusses(ESBs)approachesinthisSearchSOAinterview.HealsooffersadviceonsuchAPImattersas
changemanagement,XMLvs.JSONdataformatsandusesforhypermedia.
CoauthoroftheO'Reillybook,APIs:AStrategyGuide,Brailhasalonghistoryinmiddlewaredevelopment.HebuiltmiddlewarelibrariesforCitibankandwasprincipalarchitectfortransactplustechnicalleadforBEAs
WebLogicJMS.AtApigee,anAPIandmiddlewarebackendasaserviceprovider,heisthearchitectureleadforallproducts.
WhenandwhyshouldAPIsreplaceintegrationmiddleware?
GregBrail:JustasAPIsarefastenoughforthemostdemandingmobileapplications,andsecureenoughforimportantconsumerfocusedusecases,thereisnoreasonwhytheycannotbethedefaultchoiceforintegrationtasks
aswell.ThereisverylittlereasontouseamoretraditionalapplicationtoapplicationprotocolorintegrationtechnologywhenanAPIcanbeusedinstead.
Exceptions,Ithink,arefewerandfartherbetweenthanpeoplethink.Agoodexamplewouldbeapplicationslikehighfrequencyfinancialtrading,wherethethroughputandlatencydemandsaresoextremethatevenTCP,let
aloneHTTP,isjusttooslow.
Evenwheremoretypicalenterprisetechnologylikemessagequeuingandpublish/subscribeisused,inmanycases,wrappingthemessagingsystemwithanAPImakesiteasiertoconsume.
HowdoAPIsasanintegrationapproachcomparetoSOAandESBs?
Brail:SOAisaboutconnectingserviceswithintheenterprisetoachievereuseandsavemoney.APIsbuilduponSOAbyemphasizingdeveloperusabilityandselfservice,andaboutcreatingnewservicesthatcanbeused
bothinsidetheenterpriseaswellasbycustomers,partners,anddevelopers.SOAdidn'tdomuchtoenablethosekindsofusecases.
ESBssolvepartoftheAPIintegrationandSOAproblem,butAPIsarealotmore.Forinstance,ESBsdonothingtomakeiteasierfordeveloperstoconsumeAPIsviaselfservice,andtheydonothingtomakeanexisting
systemofrecordsafeformobileuseontheInternetbymanaginghightrafficvolumesandprovidingadvancedsecurityandthreatdetection.
OurreaderstellusthatchangemanagementisapainpointinAPImanagement.Whatprocessandtechnicalproblemsdoesitpose?
Brail:AnAPIisacontractbetweentheAPIproviderandthedeveloper.Anycontracthastoclearlystatewhatmightchangeandhowthedeveloperwillknowaboutthosechanges.InthemostcommonAPIstyletheURI
andverbbasedstylethatmostdevelopersunderstandit'sgenerallyunderstoodthatonceaparticularURI/verbcombinationisoutthere,itwon'tgoawaywithoutalotofnotice,orchangeinanincompatibleway.
Thekeytomakingthiscontractworkisgoodtesting.TodaywehavetoolslikeSwaggerthatletusformallyspecifytheformatofanAPI,andtherearemoreandmoretoolsappearingonthemarketthatcanusethatdatato
testandverifyanAPI.WithoutcontinuoustestingoftheAPIimplementation,it'shardtoguaranteethatthecontractremainsvalid.
Whatarebestpractices,criteriaandconsequencesoferrorsinchoosingdataformats(XML,JSON,etc.)whendesigningandbuildingAPIs?
Brail:Today,Ithinkit'shardtogowrongwithJSON.It'stheeasiestformattocreateandparseinnearlyanylanguagebecauseitissoclosetowhatmostprogramminglanguagesexpect,parsingisreasonablyfast,andit's
readableenough.Ithinkthat95%ofAPIsshouldjuststickwithJSON.
Theother5%,inmind,breaksdownintousecaseswhereextremeperformanceisneeded,andusecaseswherethereareexistingXMLschemasthatrepresentalotofintellectualcapitalthatyouwanttoreuse.Forextreme
performance,seeagainhighspeedtrading.I'mtalkingaboutextremeperformance,notamerefewthousandoftensofthousandsofAPIcallspersecond.ForexistingXMLschemas,seestandardslikeFpML[Financial
ProductsMarkupLanguage]andthelikewherealotofpeoplespendalotoftimetryingtocreateacommonwaytodescribesomeverycomplexthingsinXML.

WhatapproachesshoulddevelopersandarchitectstaketodesignAPIsthataremoreusabletodayandviableinthefuture?
Brail:Therearesomeplaceswherehypermedia[whichextendshypertextlinkingtoincludelinksamonganysetofmultimediaobjects]isveryeffective.IftheAPIproviderandthedevelopersunderstandeachotherwell,and
agreeonaconventionandcontract,thenahypermediadrivenAPIcanbethebasisforarobustandefficientuserexperienceonethatallowstheAPIprovidertoadjustontheflytochangingnetworkandmarketconditions,
inthesamewaythatatraditionalWebappcanbechangedbasedonuseranalytics.Idon'tthinkwe'llseehypermediabasedAPIsreplacetheideaofaverywelldescribedURIpatternforeverythingintheworld,butitthey
becomeaveryeffectivewaytowritemobileapps.
Finally,IthinkthattheideaofmakingamoretraditionalAPI"navigable"byaddinghypermedialinksthatletaclientbrowsetheAPIjustasaWebuserbrowsesawebpage,issomethingthatalotmoreAPIsshouldbe
doingtoday.
30Jun2015
AllRightsReserved,Copyright20012015,TechTarget|ReadourPrivacyStatement

You might also like