• Intro to AutoHotkey HotStrings with AutoHotkey Intermediate AutoHotkey GUIs are Easy with AutoHotkey Intro to DOS & AutoHotkey

Example Webservice / API call- 4 GoogleMaps API services

Rest API Robot FrameworkGoogleMaps API services

In the following video I work through connecting for four separate APIs which are all under GoogleMaps.  It is very easy to connect to them with AutoHotkey.  Simply get your own token and then adapt the below code to your needs!

If you’re new to API calls, be sure to get our API Syntax Writer

Video reviewing the four GoogleMaps APIs.

GoogleMaps Directions API

GoogleMaps GeoCode API

Example Webservice / API call- Connecting to Zoom & extracting info

Rest API Robot FrameworkAutoHotkey Bottle 3For the the AutoHotkey Webinars we use Zoom which is a great, robust, inexpensive tool for hosting online meetings/webinars.  They have a free version which allows you to connect with people for up to 45 minutes!

Below I walk through the following code where I demonstrate how I extract information about users & their meetings.   This is a great example of how many vendors offer APIs to connect to their tools.

IniRead, API_Token ,Auth.ini,API, Token
IniRead, API_Key   ,Auth.ini,API, Key
IniRead, API_Secret,Auth.ini,API, Secret

;~  EndPoint:="https://api.zoom.us/v1/user/list" ;get list of users under your account
;~  EndPoint:="https://api.zoom.us/v1/meeting/list" ;get list of meetings for a given user
EndPoint:="https://api.zoom.us/v1/meeting/get" ;get specific meeting info
;~  QueryString:=QueryString_Builder({"api_key":API_Key,"api_secret":API_Secret,"data_type":"XML","host_id":"pPzEua3eSDerCD2WO3JbUg"})
QueryString:=QueryString_Builder({"api_key":API_Key,"api_secret":API_Secret,"data_type":"XML","id":"693773857","host_id":"pPzEua3eSDerCD2WO3JbUg"})

;********API call**********************
HTTP := ComObjCreate("WinHttp.WinHttpRequest.5.1") ;Create COM Object
HTTP.Open("POST", EndPoint . QueryString) ;GET & POST are most frequent, Make sure you UPPERCASE
HTTP.Send() ;If POST request put data in "Payload" variable
Response_data:= HTTP.ResponseText ;Save the text that is returned
SciTE_Output(Response_data) ;Text,Clear=1,LineBreak=1,Exit=0

;***********query string builder******************* 
QueryString_Builder(kvp){
for key, value in kvp
  queryString.=((A_Index="1")?(url "?"):("&")) key "=" value
return queryString
}

AutoHotkey Bottle 4Video walking through developing the Zoom API call

Example Webservice / API call- Zillow -Get deep search results

Rest API Robot FrameworkBlack Bottle 2In this review we follow-up on our API webinar showing how to access Real estate / home values through the Zillow API.  Here is the code I walk through in the below video.   This API is pretty straight-foward and easy to use.  It can be a lot of fun to see what your home, and your neighbor’s is worth!

IniRead, API_Token ,Auth.ini,API, Token

QueryString:=QueryString_Builder({"address":"836 Kilbridge Lane","citystatezip":"Coppell,TX","zws-id":API_Token})
;~  QueryString:=QueryString_Builder({"address":"31 Boulevard terrace","citystatezip":"Novato,CA","zws-id":API_Token})
EndPoint:="http://www.zillow.com/webservice/GetDeepSearchResults.htm"

;***********API call to Zillow*******************
    HTTP := ComObjCreate("WinHttp.WinHttpRequest.5.1")
    HTTP.Open("GET", EndPoint . QueryString)
    HTTP.Send()
;~  SciTE_Output(HTTP.ResponseText) ;Text,Clear=1,LineBreak=1,Exit=0
    SciTE_Output(sXML_Pretty(HTTP.ResponseText,"   ")) ;Text,Clear=1,LineBreak=1,Exit=0

;***********Query string builder*******************
QueryString_Builder(kvp){
for key, value in kvp
  queryString.=((A_Index="1")?(url "?"):("&")) key "=" value
return queryString
}

AutoHotkey Bottle 4

Video walking through the API code

 

 

Example Webservice / API call- Yelp and working through oAuth2

Rest API Robot FrameworkBlack Bottle 2In our API webinar we discussed how oAuth2 works however there is no better way to explain it than to actually work through an example!  In the below video & code I demonstrate how to access Yelp to perform the “handshake” with oAuth1 and receive the oAuth2 authentication.  I also demonstrate using a named Regular Expression to isolate the returned token.

;~  https://www.yelp.com/developers/documentation/v3/authentication
ID:="94MAk4OrJa_y7ww5IV7HQg"
Secret:="eaHaNtMp4SbdBLB7aWpReLhe2oGWqeT32cMDG8ksMUc6r4ARA2RmPo7o6y6mG0pS"

EndPoint:="https://api.yelp.com/oauth2/token"
QueryString:=QueryString_Builder({"grant_type":"client_credentials","client_id":ID,"client_secret":Secret})
;***********API call to get Authorization Token*******************
HTTP := ComObjCreate("WinHttp.WinHttpRequest.5.1")
HTTP.Open("POST",EndPoint . QueryString)
HTTP.Send()
data:=HTTP.ResponseText ;~ MsgBox,,title, % response
RegExMatch(data,".*access_token\x22:\s\x22(?<Token>.*?)\x22.*",Yelp_) ;RegEx to grab token
;~  MsgBox % Yelp_token

;~  https://www.yelp.com/developers/v3/manage_app?app_created=True
;~  https://www.yelp.com/developers/documentation/v3/business_search
EndPoint:="https://api.yelp.com/v3/businesses/search"

;~  https://www.yelp.com/developers/documentation/v2/all_category_list
;~  https://www.yelp.com/developers/documentation/v2/all_category_list/categories.json
QueryString:=QueryString_Builder({"term":"restaurants","location":"Coppell, TX","categories":"chicken_wings"})

;***********API call to yelp with Credentials*******************
HTTP := ComObjCreate("WinHttp.WinHttpRequest.5.1")
HTTP.Open("GET", EndPoint . queryString)
HTTP.SetRequestHeader("Authorization","Bearer " . Yelp_token)
HTTP.Send()
Response_Data:=HTTP.ResponseText ;~ MsgBox,,title, % response
Response_Data:=formatjson(Response_Data)
SciTE_Output(Response_Data) ;Text,Clear=1,LineBreak=1,Exit=0


;***********QueryString Builders*******************
QueryString_Builder(kvp){
for key, value in kvp
  queryString.=((A_Index="1")?(url "?"):("&")) key "=" value
return queryString
}

Black Bottle 2Video walking through the API example / oAuth2 process

 

 

 

  • Intro to AutoHotkey HotStrings with AutoHotkey Intermediate AutoHotkey GUIs are Easy with AutoHotkey Intro to DOS & AutoHotkey