Skip to main content

Python client library for DNS Lookup API.

Project description

website-contacts-py license dns-lookup-py release dns-lookup-py build

Overview

The client library for DNS Lookup API in Python language.

The minimum Python version is 3.6.

Installation

pip install dns-lookup-api

Examples

Full API documentation available here

Create a new client

from dnslookupapi import *

client = Client('Your API key')

Make basic requests

# Get DNS records for a domain name.
response = client.get('youtube.com')
print(response)
print(response.records_by_type['MX'])

# Get raw API response in XML format
raw_result = client.get_raw('bbc.com',
    output_format=Client.XML_FORMAT)

Advanced usage

Extra request parameters

result = client.get(
    'samsung.com',
    'A,MX,NS')

Response model overview

Response:
    - domain_name: [str]
    - dns_types: str
    - types: [int]
    - dns_records: [DnsRecord]
        - name: str
        - type: int
        - dns_type: str
        - ttl: int
        - value: str
        - raw_text: str
    - meta_description: str
    - meta_title: str
    - records_by_type: { 'dns_type' -> [DnsRecord] }

Sample response

{
'domain_name': 'youtube.com',
'types': '[-1]',
'dns_types': '_all',
'dns_records': [
      {'type': '16', 'dns_type': 'TXT', 'name': 'youtube.com.', 'ttl': '3600',
       'value': 'v=spf1 include:google.com mx -all',
       'raw_text': 'youtube.com.\t\t3600\tIN\tTXT\t"v=spf1 include:google.com mx -all"'},
      {'type': '16', 'dns_type': 'TXT', 'name': 'youtube.com.', 'ttl': '3600',
       'value': 'google-site-verification=QtQWEwHWM8tHiJ4s-jJWzEQrD_fF3luPnpzNDH-Nw-w',
       'raw_text': 'youtube.com.\t\t3600\tIN\tTXT\t"google-site-verification=QtQWEwHWM8tHiJ4s-jJWzEQrD_fF3luPnpzNDH-Nw-w"'},
      {'type': '1', 'dns_type': 'A', 'name': 'youtube.com.', 'ttl': '300',
       'value': '142.250.68.78',
       'raw_text': 'youtube.com.\t\t300\tIN\tA\t142.250.68.78'},
      {'type': '257', 'dns_type': 'CAA', 'name': 'youtube.com.', 'ttl': '21600',
       'value': 'pki.goog',
       'raw_text': 'youtube.com.\t\t21600\tIN\tCAA\t0 issue "pki.goog"',
       'flags': '0', 'tag': 'issue'},
      {'type': '2', 'dns_type': 'NS', 'name': 'youtube.com.', 'ttl': '21600',
       'value': 'ns2.google.com.',
       'raw_text': 'youtube.com.\t\t21600\tIN\tNS\tns2.google.com.'},
      {'type': '2', 'dns_type': 'NS', 'name': 'youtube.com.', 'ttl': '21600',
       'value': 'ns1.google.com.',
       'raw_text': 'youtube.com.\t\t21600\tIN\tNS\tns1.google.com.'},
      {'type': '6', 'dns_type': 'SOA', 'name': 'youtube.com.', 'ttl': '60',
       'value': 'ns1.google.com.',
       'raw_text': 'youtube.com.\t\t60\tIN\tSOA\tns1.google.com. dns-admin.google.com. 404480356 900 900 1800 60',
       'admin': 'dns-admin.google.com.', 'host': 'ns1.google.com.',
       'expire': '1800', 'minimum': '60', 'refresh': '900', 'retry': '900',
       'serial': '404480356'},
      {'type': '28', 'dns_type': 'AAAA', 'name': 'youtube.com.', 'ttl': '300',
       'value': '2607:f8b0:4007:811:0:0:0:200e',
       'raw_text': 'youtube.com.\t\t300\tIN\tAAAA\t2607:f8b0:4007:811:0:0:0:200e'},
      {'type': '15', 'dns_type': 'MX', 'name': 'youtube.com.', 'ttl': '254',
       'value': 'smtp.google.com.',
       'raw_text': 'youtube.com.\t\t254\tIN\tMX\t0 smtp.google.com.',
       'priority': '0', 'host': 'smtp.google.com.'}
                ]

'records_by_type':
  {'TXT': [
          {'type': '16', 'dns_type': 'TXT', 'name': 'youtube.com.', 'ttl': '3600',
           'value': 'v=spf1 include:google.com mx -all',
           'raw_text': 'youtube.com.\t\t3600\tIN\tTXT\t"v=spf1 include:google.com mx -all"'},
          {'type': '16', 'dns_type': 'TXT', 'name': 'youtube.com.', 'ttl': '3600',
           'value': 'google-site-verification=QtQWEwHWM8tHiJ4s-jJWzEQrD_fF3luPnpzNDH-Nw-w',
           'raw_text': 'youtube.com.\t\t3600\tIN\tTXT\t"google-site-verification=QtQWEwHWM8tHiJ4s-jJWzEQrD_fF3luPnpzNDH-Nw-w"'}
          ],
   'A':   [
          {'type': '1', 'dns_type': 'A', 'name': 'youtube.com.', 'ttl': '300',
           'value': '142.250.68.78',
           'raw_text': 'youtube.com.\t\t300\tIN\tA\t142.250.68.78'}
          ],
   'CAA': [
          {'type': '257', 'dns_type': 'CAA', 'name': 'youtube.com.', 'ttl': '21600',
           'value': 'pki.goog',
           'raw_text': 'youtube.com.\t\t21600\tIN\tCAA\t0 issue "pki.goog"',
           'flags': '0', 'tag': 'issue'}
          ],
   'NS':  [
          {'type': '2', 'dns_type': 'NS', 'name': 'youtube.com.', 'ttl': '21600',
           'value': 'ns2.google.com.',
           'raw_text': 'youtube.com.\t\t21600\tIN\tNS\tns2.google.com.'},
          {'type': '2', 'dns_type': 'NS', 'name': 'youtube.com.', 'ttl': '21600',
           'value': 'ns1.google.com.',
           'raw_text': 'youtube.com.\t\t21600\tIN\tNS\tns1.google.com.'}
          ],
   'SOA': [
          {'type': '6', 'dns_type': 'SOA', 'name': 'youtube.com.', 'ttl': '60',
           'value': 'ns1.google.com.',
           'raw_text': 'youtube.com.\t\t60\tIN\tSOA\tns1.google.com. dns-admin.google.com. 404480356 900 900 1800 60',
           'admin': 'dns-admin.google.com.', 'host': 'ns1.google.com.',
           'expire': '1800', 'minimum': '60', 'refresh': '900',
           'retry': '900', 'serial': '404480356'}
          ],
   'AAAA': [
          {'type': '28', 'dns_type': 'AAAA', 'name': 'youtube.com.', 'ttl': '300',
           'value': '2607:f8b0:4007:811:0:0:0:200e',
           'raw_text': 'youtube.com.\t\t300\tIN\tAAAA\t2607:f8b0:4007:811:0:0:0:200e'}
           ],
   'MX':  [
          {'type': '15', 'dns_type': 'MX', 'name': 'youtube.com.', 'ttl': '254',
           'value': 'smtp.google.com.',
           'raw_text': 'youtube.com.\t\t254\tIN\tMX\t0 smtp.google.com.',
           'priority': '0',
           'host': 'smtp.google.com.'}
          ]
  }
}

Changelog

1.0.0 (2021-10-21)

  • First release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dns-lookup-api-1.0.0.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

dns_lookup_api-1.0.0-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file dns-lookup-api-1.0.0.tar.gz.

File metadata

  • Download URL: dns-lookup-api-1.0.0.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for dns-lookup-api-1.0.0.tar.gz
Algorithm Hash digest
SHA256 a7f4605ec100f1a6d736105cbc754f07a35dee2aa783228e61fc0db445d84392
MD5 052c393f872b619f07e0c206c1d457bf
BLAKE2b-256 75b448654dbd918efece1756ba1a1c2a2127a4598cbd96790f9ca353b740f976

See more details on using hashes here.

File details

Details for the file dns_lookup_api-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: dns_lookup_api-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for dns_lookup_api-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a1da4919778ea4eec665ea35e5e6b13883e2b2621b58a35a616fce33fe11e018
MD5 97746d69b7e8696fb7b781796b41daa2
BLAKE2b-256 f780b74d8f474880e9864e7967ae08afc047be4f8c8e97e9dd31912859b9b730

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page