API documentation

Our API usage is pretty simple!

You need to generate an API key from your Dashboard

[POST] https://api.ip.onl/api/webservice/action/query

Headers:

  • api-key: Your API key

Body:

  • ip: User's IP Address
  • format: Response format: json, xml or yaml - Default: json
  • type: Response type: short or full
  • user-agent: User's user agent

Examples

JS
const axios = require("axios");
  const qs = require("qs");

  // Your payload
  let data = qs.stringify({
    ip: ip, // User's IP Address
    format: format, // Response format: json, xml or yaml  -  Default: json
    type: type, // short or full
  });

  const YOUR_API_KEY = "";

  let config = {
    method: "POST",
    url: "https://api.ip.onl/api/webservice/action/query",
    headers: {
      "api-key": YOUR_API_KEY,
      "Content-Type": "application/x-www-form-urlencoded",
    },
    data: data,
  };

  axios
    .request(config)
    .then((response) => {
      console.log(JSON.stringify(response.data));
    })
    .catch((error) => {
      console.log(error);
    });
    
Python
import requests

  # Your payload
  payload = { 
    'ip': 'ip', # User's IP Address
    'format': 'format', # Response format: json, xml or yaml  -  Default: json
    'type': 'type', # short or full
  }

  YOUR_API_KEY = ""

  url = "https://api.ip.onl/api/webservice/action/query"

  headers = {
    'api-key': YOUR_API_KEY,
    'Content-Type': 'application/x-www-form-urlencoded'
  }

  response = requests.request("POST", url, headers=headers, data=payload)

  print(response.text)
  
PHP
<?php

  # Your payload
    $post_data = [
        'ip' => $ip, # User's IP Address
        'format' => $format, # Response format: json, xml or yaml  -  Default: json
        'type' => $type, # short or full
    ];

    $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => 'https://api.ip.onl/api/webservice/action/query',
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_MAXREDIRS => 1,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_FOLLOWLOCATION => true,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => 'POST',
      CURLOPT_POSTFIELDS => http_build_query($post_data),
      CURLOPT_HTTPHEADER => array(
        'api-key: ' . $YOUR_API_KEY,
        'Content-Type: application/x-www-form-urlencoded'
      ),
    ));

    $response = curl_exec($curl);

    curl_close($curl);
    
    echo $response;

  ?>