domaintools-api-test-upload


Namedomaintools-api-test-upload JSON
Version 2.2.0 PyPI version JSON
download
home_pageNone
SummaryDomainTools Official Python API
upload_time2024-12-18 20:02:23
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseThe MIT License (MIT) Copyright (c) 2016 DomainTools 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.
keywords python python3
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            ![domaintools](https://github.com/DomainTools/python_api/raw/main/artwork/logo.png)
===================

[![PyPI version](https://badge.fury.io/py/domaintools_api.svg)](http://badge.fury.io/py/domaintools_api)
[![CI Status](https://github.com/domaintools/python_api/workflows/Tests/badge.svg)](https://github.com/domaintools/python_api/actions)
[![Coverage Status](https://coveralls.io/repos/github/DomainTools/python_api/badge.svg?branch=main)](https://coveralls.io/github/DomainTools/python_api?branch=main)
[![License](https://img.shields.io/github/license/mashape/apistatus.svg)](https://pypi.python.org/pypi/domaintools_api/)

DomainTools Official Python API

![domaintools Example](https://github.com/DomainTools/python_api/raw/main/artwork/example.gif)

The DomainTools Python API Wrapper provides an interface to work with our cybersecurity and related data tools provided by our Iris Investigate™, Iris Enrich™, and Iris Detect™ products. It is actively maintained and may be downloaded via <a href="https://github.com/DomainTools/python_api">GitHub</a> or <a href="https://pypi.org/project/domaintools-api/">PyPI</a>. See the included README file, the examples folder, and API documentation (https://app.swaggerhub.com/apis-docs/DomainToolsLLC/DomainTools_APIs/1.0#) for more info.

Installing the DomainTools API
===================

To install the API run

```bash
pip install domaintools_api --upgrade
```

Ideally, within a virtual environment.


Using the API
===================

To start out create an instance of the API - passing in your credentials

```python

from domaintools import API


api = API(USER_NAME, KEY)
```

Every API endpoint is then exposed as a method on the API object, with any parameters that should be passed into that endpoint
being passed in as method arguments:

```python
api.iris_enrich('domaintools.com')
```

You can get an overview of every endpoint that you can interact with using the builtin help function:

```python
help(api)
```

Or if you know the endpoint you want to use, you can get more information about it:

```python
help(api.iris_investigate)
```

If applicable, native Python looping can be used directly to loop through any results:

```python
for result in api.iris_enrich('domaintools.com').response().get('results', {}):
    print(result['domain'])
```

You can also use a context manager to ensure processing on the results only occurs if the request is successfully made:

```python
with api.iris_enrich('domaintools.com').response().get('results', {}) as results:
    print(results)
```

For API calls where a single item is expected to be returned, you can directly interact with the result:

```python
profile = api.domain_profile('google.com')
title = profile['website_data']['title']
```

For any API call where a single type of data is expected you can directly cast to the desired type:

```python
float(api.reputation('google.com')) == 0.0
int(api.reputation('google.com')) == 0
```

The entire structure returned from DomainTools can be retrieved by doing `.data()` while just the actionable response information
can be retrieved by doing `.response()`:

```python
api.iris_enrich('domaintools.com').data() == {'response': { ... }}
api.iris_enrich('domaintools.com').response() == { ... }
```

You can directly get the html, xml, or json version of the response by calling `.(html|xml|json)()` These only work with non AsyncResults:
```python
json = str(api.domain_search('google').json())
xml = str(api.domain_search('google').xml())
html = str(api.domain_search('google').html())
```

If any API call is unsuccesfull, one of the exceptions defined in `domaintools.exceptions` will be raised:

```python-traceback
api.domain_profile('notvalid').data()


---------------------------------------------------------------------------
BadRequestException                       Traceback (most recent call last)
<ipython-input-3-f9e22e2cf09d> in <module>()
----> 1 api.domain_profile('google').data()

/home/tcrosley/projects/external/python_api/venv/lib/python3.5/site-packages/domaintools-0.0.1-py3.5.egg/domaintools/base_results.py in data(self)
     25                 self.api._request_session = Session()
     26             results = self.api._request_session.get(self.url, params=self.kwargs)
---> 27             self.status = results.status_code
     28             if self.kwargs.get('format', 'json') == 'json':
     29                 self._data = results.json()

/home/tcrosley/projects/external/python_api/venv/lib/python3.5/site-packages/domaintools-0.0.1-py3.5.egg/domaintools/base_results.py in status(self, code)
     44
     45         elif code == 400:
---> 46             raise BadRequestException()
     47         elif code == 403:
     48             raise NotAuthorizedException()

BadRequestException:

```

the exception will contain the status code and the reason for the exception:

```python
try:
    api.domain_profile('notvalid').data()
except Exception as e:
    assert e.code == 400
    assert 'We could not understand your request' in e.reason['error']['message']
```

You can get the status code of a response outside of exception handling by doing `.status`:

```python

api.domain_profile('google.com').status == 200
```

Using the API Asynchronously
===================

![domaintools Async Example](https://github.com/DomainTools/python_api/raw/main/artwork/example_async.gif)

The DomainTools API automatically supports async usage:

```python

search_results = await api.iris_enrich('domaintools.com').response().get('results', {})
```

There is built-in support for async context managers:

```python
async with api.iris_enrich('domaintools.com').response().get('results', {}) as search_results:
    # do things
```

And direct async for loops:

```python
async for result in api.iris_enrich('domaintools.com').response().get('results', {}):
    print(result)
```

All async operations can safely be intermixed with non async ones - with optimal performance achieved if the async call is done first:
```python
profile = api.domain_profile('google.com')
await profile
title = profile['website_data']['title']
```

Interacting with the API via the command line client
===================

![domaintools CLI Example](https://github.com/DomainTools/python_api/raw/main/artwork/example_cli.gif)

Immediately after installing `domaintools_api` with pip, a `domaintools` command line client will become available to you:

```bash
domaintools --help
```

To use - simply pass in the api_call you would like to make along with the parameters that it takes and your credentials:

```bash
domaintools iris_investigate --domains domaintools.com -u $TEST_USER -k $TEST_KEY
```

Optionally, you can specify the desired format (html, xml, json, or list) of the results:

```bash
domaintools domain_search google --max_length 10 -u $TEST_USER -k $TEST_KEY -f html
```

To avoid having to type in your API key repeatedly, you can specify them in `~/.dtapi` separated by a new line:

```bash
API_USER
API_KEY
```

Python Version Support Policy
===================

Please see the [supported versions](https://github.com/DomainTools/python_api/raw/main/PYTHON_SUPPORT.md) document 
for the DomainTools Python support policy.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "domaintools-api-test-upload",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "Python, Python3",
    "author": null,
    "author_email": "DomainTools <integrations@domaintools.com>",
    "download_url": "https://files.pythonhosted.org/packages/68/a6/13c6d6b2fe76ebecf8614dd1240ff269386d0a606334b9de9f49c80f98fa/domaintools_api_test_upload-2.2.0.tar.gz",
    "platform": null,
    "description": "![domaintools](https://github.com/DomainTools/python_api/raw/main/artwork/logo.png)\n===================\n\n[![PyPI version](https://badge.fury.io/py/domaintools_api.svg)](http://badge.fury.io/py/domaintools_api)\n[![CI Status](https://github.com/domaintools/python_api/workflows/Tests/badge.svg)](https://github.com/domaintools/python_api/actions)\n[![Coverage Status](https://coveralls.io/repos/github/DomainTools/python_api/badge.svg?branch=main)](https://coveralls.io/github/DomainTools/python_api?branch=main)\n[![License](https://img.shields.io/github/license/mashape/apistatus.svg)](https://pypi.python.org/pypi/domaintools_api/)\n\nDomainTools Official Python API\n\n![domaintools Example](https://github.com/DomainTools/python_api/raw/main/artwork/example.gif)\n\nThe DomainTools Python API Wrapper provides an interface to work with our cybersecurity and related data tools provided by our Iris Investigate\u2122, Iris Enrich\u2122, and Iris Detect\u2122 products. It is actively maintained and may be downloaded via <a href=\"https://github.com/DomainTools/python_api\">GitHub</a> or <a href=\"https://pypi.org/project/domaintools-api/\">PyPI</a>. See the included README file, the examples folder, and API documentation (https://app.swaggerhub.com/apis-docs/DomainToolsLLC/DomainTools_APIs/1.0#) for more info.\n\nInstalling the DomainTools API\n===================\n\nTo install the API run\n\n```bash\npip install domaintools_api --upgrade\n```\n\nIdeally, within a virtual environment.\n\n\nUsing the API\n===================\n\nTo start out create an instance of the API - passing in your credentials\n\n```python\n\nfrom domaintools import API\n\n\napi = API(USER_NAME, KEY)\n```\n\nEvery API endpoint is then exposed as a method on the API object, with any parameters that should be passed into that endpoint\nbeing passed in as method arguments:\n\n```python\napi.iris_enrich('domaintools.com')\n```\n\nYou can get an overview of every endpoint that you can interact with using the builtin help function:\n\n```python\nhelp(api)\n```\n\nOr if you know the endpoint you want to use, you can get more information about it:\n\n```python\nhelp(api.iris_investigate)\n```\n\nIf applicable, native Python looping can be used directly to loop through any results:\n\n```python\nfor result in api.iris_enrich('domaintools.com').response().get('results', {}):\n    print(result['domain'])\n```\n\nYou can also use a context manager to ensure processing on the results only occurs if the request is successfully made:\n\n```python\nwith api.iris_enrich('domaintools.com').response().get('results', {}) as results:\n    print(results)\n```\n\nFor API calls where a single item is expected to be returned, you can directly interact with the result:\n\n```python\nprofile = api.domain_profile('google.com')\ntitle = profile['website_data']['title']\n```\n\nFor any API call where a single type of data is expected you can directly cast to the desired type:\n\n```python\nfloat(api.reputation('google.com')) == 0.0\nint(api.reputation('google.com')) == 0\n```\n\nThe entire structure returned from DomainTools can be retrieved by doing `.data()` while just the actionable response information\ncan be retrieved by doing `.response()`:\n\n```python\napi.iris_enrich('domaintools.com').data() == {'response': { ... }}\napi.iris_enrich('domaintools.com').response() == { ... }\n```\n\nYou can directly get the html, xml, or json version of the response by calling `.(html|xml|json)()` These only work with non AsyncResults:\n```python\njson = str(api.domain_search('google').json())\nxml = str(api.domain_search('google').xml())\nhtml = str(api.domain_search('google').html())\n```\n\nIf any API call is unsuccesfull, one of the exceptions defined in `domaintools.exceptions` will be raised:\n\n```python-traceback\napi.domain_profile('notvalid').data()\n\n\n---------------------------------------------------------------------------\nBadRequestException                       Traceback (most recent call last)\n<ipython-input-3-f9e22e2cf09d> in <module>()\n----> 1 api.domain_profile('google').data()\n\n/home/tcrosley/projects/external/python_api/venv/lib/python3.5/site-packages/domaintools-0.0.1-py3.5.egg/domaintools/base_results.py in data(self)\n     25                 self.api._request_session = Session()\n     26             results = self.api._request_session.get(self.url, params=self.kwargs)\n---> 27             self.status = results.status_code\n     28             if self.kwargs.get('format', 'json') == 'json':\n     29                 self._data = results.json()\n\n/home/tcrosley/projects/external/python_api/venv/lib/python3.5/site-packages/domaintools-0.0.1-py3.5.egg/domaintools/base_results.py in status(self, code)\n     44\n     45         elif code == 400:\n---> 46             raise BadRequestException()\n     47         elif code == 403:\n     48             raise NotAuthorizedException()\n\nBadRequestException:\n\n```\n\nthe exception will contain the status code and the reason for the exception:\n\n```python\ntry:\n    api.domain_profile('notvalid').data()\nexcept Exception as e:\n    assert e.code == 400\n    assert 'We could not understand your request' in e.reason['error']['message']\n```\n\nYou can get the status code of a response outside of exception handling by doing `.status`:\n\n```python\n\napi.domain_profile('google.com').status == 200\n```\n\nUsing the API Asynchronously\n===================\n\n![domaintools Async Example](https://github.com/DomainTools/python_api/raw/main/artwork/example_async.gif)\n\nThe DomainTools API automatically supports async usage:\n\n```python\n\nsearch_results = await api.iris_enrich('domaintools.com').response().get('results', {})\n```\n\nThere is built-in support for async context managers:\n\n```python\nasync with api.iris_enrich('domaintools.com').response().get('results', {}) as search_results:\n    # do things\n```\n\nAnd direct async for loops:\n\n```python\nasync for result in api.iris_enrich('domaintools.com').response().get('results', {}):\n    print(result)\n```\n\nAll async operations can safely be intermixed with non async ones - with optimal performance achieved if the async call is done first:\n```python\nprofile = api.domain_profile('google.com')\nawait profile\ntitle = profile['website_data']['title']\n```\n\nInteracting with the API via the command line client\n===================\n\n![domaintools CLI Example](https://github.com/DomainTools/python_api/raw/main/artwork/example_cli.gif)\n\nImmediately after installing `domaintools_api` with pip, a `domaintools` command line client will become available to you:\n\n```bash\ndomaintools --help\n```\n\nTo use - simply pass in the api_call you would like to make along with the parameters that it takes and your credentials:\n\n```bash\ndomaintools iris_investigate --domains domaintools.com -u $TEST_USER -k $TEST_KEY\n```\n\nOptionally, you can specify the desired format (html, xml, json, or list) of the results:\n\n```bash\ndomaintools domain_search google --max_length 10 -u $TEST_USER -k $TEST_KEY -f html\n```\n\nTo avoid having to type in your API key repeatedly, you can specify them in `~/.dtapi` separated by a new line:\n\n```bash\nAPI_USER\nAPI_KEY\n```\n\nPython Version Support Policy\n===================\n\nPlease see the [supported versions](https://github.com/DomainTools/python_api/raw/main/PYTHON_SUPPORT.md) document \nfor the DomainTools Python support policy.\n",
    "bugtrack_url": null,
    "license": "The MIT License (MIT)  Copyright (c) 2016 DomainTools  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. ",
    "summary": "DomainTools Official Python API",
    "version": "2.2.0",
    "project_urls": {
        "Homepage": "https://github.com/domaintools/python_api"
    },
    "split_keywords": [
        "python",
        " python3"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ef202b86864d15a0d5e6882dbd93bf5fb61103d07f965579fe6a165de5ee4bdd",
                "md5": "2d5bfb73b13ae85acad2f5672e535eec",
                "sha256": "6a9d193714066924a6c425f06337882cdb2ab9915e5a90cd76bdb01f3f23a355"
            },
            "downloads": -1,
            "filename": "domaintools_api_test_upload-2.2.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2d5bfb73b13ae85acad2f5672e535eec",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.9",
            "size": 40403,
            "upload_time": "2024-12-18T20:02:20",
            "upload_time_iso_8601": "2024-12-18T20:02:20.046821Z",
            "url": "https://files.pythonhosted.org/packages/ef/20/2b86864d15a0d5e6882dbd93bf5fb61103d07f965579fe6a165de5ee4bdd/domaintools_api_test_upload-2.2.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "68a613c6d6b2fe76ebecf8614dd1240ff269386d0a606334b9de9f49c80f98fa",
                "md5": "11b037cc11df877dcc52af597c38810c",
                "sha256": "52d35ec79c476b3f872614ab1ce9eb62d23f6c98728aaea28680d04163820df3"
            },
            "downloads": -1,
            "filename": "domaintools_api_test_upload-2.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "11b037cc11df877dcc52af597c38810c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 40241,
            "upload_time": "2024-12-18T20:02:23",
            "upload_time_iso_8601": "2024-12-18T20:02:23.733845Z",
            "url": "https://files.pythonhosted.org/packages/68/a6/13c6d6b2fe76ebecf8614dd1240ff269386d0a606334b9de9f49c80f98fa/domaintools_api_test_upload-2.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-18 20:02:23",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "domaintools",
    "github_project": "python_api",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "tox": true,
    "lcname": "domaintools-api-test-upload"
}
        
Elapsed time: 0.42026s