Domain Checker API

Examine a domain to confirm that it is not linked to malware, botnet command-and-control (C&C) servers, or hosts involved in spam and phishing activities, which can significantly endanger network assets and data. Our domain databases are categorized using over 20 criteria and are updated hourly, ensuring comprehensive and current results for each query.

How to use?

You need to use the HTTP POST method, sending your data in the form of a JSON object within the body of the request.

POST https://inspector.gridinsoft.com/api/v1/domain/check

Request:

Field Type Description
apikey String Your unique API key that authenticates requests to our services.
domain String The domain you want to check

Example:

You can use various tools or libraries to make this POST request. Here’s how you might typically do it using curl, a command-line tool:

curl -X POST 'https://inspector.gridinsoft.com/api/v1/domain/check' \
    -H 'Content-Type: application/json' \
    -d '{
    "apikey": "YOUR_PRIVATE_APIKEY",
    "domain": "sample-domain.com"
    }'

Response:

Field Type Description
subject String Checked domain
categoryid * Integer Identifier of the assigned category
category * String Assigned category

*If the categoryid and category are not present in the response, this means the domain is considered clean.

For programming languages

Using one of these samples is the easiest way to start using our API. Feel free to add additional functionalities as needed.


import requests

def check_domain(api_key, domain, url):
    headers = {'Content-Type': 'application/json'}
    data = {'apikey': api_key, 'domain': domain}
    try:
        response = requests.post(url, json=data, headers=headers)
        response.raise_for_status()
        return response.json()
    except requests.RequestException as e:
        print(f"Error: {str(e)}")

def main():
    api_key = "YOUR_PRIVATE_APIKEY"  # Your API Key
    input_file = "domains.txt"
    url = "https://inspector.gridinsoft.com/api/v1/domain/check"
    with open(input_file, 'r') as file:
        for domain in file:
            domain = domain.strip()
            if domain:
                result = check_domain(api_key, domain, url)
                if result:
                    output = f"Domain: {domain}, Result: {result.get('subject')} - {result.get('category', 'Good')}"
                    print(output)

if __name__ == "__main__":
    main()


function Check-Domain {
    param(
        [string]$apiKey,
        [string]$domain,
        [string]$url = "https://inspector.gridinsoft.com/api/v1/domain/check"
    )

    $body = @{
        apikey = $apiKey
        domain = $domain
    } | ConvertTo-Json

    $headers = @{
        "Content-Type" = "application/json"
    }

    try {
        $response = Invoke-RestMethod -Method Post -Uri $url -Body $body -Headers $headers
        return $response
    }
    catch {
        if ($_.Exception.Response -ne $null) {
            $streamReader = [System.IO.StreamReader]::new($_.Exception.Response.GetResponseStream())
            $responseBody = $streamReader.ReadToEnd()
            $streamReader.Close()
            $error = ConvertFrom-Json -InputObject $responseBody
            Write-Host "Error: $($error.error)" -ForegroundColor Red
        } else {
            Write-Host "Error: $_" -ForegroundColor Red
        }
        return $null
    }
}

function Main {
    $apiKey = "YOUR_PRIVATE_APIKEY"  # This is your API Key
    $inputFile = "domains.txt"
    $domains = Get-Content -Path $inputFile

    foreach ($domain in $domains) {
        if (-not [string]::IsNullOrWhiteSpace($domain)) {
            $result = Check-Domain -apiKey $apiKey -domain $domain
            if ($result -ne $null) {
                $output = $result.subject
                if ($result.PSObject.Properties.Name -contains "category") {
                    $output += " - " + $result.category
                    Write-Host "Domain: $domain, Result: $output" -ForegroundColor Yellow
                } else {
                    $output += " - Good"
                    Write-Host "Domain: $domain, Result: $output" -ForegroundColor Green
                }
            }
        }
    }
}

Main


async function checkDomain(apiKey, domain) {
    const url = "https://inspector.gridinsoft.com/api/v1/domain/check";
    try {
        const response = await fetch(url, {
            method: 'POST',
            headers: {'Content-Type': 'application/json'},
            body: JSON.stringify({apikey: apiKey, domain: domain})
        });
        if (!response.ok) throw new Error(`HTTP error! Status: ${response.status}`);
        return await response.json();
    } catch (e) {
        console.error(`Error: ${e.message}`);
    }
}

