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.
main.js
index.html
1
$.get("https://api.ipdata.co?api-key=test", function (response) {
2
$("#response").html(JSON.stringify(response, null, 4));
3
}, "jsonp");
Copied!
1
<pre id="response"></pre>
Copied!
Example Request
1
curl https://api.ipdata.co?api-key=test&callback=logResults
Copied!
Sample Response
1
logResults({
2
"ip": "3.3.3.3",
3
"is_eu": false,
4
"city": "Seattle",
5
"region": "Washington",
6
"region_code": "WA",
7
"country_name": "United States",
8
"country_code": "US",
9
"continent_name": "North America",
10
"continent_code": "NA",
11
"latitude": 47.6348,
12
"longitude": -122.3451,
13
"asn": "",
14
"organisation": "",
15
"postal": "98109",
16
"calling_code": "1",
17
"flag": "https://ipdata.co/flags/us.png",
18
"emoji_flag": "\ud83c\uddfa\ud83c\uddf8",
19
"emoji_unicode": "U+1F1FA U+1F1F8",
20
"languages": [
21
{
22
"name": "English",
23
"native": "English"
24
}
25
],
26
"currency": {
27
"name": "US Dollar",
28
"code": "USD",
29
"symbol": "quot;,
30
"native": "quot;,
31
"plural": "US dollars"
32
},
33
"time_zone": {
34
"name": "America/Los_Angeles",
35
"abbr": "PDT",
36
"offset": "-0700",
37
"is_dst": true,
38
"current_time": "2019-03-27T02:54:53.576652-07:00"
39
},
40
"threat": {
41
"is_tor": false,
42
"is_proxy": false,
43
"is_anonymous": false,
44
"is_known_attacker": false,
45
"is_known_abuser": false,
46
"is_threat": false,
47
"is_bogon": false
48
},
49
"count": "1503"
50
})
Copied!
Last modified 2yr ago
Copy link