While we touched on this API in our API Webinar, I wanted to review a bit more and demonstrate the Yahoo Console which can greatly aide you in developing your API calls. Below is the code I demonstrate in the video. The Yahoo API is pretty straight-forward and, for many calls, you don’t need a secure Token or ID!
queryString:=QueryString_Builder({"q":"select * from local.search where zip='75019' and query='hot dogs'","format":"json"}) ;~ MsgBox % queryString EndPoint:="https://query.yahooapis.com/v1/public/yql" ;***********API call******************* HTTP := ComObjCreate("WinHttp.WinHttpRequest.5.1") HTTP.Open("GET", EndPoint . queryString) ;GET or POST most common; Uppercase matters! HTTP.Send() Response_Data:=HTTP.ResponseText SciTE_Output(Response_Data) ;Text,Clear=1,LineBreak=1,Exit=0 ;~ SciTE_Output(sXML_Pretty(Response_data," ")) ;Text,Clear=1,LineBreak=1,Exit=0 return QueryString_Builder(kvp){ for key, value in kvp queryString.=((A_Index="1")?(url "?"):("&")) key "=" value return queryString }
Video demonstrating Example API call to Yahoo