#!/bin/bash
​
country = $( curl -s https://api.ipdata.co/country_name?api-key = test )
echo "My country is: $country "
NGS (Next Generation Shell) country = ` curl -s https://api.ipdata.co/country_name?api-key = test `
echo ( "My country is: $country " )
from requests import get
​
country = get ( 'https://api.ipdata.co/country_name?api-key=test' ) . text
print ( 'My country is: {}' . format ( country ) )
require "net/http"
​
country = Net : : HTTP . get ( URI ( "https://api.ipdata.co/country_name?api-key=test" ) )
puts "My country is: " + country
<?php
$country = file_get_contents ( 'https://api.ipdata.co/country_name?api-key=test' ) ;
echo "My country is: " . $country ;
?>
try ( java . util . Scanner s = new java . util . Scanner ( new java . net . URL ( "https://api.ipdata.co/country_name?api-key=test" ) . openStream ( ) , "UTF-8" ) . useDelimiter ( "\\A" ) ) {
System . out . println ( "My current country is " + s . next ( ) ) ;
} catch ( java . io . IOException e ) {
e . printStackTrace ( ) ;
}
use strict ;
use warnings ;
use LWP : : UserAgent ;
​
my $ua = new LWP : : UserAgent ( ) ;
my $country = $ua -> get ( 'https://api.ipdata.co/country_name?api-key=test' ) -> content ;
print 'My country is: ' . $country ;
var httpClient = new HttpClient();
var country = await httpClient.GetStringAsync("https://api.ipdata.co/country_name?api-key=test");
Console.WriteLine($"My country is: {country}");
Dim httpClient As New System.Net.Http.HttpClient
Dim country As String = Await httpClient.GetStringAsync("https://api.ipdata.co/country_name?api-key=test")
Console.WriteLine($"My country is: {country}")
var http = require ( 'http' ) ;
​
http . get ( { 'host' : 'api.ipdata.co?api-key=test' , 'port' : 80 , 'path' : '/' } , function ( resp ) {
resp . on ( 'data' , function ( ip ) {
console . log ( "My country is: " + country ) ;
} ) ;
} ) ;
package main
​
import (
"io/ioutil"
"net/http"
"os"
)
​
func main ( ) {
res , _ := http . Get ( "https://api.ipdata.co/country_name?api-key=test" )
country , _ := ioutil . ReadAll ( res . Body )
os . Stdout . Write ( country )
}
(require net/url)
​
(define country (port->string (get-pure-port (string->url "https://api.ipdata.co/country_name?api-key=test"))))
(printf "My country is: ~a" country)
;This example requires the drakma http package installed.
;It can be found here: http://www.weitz.de/drakma
​
(let ((stream
(drakma:http-request "https://api.ipdata.co/country_name?api-key=test" :want-stream t)))
(let ((public-ip (read-line stream)))
(format t "My country is: ~A" public-country)))
Dim s As New HTTPSecureSocket
Dim t As String = s.Get("https://api.ipdata.co/country_name?api-key=test",10)
MsgBox "My country is: " + t
Scala
val country = scala.io.Source.fromURL("https://api.ipdata.co/country_name?api-key=test").mkString
println(s"My country is: $country")
< script type = "application/javascript" >
function getIP ( json ) {
document . write ( "My country is: " , json . country ) ;
}
< / script >
​
< script type = "application/javascript" src = "https://api.ipdata.co/country_name?api-key=test?format=jsonp&callback=getCountry" > < / script >
< script type = "application/javascript" >
$ ( function ( ) {
$ . getJSON ( "https://api.ipdata.co/country_name?api-key=test?format=jsonp&callback=?" ,
function ( json ) {
document . write ( "My country is: " , json . country ) ;
}
) ;
} ) ;
< / script >
using System ;
using System . Net ;
​
namespace Ipdata . Examples {
class Program {
public static void Main ( string [ ] args ) {
WebClient webClient = new WebClient ( ) ;
string publicCountry = webClient . DownloadString ( "https://api.ipdata.co/country_name?api-key=test" ) ;
Console . WriteLine ( "My country is: {0}" , publicCountry ) ;
}
}
}
:inets . start
{ :ok , { _ , _ , inet_addr } } = :httpc . request ( 'http://api.ipdata.co?api-key=test' )
:inets . stop
nim
import HttpClient
var country = newHttpClient ( ) . getContent ( "https://api.ipdata.co/country_name?api-key=test" )
echo ( "My country is: " , country )
$response = Invoke-RestMethod -Uri 'https://api.ipdata.co?api-key=test'
"My country is: $( $response.country_name ) "
http . Fetch ( "https://api.ipdata.co/country_name?api-key=test" , function ( body ) print ( "My country is: " .. body ) end
InitNetwork()
*Buffer = ReceiveHTTPMemory("https://api.ipdata.co/?api-key=test")
If *Buffer
ParseJSON(0, PeekS(*Buffer, MemorySize(*Buffer), #PB_UTF8))
FreeMemory(*Buffer)
Debug GetJSONString(GetJSONMember(JSONValue(0), "country_name"))
EndIf
put "My country is" && url "https://api.ipdata.co/country_name?api-key=test"
Objective-C
NSURL *url = [NSURL URLWithString:@"https://api.ipdata.co/country_name?api-key=test/"];
NSString *country = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];
NSLog(@"My country is: %@", country);
if (client.connect("api.ipdata.co?api-key=test", 80)) {
Serial.println("connected");
client.println("GET / HTTP/1.0");
client.println("Host: api.ipdata.co/country_name?api-key=test");
client.println();
} else {
Serial.println("connection failed");
}