Basic Host Domains Example¶
This sample invokes and displays the results of a DomainTools "Host Domains" via DXL.
- For more information see:
- https://www.domaintools.com/resources/api-documentation/reverse-ip/
Prerequisites¶
- The samples configuration step has been completed (see Samples Configuration)
- The DomainTools API DXL service is running (see DomainTools API DXL Service)
Running¶
To run this sample execute the sample/basic/basic_host_domains_example.py
script as follows:
python sample/basic/basic_host_domains_example.py
The output should appear similar to the following:
{ "response": { "ip_addresses": { "domain_count": 1, "domain_names": [ "DAILYCHANGES.COM" ], "ip_address": "64.246.165.240" } } }
The received results are displayed.
Details¶
The majority of the sample code is shown below:
# Create the client with DxlClient(config) as dxl_client: # Connect to the fabric dxl_client.connect() logger.info("Connected to DXL fabric.") # Create client wrapper client = DomainToolsApiClient(dxl_client) # Invoke 'host domains' method on service resp_dict = client.host_domains("64.246.165.240") # Print out the response (convert dictionary to JSON for pretty printing) print("Response:\n{}".format( MessageUtils.dict_to_json(resp_dict, pretty_print=True)))
Once a connection is established to the DXL fabric, a
dxldomaintoolsclient.client.DomainToolsApiClient
instance is created
which will be used to invoke remote commands on the DomainTools API DXL
service.
Next, the
dxldomaintoolsclient.client.DomainToolsApiClient.host_domains()
method is invoked with a domain name.
The final step is to display the contents of the returned dictionary (dict
)
which contains the results of the host domains query.
From the DomainTools Host Domains documentation:
"The Reverse IP API provides a list of domain names that share the same Internet host (i.e. the same IP address). You can request an IP address directly, or you can provide a domain name; if you provide a domain name, the API will respond with the list of other domains that share the same IP."