choose json for building apis
DESCRIPTION
dTRANSCRIPT
-
SearchSOA.com
ChooseJSONforbuildingAPIs
Bynull
Moreandmore,developerswhoareusedtoworkingintheWebandmobileworldsnaturallyturntoAPIsasthemosteffectivewaytoconnectclientsandservers,accordingto
GregBrail.Asthesedevelopersencounterapplicationtoapplicationproblemslikebusinesstobusinessconnectionsbetweenenterprises,theirfirstreactionis,"Whycan'twejustuseanAPIhere?"
BrailanswersthatAPIversusmiddlewarequestionandcomparesAPIbasedintegrationtoSOAandenterpriseservicebusses(ESBs)approachesinthisSearchSOAinterview.HealsooffersadviceonsuchAPImattersaschangemanagement,XMLvs.JSONdataformatsandusesforhypermedia.
CoauthoroftheO'Reillybook,APIs:AStrategyGuide,Brailhasalonghistoryinmiddlewaredevelopment.HebuiltmiddlewarelibrariesforCitibankandwasprincipalarchitectfortransactplustechnicalleadforBEAsWebLogicJMS.AtApigee,anAPIandmiddlewarebackendasaserviceprovider,heisthearchitectureleadforallproducts.
WhenandwhyshouldAPIsreplaceintegrationmiddleware?
GregBrail:JustasAPIsarefastenoughforthemostdemandingmobileapplications,andsecureenoughforimportantconsumerfocusedusecases,thereisnoreasonwhytheycannotbethedefaultchoiceforintegrationtasksaswell.ThereisverylittlereasontouseamoretraditionalapplicationtoapplicationprotocolorintegrationtechnologywhenanAPIcanbeusedinstead.
Exceptions,Ithink,arefewerandfartherbetweenthanpeoplethink.Agoodexamplewouldbeapplicationslikehighfrequencyfinancialtrading,wherethethroughputandlatencydemandsaresoextremethatevenTCP,letaloneHTTP,isjusttooslow.
Evenwheremoretypicalenterprisetechnologylikemessagequeuingandpublish/subscribeisused,inmanycases,wrappingthemessagingsystemwithanAPImakesiteasiertoconsume.
HowdoAPIsasanintegrationapproachcomparetoSOAandESBs?Brail:SOAisaboutconnectingserviceswithintheenterprisetoachievereuseandsavemoney.APIsbuilduponSOAbyemphasizingdeveloperusabilityandselfservice,andaboutcreatingnewservicesthatcanbeusedbothinsidetheenterpriseaswellasbycustomers,partners,anddevelopers.SOAdidn'tdomuchtoenablethosekindsofusecases.
ESBssolvepartoftheAPIintegrationandSOAproblem,butAPIsarealotmore.Forinstance,ESBsdonothingtomakeiteasierfordeveloperstoconsumeAPIsviaselfservice,andtheydonothingtomakeanexistingsystemofrecordsafeformobileuseontheInternetbymanaginghightrafficvolumesandprovidingadvancedsecurityandthreatdetection.
OurreaderstellusthatchangemanagementisapainpointinAPImanagement.Whatprocessandtechnicalproblemsdoesitpose?
Brail:AnAPIisacontractbetweentheAPIproviderandthedeveloper.Anycontracthastoclearlystatewhatmightchangeandhowthedeveloperwillknowaboutthosechanges.InthemostcommonAPIstyletheURIandverbbasedstylethatmostdevelopersunderstandit'sgenerallyunderstoodthatonceaparticularURI/verbcombinationisoutthere,itwon'tgoawaywithoutalotofnotice,orchangeinanincompatibleway.
Thekeytomakingthiscontractworkisgoodtesting.TodaywehavetoolslikeSwaggerthatletusformallyspecifytheformatofanAPI,andtherearemoreandmoretoolsappearingonthemarketthatcanusethatdatatotestandverifyanAPI.WithoutcontinuoustestingoftheAPIimplementation,it'shardtoguaranteethatthecontractremainsvalid.
Whatarebestpractices,criteriaandconsequencesoferrorsinchoosingdataformats(XML,JSON,etc.)whendesigningandbuildingAPIs?Brail:Today,Ithinkit'shardtogowrongwithJSON.It'stheeasiestformattocreateandparseinnearlyanylanguagebecauseitissoclosetowhatmostprogramminglanguagesexpect,parsingisreasonablyfast,andit'sreadableenough.Ithinkthat95%ofAPIsshouldjuststickwithJSON.
Theother5%,inmind,breaksdownintousecaseswhereextremeperformanceisneeded,andusecaseswherethereareexistingXMLschemasthatrepresentalotofintellectualcapitalthatyouwanttoreuse.Forextremeperformance,seeagainhighspeedtrading.I'mtalkingaboutextremeperformance,notamerefewthousandoftensofthousandsofAPIcallspersecond.ForexistingXMLschemas,seestandardslikeFpML[FinancialProductsMarkupLanguage]andthelikewherealotofpeoplespendalotoftimetryingtocreateacommonwaytodescribesomeverycomplexthingsinXML.
http://searchwindevelopment.techtarget.com/definition/JSON-Javascript-Object-Notationhttps://apigee.com/about/http://shop.oreilly.com/product/0636920021223.dohttp://searchexchange.techtarget.com/definition/application-program-interfacehttp://searchsoa.techtarget.com/definition/enterprise-service-bushttp://searchsoa.techtarget.com/definition/XMLhttp://searchcio.techtarget.com/definition/change-managementhttp://whatis.techtarget.com/definition/FpML-Financial-Products-Markup-Languagehttp://searchsoa.techtarget.com/definition/service-oriented-architecturehttp://searchsoa.techtarget.com/tip/API-design-How-to-properly-build-an-application-program-interface -
WhatapproachesshoulddevelopersandarchitectstaketodesignAPIsthataremoreusabletodayandviableinthefuture?Brail:Therearesomeplaceswherehypermedia[whichextendshypertextlinkingtoincludelinksamonganysetofmultimediaobjects]isveryeffective.IftheAPIproviderandthedevelopersunderstandeachotherwell,andagreeonaconventionandcontract,thenahypermediadrivenAPIcanbethebasisforarobustandefficientuserexperienceonethatallowstheAPIprovidertoadjustontheflytochangingnetworkandmarketconditions,inthesamewaythatatraditionalWebappcanbechangedbasedonuseranalytics.Idon'tthinkwe'llseehypermediabasedAPIsreplacetheideaofaverywelldescribedURIpatternforeverythingintheworld,butittheybecomeaveryeffectivewaytowritemobileapps.
Finally,IthinkthattheideaofmakingamoretraditionalAPI"navigable"byaddinghypermedialinksthatletaclientbrowsetheAPIjustasaWebuserbrowsesawebpage,issomethingthatalotmoreAPIsshouldbedoingtoday.
30Jun2015
AllRightsReserved,Copyright20012015,TechTarget|ReadourPrivacyStatement
http://searchsoa.techtarget.com/about/copyrighthttp://www.techtarget.com/html/privacy_policy.htmlhttp://searchsoa.techtarget.com/definition/hypermedia