-
Notifications
You must be signed in to change notification settings - Fork 2
Basic Account Information
This sample invokes and displays the results of a DomainTools "account information" query via DXL.
See Account Information Documentation for more details.
The majority of the sample code is shown below:
# Create the client
with DxlClient(config) as client:
# Connect to the fabric
client.connect()
logger.info("Connected to DXL fabric.")
request_topic = \
"/opendxl-domaintools/service/domaintools/account_information"
req = Request(request_topic)
res = client.sync_request(req, timeout=30)
if res.message_type != Message.MESSAGE_TYPE_ERROR:
res_dict = MessageUtils.json_payload_to_dict(res)
print("Response in default (json) output format:\n{}".format(
MessageUtils.dict_to_json(res_dict, pretty_print=True)))
else:
print("Error invoking service in json with topic '{}': {} ({})".format(
request_topic, res.error_message, res.error_code))
After connecting to the DXL fabric, a request message is created with a topic that targets the "account information" method of the DomainTools API DXL service.
The next step is to perform a synchronous request via the DXL fabric. If the response message is not an error its contents are displayed. The contents should include account information for the API user that the DomainTools DXL service uses.
From the DomainTools Account Information Documentation:
The Account Information API provides a quick and easy way to get a snapshot of API product usage for an account. Usage is broken down by day and by month.
Note that because the request does not specify a format, the response returned from the client.sync_request call will be in the default DomainTools format, json.
The sample code also demonstrates how to request to receive the response in another format that the DomainTools service supports, xml:
MessageUtils.dict_to_json_payload(req, {"format": "xml"})
res = client.sync_request(req, timeout=30)
if res.message_type != Message.MESSAGE_TYPE_ERROR:
print("Response in xml output format:\n{}".format(
MessageUtils.decode_payload(res)))
else:
print("Error invoking service in xml with topic '{}': {} ({})".format(
request_topic, res.error_message, res.error_code))
In this case, the payload of the request message is set with a format key set to xml. The contents of the raw xml response are decoded and displayed.
The output for the first response, in which the service returned data in json format, should appear similar to the following:
{
"response": {
"account": {
"active": true,
"api_username": "username"
},
"products": [
{
"absolute_limit": null,
"expiration_date": null,
"id": "account-information",
"per_minute_limit": "5",
"per_month_limit": "100000",
"usage": {
"month": "0",
"today": "0"
}
},
{
"absolute_limit": "10000",
"expiration_date": "2017-07-18",
"id": "parsed-whois",
"per_minute_limit": "120",
"per_month_limit": null,
"usage": {
"month": "0",
"today": "0"
}
}
]
}
}
The received results are displayed.
The response output for the request made with xml as the value for the format parameter should appear similar to the following:
<?xml version="1.0"?>
<whoisapi>
<response>
<account>
<api_username>username</api_username>
<active>1</active>
</account>
<products>
<id>account-information</id>
<per_month_limit>100000</per_month_limit>
<per_minute_limit>5</per_minute_limit>
<absolute_limit/>
<usage>
<today>12</today>
<month>202</month>
</usage>
<expiration_date>2017-09-30</expiration_date>
</products>
<products>
<id>parsed-whois</id>
<per_month_limit/>
<per_minute_limit>120</per_minute_limit>
<absolute_limit>10000</absolute_limit>
<usage>
<today>0</today>
<month>4</month>
</usage>
<expiration_date>2017-09-30</expiration_date>
</products>
</response>
</whoisapi>
DomainTools DXL Python Service
Documentation
-
Release Documentation
- (Steps to install, configure, and run the service)
-
Docker Support
- (Steps to run the service in a Docker container)
Service Methods
- Domain
- IP
- Account
- Brand
- Name Server
- PhishEye
- General
- Whois
Examples
- Basic
- Account Information
- Brand Monitor
- Domain Profile
- Domain Search
- Domain Suggestions
- Hosting History
- Host Domains
- IP Monitor
- IP Registrant Monitor
- Iris
- Name Server Monitor
- Parsed Whois
- PhishEye Domain List
- PhishEye Term List
- Registrant Monitor
- Reputation
- Reverse IP
- Reverse IP Whois
- Reverse Name Server
- Reverse Whois
- Whois Lookup
- Whois History