Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
whoisxmlapi committed Oct 21, 2021
0 parents commit dc8e8cf
Show file tree
Hide file tree
Showing 23 changed files with 1,197 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: "Build"

on: [push, pull_request]

jobs:
build:
name: "Build"
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 tox
pip install -r requirements.txt
- name: Lint with flake8
run: |
flake8 src tests --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 src tests --count --exit-zero --max-line-length=127 --statistics
- name: Test with tox
env:
API_KEY: ${{ secrets.WHOISXMLAPI_API_KEY }}
run: |
tox -e py
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
build
dist
/**/*.egg-info
/**/__pycache__
venv
.env
*.sh
.tox
.idea
5 changes: 5 additions & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

Authors
=======

* WHOIS API, Inc - `whoisxmlapi.com <https://whoisxmlapi.com>`_
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

Changelog
=========

1.0.0 (2021-10-21)
------------------

* First release
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2021 WHOIS API, Inc

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
9 changes: 9 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
graft src
graft tests

include AUTHORS.rst
include CHANGELOG.rst
include LICENSE
include README.rst

global-exclude *.py[cod] __pycache__ *.so *.dylib
183 changes: 183 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
.. image:: https://img.shields.io/badge/License-MIT-green.svg
:alt: website-contacts-py license
:target: https://opensource.org/licenses/MIT

.. image:: https://img.shields.io/pypi/v/dns-lookup-api.svg
:alt: dns-lookup-py release
:target: https://pypi.org/project/dns-lookup-api

.. image:: https://github.com/whois-api-llc/dns-lookup-py/workflows/Build/badge.svg
:alt: dns-lookup-py build
:target: https://github.com/whois-api-llc/dns-lookup-py/actions

========
Overview
========

The client library for
`DNS Lookup API <https://dns-lookup.whoisxmlapi.com/api>`_
in Python language.

The minimum Python version is 3.6.

Installation
============

.. code-block:: shell
pip install dns-lookup-api
Examples
========

Full API documentation available `here <https://dns-lookup.whoisxmlapi.com/api/documentation/making-requests>`_

Create a new client
-------------------

.. code-block:: python
from dnslookupapi import *
client = Client('Your API key')
Make basic requests
-------------------

.. code-block:: python
# 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

.. code-block:: python
result = client.get(
'samsung.com',
'A,MX,NS')
Response model overview
-----------------------

.. code-block:: python
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
---------------

.. code-block:: python
{
'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.'}
]
}
}
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
requests==2.25.1
78 changes: 78 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/usr/bin/env python
# -*- encoding: utf-8 -*-

import io
import re
from glob import glob
from os.path import basename
from os.path import dirname
from os.path import join
from os.path import splitext

from setuptools import find_packages
from setuptools import setup


def read(*names, **kwargs):
return io.open(
join(dirname(__file__), *names),
encoding=kwargs.get('encoding', 'utf8')
).read()


version_content = {}
exec(read('src/dnslookupapi/version.py'), version_content)

setup(
name='dns-lookup-api',
version=version_content['VERSION'],
python_requires='>=3.6',
license='MIT',
description='Python client library for DNS Lookup API.',
long_description='%s\n%s' % (
re.compile('^.. start-badges.*^.. end-badges', re.M | re.S).sub('', read('README.rst')),
re.sub(':[a-z]+:`~?(.*?)`', r'``\1``', read('CHANGELOG.rst'))
),
author='WHOIS API, Inc',
author_email='[email protected]',
url='https://github.com/whois-api-llc/dns-lookup-py',
packages=find_packages('src'),
package_dir={'': 'src'},
py_modules=[splitext(basename(path))[0] for path in glob('src/*.py')],
include_package_data=True,
zip_safe=False,
classifiers=[
# complete classifier list: http://pypi.python.org/pypi?%3Aaction=list_classifiers
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: Unix',
'Operating System :: POSIX',
'Operating System :: Microsoft :: Windows',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Topic :: Utilities',
],
keywords=[
'dns',
'dns api',
'dns lookup',
'dns request',
'api',
'whois',
'whoisxmlapi',
],
install_requires=[
'requests',
],
extras_require={
'dev': [
'tox',
'flake8',
]
}
)
11 changes: 11 additions & 0 deletions src/dnslookupapi/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
__all__ = ['Client', 'ErrorMessage', 'DnsLookupApiError', 'ApiAuthError',
'HttpApiError', 'EmptyApiKeyError', 'ParameterError',
'ResponseError', 'BadRequestError', 'UnparsableApiResponseError',
'ApiRequester', 'Response', 'DnsRecord', 'DnsCaaRecord', 'DnsMxRecord', 'DnsSoaRecord']

from .client import Client
from .net.http import ApiRequester
from .models.response import ErrorMessage, Response, DnsRecord, DnsCaaRecord, DnsMxRecord, DnsSoaRecord
from .exceptions.error import DnsLookupApiError, ParameterError, \
EmptyApiKeyError, ResponseError, UnparsableApiResponseError, \
ApiAuthError, BadRequestError, HttpApiError
Loading

0 comments on commit dc8e8cf

Please sign in to comment.