JSONP
Simply set a "callback" query parameter with your function name in your request.
With JQuery
Here you do not have to explicitly pass in the callback parameter as JQuery passes the entire API response into an anonymous function.
$.get("https://api.ipdata.co?api-key=<<apiKey>>", function (response) {
$("#response").html(JSON.stringify(response, null, 4));
}, "jsonp");
<pre id="response"></pre>
Example Request
curl https://api.ipdata.co?api-key=<<apiKey>>&callback=logResults
Sample Response
logResults({
"ip": "3.3.3.3",
"is_eu": false,
"city": "Seattle",
"region": "Washington",
"region_code": "WA",
"country_name": "United States",
"country_code": "US",
"continent_name": "North America",
"continent_code": "NA",
"latitude": 47.6348,
"longitude": -122.3451,
"asn": "",
"organisation": "",
"postal": "98109",
"calling_code": "1",
"flag": "https://ipdata.co/flags/us.png",
"emoji_flag": "\ud83c\uddfa\ud83c\uddf8",
"emoji_unicode": "U+1F1FA U+1F1F8",
"languages": [
{
"name": "English",
"native": "English"
}
],
"currency": {
"name": "US Dollar",
"code": "USD",
"symbol": "$",
"native": "$",
"plural": "US dollars"
},
"time_zone": {
"name": "America/Los_Angeles",
"abbr": "PDT",
"offset": "-0700",
"is_dst": true,
"current_time": "2019-03-27T02:54:53.576652-07:00"
},
"threat": {
"is_tor": false,
"is_proxy": false,
"is_anonymous": false,
"is_known_attacker": false,
"is_known_abuser": false,
"is_threat": false,
"is_bogon": false
},
"count": "1503"
})
Updated over 2 years ago