(async function main() {
    const apiKey = "YOUR_PRIVATE_APIKEY";  // Your API key
    const domains = ['example.com', 'anotherdomain.com']; // Your domains list

    for (let domain of domains) {
        const result = await checkDomain(apiKey, domain);
        if (result) {
            const output = `Domain: ${domain}, Result: ${result.subject} - ${result.category || 'Good'}`;
            console.log(output);
        }
    }
})();


import io.ktor.client.*
import io.ktor.client.engine.cio.*
import io.ktor.client.features.*
import io.ktor.client.request.*
import io.ktor.client.response.*
import io.ktor.http.*
import kotlinx.coroutines.*

suspend fun checkDomain(apiKey: String, domain: String, url: String) {
    val client = HttpClient(CIO) {
        install(JsonFeature) {
            serializer = GsonSerializer {
                // Configure Gson if needed
            }
        }
    }

    try {
        val response: HttpResponse = client.post(url) {
            contentType(ContentType.Application.Json)
            body = mapOf("apikey" to apiKey, "domain" to domain)
        }
        if (response.status == HttpStatusCode.OK) {
            val result = response.receive<String>()
            println("Domain: $domain, Result: $result")
        } else {
            println("HTTP request failed with status code ${response.status}")
        }
    } catch (e: Exception) {
        println("Error: ${e.message}")
    } finally {
        client.close()
    }
}

fun main() = runBlocking {
    val apiKey = "YOUR_PRIVATE_APIKEY"
    val url = "https://inspector.gridinsoft.com/api/v1/domain/check"
    File("domains.txt").forEachLine { domain ->
        if (domain.isNotBlank()) {
            checkDomain(apiKey, domain, url)
        }
    }
}

package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "io/ioutil"
    "net/http"
)

type DomainCheck struct {
    ApiKey string `json:"apikey"`
    Domain string `json:"domain"`
}

type Result struct {
    Subject  string `json:"subject"`
    Category string `json:"category,omitempty"`
    CategoryId string `json:"categoryid,omitempty"`
}

func checkDomain(apiKey, domain, url string) (*Result, error) {
    check := DomainCheck{ApiKey: apiKey, Domain: domain}
    body, _ := json.Marshal(check)
    req, err := http.NewRequest("POST", url, bytes.NewBuffer(body))
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        return nil, err
    }
    defer resp.Body.Close()

    result := &Result{}
    data, _ := ioutil.ReadAll(resp.Body)
    if err := json.Unmarshal(data, result); err != nil {
        return nil, err
    }
    return result, nil
}

func main() {
    apiKey := "YOUR_PRIVATE_APIKEY" // Your API key
    url := "https://inspector.gridinsoft.com/api/v1/domain/check"
    domains := []string{"example.com", "anotherdomain.com"} // Your domains list

    for _, domain := range domains {
        result, err := checkDomain(apiKey, domain, url)
        if err != nil {
            fmt.Println("Error:", err)
        } else {
            output := fmt.Sprintf("Domain: %s, Result: %s - %s", domain, result.Subject, result.Category)
            if result.Category == "" {
                output = fmt.Sprintf("Domain: %s, Result: %s - Good", domain, result.Subject)
            }
            fmt.Println(output)
        }
    }
}


#!/bin/bash

api_key="YOUR_PRIVATE_APIKEY"  # Your API Key
input_file="domains.txt"
url="https://inspector.gridinsoft.com/api/v1/domain/check"

while IFS= read -r domain
do
    if [[ -n "$domain" ]]; then
        # Making an HTTP POST request
        response=$(curl -s -X POST -H "Content-Type: application/json" -d "{\"apikey\":\"$api_key\", \"domain\":\"$domain\"}" "$url")
        # Parsing JSON and checking for errors
        if echo "$response" | jq -e .error > /dev/null; then
            echo "Error: $(echo "$response" | jq -r .error)"
        else
            subject=$(echo "$response" | jq -r .subject)
            category=$(echo "$response" | jq -r .category // "Good")
            echo "Domain: $domain, Result: $subject - $category"
        fi
    fi
done < "$input_file"
  • JSON Parsing: The script uses `jq` to parse the JSON response. Make sure `jq` is installed on your system to use this feature.
  • HTTP Status Codes: It captures the HTTP status code to determine whether the request was successful (`200 OK`) or if there was an error. This helps in determining the appropriate action based on the response code.
  • Output Handling: The script now properly separates the response handling and error messages, improving the readability and user experience when interacting with the script.
  • Reading Domains: Domains are read from a text file, making it easy to check multiple domains in one go.

Ruby's standard library includes `net/http`, which is suitable for making HTTP requests.


require 'net/http'
require 'uri'
require 'json'

def check_domain(api_key, domain, url)
    uri = URI.parse(url)
    request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
    request.body = {apikey: api_key, domain: domain}.to_json

    response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") do |http|
        http.request(request)
    end

    if response.is_a?(Net::HTTPSuccess)
        result = JSON.parse(response.body)
        puts "Domain: #{domain}, Result: #{result['subject']} - #{result['category'] || 'Good'}"
    else
        puts "HTTP request failed with status code #{response.code}"
    end
rescue => e
    puts "Error: #{e.message}"
end

api_key = "YOUR_PRIVATE_APIKEY"
url = "https://inspector.gridinsoft.com/api/v1/domain/check"
File.readlines("domains.txt").each do |domain|
    domain.strip!
    check_domain(api_key, domain, url) unless domain.empty?
end

function checkDomain($apiKey, $domain, $url) {
    $ch = curl_init();
    $data = json_encode(['apikey' => $apiKey, 'domain' => $domain]);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);

    $response = curl_exec($ch);
    if (curl_errno($ch)) {
        echo "Error in sending request: " . curl_error($ch);
    } else {
        $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        if ($httpCode == 200) {
            echo "Response: " . $response;
        } else {
            echo "Failed to check domain, HTTP Status Code: " . $httpCode;
        }
    }
    curl_close($ch);
}

// Example usage:
$apiKey = 'YOUR_PRIVATE_APIKEY'; // Your API key
$domain = 'example.com';
$url = 'https://inspector.gridinsoft.com/api/v1/domain/check';
checkDomain($apiKey, $domain, $url);

using System;
using System.IO;
using System.Net.Http;
using System.Text;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Threading.Tasks;

class Program
{
    static HttpClient client = new HttpClient();

    static async Task<Dictionary<string, string>> CheckDomain(string apiKey, string domain, string url)
    {
        var headers = new Dictionary<string, string> {
            {"Content-Type", "application/json"}
        };
        var data = new Dictionary<string, string> {
            {"apikey", apiKey},
            {"domain", domain}
        };

        try
        {
            StringContent content = new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, "application/json");
            HttpResponseMessage response = await client.PostAsync(url, content);
            response.EnsureSuccessStatusCode();
            string responseBody = await response.Content.ReadAsStringAsync();
            return JsonConvert.DeserializeObject<Dictionary<string, string>>(responseBody);
        }
        catch (HttpRequestException e)
        {
            Console.WriteLine($"Error: {e.Message}");
            return null;
        }
    }

    static async Task Main(string[] args)
    {
        string apiKey = "YOUR_PRIVATE_APIKEY"; // Your API Key
        string url = "https://inspector.gridinsoft.com/api/v1/domain/check";
        string inputFilePath = "domains.txt";

        if (!File.Exists(inputFilePath))
        {
            Console.WriteLine("Input file does not exist.");
            return;
        }

        foreach (string domain in File.ReadLines(inputFilePath))
        {
            string trimmedDomain = domain.Trim();
            if (!string.IsNullOrEmpty(trimmedDomain))
            {
                var result = await CheckDomain(apiKey, trimmedDomain, url);
                if (result != null && result.ContainsKey("subject"))
                {
                    string output = $"Domain: {trimmedDomain}, Result: {result["subject"]} - {result.GetValueOrDefault("category", "Good")}";
                    Console.WriteLine(output);
                }
            }
        }
    }
}
  • JsonConvert: Part of the `Newtonsoft.Json` library, used here for serializing the request data to JSON and deserializing the response.
  • Error Handling: `HttpResponseMessage.EnsureSuccessStatusCode` is used to throw an exception if the HTTP response status is an error code. The catch block captures and prints these errors.
  • File Handling: The `System.IO.File.ReadLines` method is used to read each line from the file, treating each line as a domain to check.
  • Reading Domains: Domains are read from a text file, making it easy to check multiple domains in one go.

#include <cpprest/http_client.h>
#include <cpprest/filestream.h>
#include <cpprest/json.h>
#include <iostream>
#include <fstream>
#include <string>

using namespace utility; // Common utilities like string conversions
using namespace web; // Common features like URIs.
using namespace web::http; // Common HTTP functionality
using namespace web::http::client; // HTTP client features

void check_domain(const std::string& api_key, const std::string& domain, const std::string& url) {
    http_client client(U(url));
    json::value postData;
    postData[U("apikey")] = json::value::string(api_key);
    postData[U("domain")] = json::value::string(domain);

    client.request(methods::POST, U(""), postData.serialize(), U("application/json")).then([](http_response response) {
        if (response.status_code() == status_codes::OK) {
            return response.extract_json();
        } else {
            throw std::runtime_error("HTTP request failed with status code " + std::to_string(response.status_code()));
        }
    }).then([](json::value jsonObject) {
        std::wcout << U("Domain: ") << jsonObject[U("domain")].as_string()
                   << U(", Result: ") << jsonObject[U("subject")].as_string()
                   << U(" - ") << jsonObject[U("category")].as_string() << std::endl;
    }).wait();
}

int main() {
    std::string api_key = "YOUR_PRIVATE_APIKEY";
    std::string url = "https://inspector.gridinsoft.com/api/v1/domain/check";
    std::ifstream file("domains.txt");
    std::string domain;

    while (getline(file, domain)) {
        if (!domain.empty()) {
            check_domain(api_key, domain, url);
        }
    }
    file.close();

    return 0;
}


import java.io.*;
import java.net.URI;
import java.net.http.*;
import java.net.http.HttpRequest.BodyPublishers;
import java.net.http.HttpResponse.BodyHandlers;
import org.json.JSONObject;

public class DomainChecker {
    private static final String API_KEY = "YOUR_PRIVATE_APIKEY";  // Your API Key
    private static final String URL = "https://inspector.gridinsoft.com/api/v1/domain/check";

    public static void Check(String apiKey, String domain) {
        try {
            HttpClient client = HttpClient.newHttpClient();
            JSONObject data = new JSONObject();
            data.put("apikey", apiKey);
            data.put("domain", domain);

            HttpRequest request = HttpRequest.newBuilder()
                    .uri(URI.create(URL))
                    .header("Content-Type", "application/json")
                    .POST(BodyPublishers.ofString(data.toString()))
                    .build();

            HttpResponse<String> response = client.send(request, BodyHandlers.ofString());
            JSONObject jsonResponse = new JSONObject(response.body());

            if (jsonResponse.has("error")) {
                System.out.println("Error: " + jsonResponse.getString("error"));
            } else {
                String subject = jsonResponse.optString("subject", "Unknown");
                String category = jsonResponse.optString("category", "Good");
                System.out.println("Domain: " + domain + ", Result: " + subject + " - " + category);
            }
        } catch (Exception e) {
            System.out.println("Error: " + e.getMessage());
        }
    }

    public static void main(String[] args) {
        try (BufferedReader reader = new BufferedReader(new FileReader("domains.txt"))) {
            String domain;
            while ((domain = reader.readLine()) != null) {
                if (!domain.isBlank()) {
                    Check(API_KEY, domain.trim());
                }
            }
        } catch (IOException e) {
            System.out.println("Error reading file: " + e.getMessage());
        }
    }
}

To implement the domain check function in Rust, you can use the `reqwest` crate for making HTTP requests and `serde` for JSON serialization/deserialization.

Before you begin, ensure these crates are added to your `Cargo.toml`:


[dependencies]
reqwest = { version = "0.11", features = ["json"] }
tokio = { version = "1", features = ["full"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"


use reqwest::Client;
use serde::{Deserialize, Serialize};
use serde_json::json;
use std::fs::File;
use std::io::{BufRead, BufReader};
use std::error::Error;

#[derive(Serialize)]
struct DomainCheckRequest {
    apikey: String,
    domain: String,
}

#[derive(Deserialize)]
struct DomainCheckResponse {
    subject: Option<String>,
    category: Option<String>,
}

async fn check_domain(client: &Client, api_key: &str, domain: &str, url: &str) -> Result<(), Box<dyn Error>> {
    let request_body = DomainCheckRequest {
        apikey: api_key.to_string(),
        domain: domain.to_string(),
    };

    let response = client
        .post(url)
        .json(&request_body)
        .send()
        .await?;

    if response.status().is_success() {
        let result = response.json::<DomainCheckResponse>().await?;
        println!("Domain: {}, Result: {} - {}", domain, result.subject.unwrap_or_default(), result.category.unwrap_or("Good".to_string()));
    } else {
        eprintln!("HTTP request failed with status code {}", response.status());
    }

    Ok(())
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    let api_key = "YOUR_PRIVATE_APIKEY";
    let url = "https://inspector.gridinsoft.com/api/v1/domain/check";
    let client = Client::new();

    let file = File::open("domains.txt")?;
    let reader = BufReader::new(file);

    for line in reader.lines() {
        let domain = line?;
        if !domain.trim().is_empty() {
            check_domain(&client, &api_key, &domain, &url).await?;
        }
    }

    Ok(())
}
    
  • Dependencies: Uses `reqwest` for HTTP requests, `tokio` for async runtime, and `serde` for JSON handling.
  • Structs: `DomainCheckRequest` for the request body and `DomainCheckResponse` for parsing the JSON response.
  • Async Functionality: The `check_domain` function is asynchronous, using Tokio's async runtime to handle the HTTP requests concurrently.
  • Error Handling: Proper error handling is implemented, ensuring that any issues during the HTTP request or file operations are reported.
  • Reading Domains: Domains are read from a text file, making it easy to check multiple domains in one go.

import Foundation

struct DomainCheck: Codable {
    let apikey: String
    let domain: String
}

func checkDomain(apiKey: String, domain: String, url: URL, completion: @escaping (Result<String, Error>) -> Void) {
    var request = URLRequest(url: url)
    request.httpMethod = "POST"
    request.addValue("application/json", forHTTPHeaderField: "Content-Type")

    let domainData = DomainCheck(apikey: apiKey, domain: domain)
    do {
        let jsonData = try JSONEncoder().encode(domainData)
        request.httpBody = jsonData
    } catch {
        completion(.failure(error))
        return
    }

    let task = URLSession.shared.dataTask(with: request) { data, response, error in
        guard let data = data, error == nil else {
            completion(.failure(error ?? NSError(domain: "Unknown error", code: -1, userInfo: nil)))
            return
        }

        if let httpResponse = response as? HTTPURLResponse, httpResponse.statusCode != 200 {
            let errorString = "HTTP Error: \(httpResponse.statusCode)"
            completion(.failure(NSError(domain: errorString, code: httpResponse.statusCode, userInfo: nil)))
            return
        }

        do {
            let result = try JSONDecoder().decode(Dictionary<String, String>.self, from: data)
            let output = "Domain: \(domain), Result: \(result["subject"] ?? "Unknown") - \(result["category"] ?? "Good")"
            completion(.success(output))
        } catch {
            completion(.failure(error))
        }
    }
    task.resume()
}

func main() {
    let apiKey = "YOUR_PRIVATE_APIKEY"  // Your API Key
    let urlString = "https://inspector.gridinsoft.com/api/v1/domain/check"
    guard let url = URL(string: urlString) else { return }

    let inputFile = "domains.txt" // This should be the path to your file in a real application
    do {
        let content = try String(contentsOfFile: inputFile, encoding: .utf8)
        let domains = content.split(separator: "\n").map(String.init)

        for domain in domains {
            let trimmedDomain = domain.trimmingCharacters(in: .whitespacesAndNewlines)
            if !trimmedDomain.isEmpty {
                checkDomain(apiKey: apiKey, domain: trimmedDomain, url: url) { result in
                    switch result {
                    case .success(let output):
                        print(output)
                    case .failure(let error):
                        print("Error: \(error)")
                    }
                }
            }
        }
    } catch {
        print("Failed to read from the file: \(error)")
    }
}

// Assuming the 'main' function would be called when you run your Swift application
main()

  • Concurrency: Swift's `URLSession` works asynchronously. The completion handlers allow for processing once the network response is received.
  • Error Handling: The script checks for errors at multiple points: when encoding JSON, sending the request, and decoding the response.
  • File Handling: In this example, the file path is hardcoded as a string. In a real macOS or iOS app, you would handle file paths differently, possibly using `FileManager`.
  • Output: The completion handler allows the function to return results asynchronously. This pattern is useful in GUI applications where blocking the main thread would be detrimental.
  • Reading Domains: Domains are read from a text file, making it easy to check multiple domains in one go.
Ready to get started?
Sign up to try Inspector API
We use cookies. Cookies help us deliver the best experience on our website. By using our website, you agree to the use of cookies.