API USAGE

4VIO API is very easy to use. It saves time for dealing with your own code, rather than dealing with API-related issues. All you have to do is determine what you want to do with the answer from the API you are using.

API Addresses and Supported Formats
API API URL Type Sample Output
IP API https://api.4vio.com/ip/v1 text 8.8.8.8
IP API https://api.4vio.com/ip/v1/json json {"ip":"8.8.8.8","ip_country":"US"}
IP API https://api.4vio.com/ip/v1/jsonp jsonp GetIP({"ip":"8.8.8.8","ip_country":"US"});
FDP API https://api.4vio.com/fdp/v1 json -
OSINT API https://api.4vio.com/osint/v1 json -
CTI API https://api.4vio.com/cti/v1 json -
Error Codes
Code Name Explanation
101 Invalid access token The token used for access is incorrect or revoked.
102 Access token has expired Token expired, new token should be get.
103 API permission denied Permission is either not granted or has been removed.
113 Invalid email address Invalid email address.
201 Rate limit exceeded Too many requests sent in a given time.
803 No records found No records found.

CODE SAMPLES

Bash

#!/bin/bash

ip=$(curl -s https://api.4vio.com/ip/v1)
echo "IP: $ip"

C#

using System;
using System.Net;

namespace ipapi.Examples {
    class Program {
        public static void Main (string[] args) {
            WebClient webClient = new WebClient();
            string publicIp = webClient.DownloadString("https://api.4vio.com/ip/v1");
            Console.WriteLine("IP: {0}", publicIp);
        }
    }
}

Go

package main

import (
        "io/ioutil"
        "net/http"
        "os"
)

func main() {
        res, _ := http.Get("https://api.4vio.com/ip/v1")
        ip, _ := ioutil.ReadAll(res.Body)
        os.Stdout.Write(ip)
}

Java

try (java.util.Scanner s = new java.util.Scanner(new java.net.URL("https://api.4vio.com/ip/v1").openStream(), "UTF-8").useDelimiter("\\A")) {
    System.out.println("IP " + s.next());
} catch (java.io.IOException e) {
    e.printStackTrace();
}

Javascript

<script type="application/javascript">
  function GetIP(json) {
    document.write("IP: ", json.ip, " - Country: ", json.ip_country);
  }
</script>

<script type="application/javascript" src="https://api.4vio.com/ip/v1/jsonp"></script>

jQuery

<script type="application/javascript">
  $(function() {
    $.getJSON("https://api.4vio.com/ip/v1/jsonp",
      function(json) {
        document.write("IP: ", json.ip);
      }
    );
  });
</script>

Lisp

;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.4vio.com/ip/v1" :want-stream t)))
  (let ((public-ip (read-line stream)))
    (format t "IP: ~A" public-ip)))

Lua

http.Fetch("https://api.4vio.com/ip/v1", function(body) print("IP: " .. body ) end

Objective-C

NSURL *url = [NSURL URLWithString:@"https://api.4vio.com/ip/v1"];
NSString *ipAddress = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];
NSLog(@"IP: %@", ipAddress);

Scala

val addr = scala.io.Source.fromURL("https://api.4vio.com/ip/v1").mkString
println(s"IP: $addr")

Perl

use strict;
use warnings;
use LWP::UserAgent;

my $ua = new LWP::UserAgent();
my $ip = $ua->get('https://api.4vio.com/ip/v1')->content;
print 'IP: '. $ip;

PHP

<?php
    $ip = file_get_contents('https://api.4vio.com/ip/v1');
    echo "IP: " . $ip;
?>

PowerShell

$ip = Invoke-RestMethod -Uri 'https://api.4vio.com/ip/v1/json'
"IP: $($ip.ip)"

Python

# This example requires the requests library be installed.  You can learn more
# about the Requests library here: http://docs.python-requests.org/en/latest/
from requests import get

ip = get('https://api.4vio.com/ip/v1').text
print('IP: {}'.format(ip))

Ruby

require "net/http"

ip = Net::HTTP.get(URI("https://api.4vio.com/ip/v1"))
puts "IP: " + ip

VB.NET

Dim httpClient As New System.Net.Http.HttpClient
Dim ip As String = Await httpClient.GetStringAsync("https://api.4vio.com/ip/v1")
Console.WriteLine($"IP: {ip}")