Unlocking Domain Insights with the Domains API Cognitive Actions

23 Apr 2025
Unlocking Domain Insights with the Domains API Cognitive Actions

In today’s digital landscape, understanding domain details is crucial for various applications ranging from cybersecurity to digital marketing. The Domains API offers a set of powerful Cognitive Actions that enable developers to seamlessly retrieve WHOIS and RDAP information for any domain. By integrating these pre-built actions, you can access crucial domain data quickly and efficiently, enhancing your application’s capabilities without the need for extensive backend development.

Prerequisites

Before getting started with the Domains API Cognitive Actions, ensure you have the following:

  • An API key for the Cognitive Actions platform.
  • A basic understanding of JSON and HTTP requests.

Authentication typically involves passing your API key in the request headers. This allows you to securely access the actions provided by the API.

Cognitive Actions Overview

Retrieve Domain WHOIS Information

Description:
This action retrieves detailed WHOIS information for a given domain, including availability, registrant data, status, and other specific details. It normalizes fields across TLDs and formats the data for consistency, providing accurate WHOIS data from both the Registry and Registrar.

Category: ip-and-domain

Input:

  • websiteDomain (required): The domain name of the website. Default is 'example.com'.
  • operationMode (optional): Specifies the operation mode of the request. Options include 'detailed', 'standard', or 'cache'.

Example Input:

{
  "operationMode": "detailed",
  "websiteDomain": "example.com"
}

Output:
The action typically returns a structured JSON containing information such as:

  • Nameservers
  • Domain status
  • Registrant details
  • Expiration dates

Example Output:

{
  "domain": "example.com",
  "availability": "registered",
  "registrar": {
    "name": "Cloudflare, Inc.",
    "url": "http://www.cloudflare.com"
  },
  "dates": {
    "created": "2004-10-08T13:53:42Z",
    "expiry": "2032-10-08T13:53:42Z"
  }
}

Conceptual Usage Example (Python):

import requests
import json

COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute"  # Hypothetical endpoint

action_id = "2a34b675-f0d0-4d85-bc35-31847bb0742c"  # Action ID for Retrieve Domain WHOIS Information

payload = {
    "operationMode": "detailed",
    "websiteDomain": "example.com"
}

headers = {
    "Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
    "Content-Type": "application/json"
}

try:
    response = requests.post(
        COGNITIVE_ACTIONS_EXECUTE_URL,
        headers=headers,
        json={"action_id": action_id, "inputs": payload}
    )
    response.raise_for_status()
    result = response.json()
    print("Action executed successfully:")
    print(json.dumps(result, indent=2))

except requests.exceptions.RequestException as e:
    print(f"Error executing action {action_id}: {e}")
    if e.response is not None:
        print(f"Response status: {e.response.status_code}")
        try:
            print(f"Response body: {e.response.json()}")
        except json.JSONDecodeError:
            print(f"Response body: {e.response.text}")

Retrieve WHOIS Data

Description:
Fetch WHOIS data for a given domain name in JSON format, enabling insights into domain ownership, registration, and expiration details.

Category: api-management

Input:

  • domainName (required): The domain name for the request. Defaults to 'example.com'.
  • isRaw (optional): Indicates whether the response should be returned in its raw form. Defaults to false.
  • followCount (optional): The number of redirects to follow during the request. Defaults to 1.

Example Input:

{
  "isRaw": false,
  "domainName": "example.com",
  "followCount": 1
}

Output:
The action returns JSON data that provides:

  • Domain name
  • Expiration date
  • Registrar details
  • Status codes

Example Output:

{
  "domainName": "example.com",
  "Registrar": "RESERVED-Internet Assigned Numbers Authority",
  "Expiry Date": "2025-08-13T04:00:00Z"
}

Conceptual Usage Example (Python):

import requests
import json

COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute"  # Hypothetical endpoint

action_id = "7684d01f-f2c4-46cc-b744-edec6d98c13a"  # Action ID for Retrieve WHOIS Data

payload = {
    "isRaw": false,
    "domainName": "example.com",
    "followCount": 1
}

headers = {
    "Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
    "Content-Type": "application/json"
}

try:
    response = requests.post(
        COGNITIVE_ACTIONS_EXECUTE_URL,
        headers=headers,
        json={"action_id": action_id, "inputs": payload}
    )
    response.raise_for_status()
    result = response.json()
    print("Action executed successfully:")
    print(json.dumps(result, indent=2))

except requests.exceptions.RequestException as e:
    print(f"Error executing action {action_id}: {e}")
    if e.response is not None:
        print(f"Response status: {e.response.status_code}")
        try:
            print(f"Response body: {e.response.json()}")
        except json.JSONDecodeError:
            print(f"Response body: {e.response.text}")

Retrieve Domain RDAP Data

Description:
Fetches comprehensive RDAP (Registration Data Access Protocol) details in JSON format for a specified domain.

Category: ip-and-domain

Input:

  • domain (required): The domain name for which the request is being made. Default is 'example.com'.

Example Input:

{
  "domain": "example.com"
}

Output:
The action returns detailed RDAP data including:

  • Domain lifecycle events
  • Nameserver information
  • Status codes

Example Output:

{
  "ldhName": "example.com",
  "status": [
    "client delete prohibited",
    "client transfer prohibited"
  ],
  "events": [
    {
      "eventDate": "1995-08-14T04:00:00Z",
      "eventAction": "registration"
    }
  ]
}

Conceptual Usage Example (Python):

import requests
import json

COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute"  # Hypothetical endpoint

action_id = "b39621f3-b0b9-4c0b-abc1-968df44f5725"  # Action ID for Retrieve Domain RDAP Data

payload = {
    "domain": "example.com"
}

headers = {
    "Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
    "Content-Type": "application/json"
}

try:
    response = requests.post(
        COGNITIVE_ACTIONS_EXECUTE_URL,
        headers=headers,
        json={"action_id": action_id, "inputs": payload}
    )
    response.raise_for_status()
    result = response.json()
    print("Action executed successfully:")
    print(json.dumps(result, indent=2))

except requests.exceptions.RequestException as e:
    print(f"Error executing action {action_id}: {e}")
    if e.response is not None:
        print(f"Response status: {e.response.status_code}")
        try:
            print(f"Response body: {e.response.json()}")
        except json.JSONDecodeError:
            print(f"Response body: {e.response.text}")

Conclusion

Integrating the Domains API Cognitive Actions into your application can significantly enhance your ability to manage and analyze domain data. Whether you're looking to retrieve WHOIS information, fetch detailed domain insights, or access RDAP data, these actions provide a robust solution that simplifies complex data retrieval. Start exploring the capabilities of the Domains API today and empower your applications with vital domain knowledge!