How can I get AppleScript to run this query and save each value (country, city, etc.) as an AppleScript variable?


I'm trying to get information about IP and domain and set the value of some variables.

I was not sure how to even run the query from AppleScript so I used do shell script to call curl:

set IPAddress to ""
set link to "http://ip-api.com/json/" & IPAddress & "?fields=country,city,isp,org,as,mobile,proxy,message"
set curl_command to "curl " & link

do shell script curl_command

The result is JSON formatted text. Is AppleScript's text delimiter the only option for parsing the result?

  • As a tip, use <!-- language: lang-none --> to turn off syntax highlighting where it's not wanted, such as that URL above.
    – TRiG
    Commented Dec 18, 2017 at 17:51
  • If the below answered your question please accept the answer.
    – ʀ2ᴅ2
    Commented Nov 15, 2018 at 17:27

1 Answer 1


The easiest way is to use JSON Helper app available on the AppStore. Then you simply do something like this:

tell application "JSON Helper"
    set json to fetch JSON from "http://ip-api.com/json/,city,isp,org,as,mobile,proxy,message"
    set countryName to |country| of json
end tell

Result: "United States"

  • Nice utility for free! In the past I've used jq in bash script, but will use this the next time I need to parse JSON. from AppleScript. +1 Commented Dec 18, 2017 at 15:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .