# Netlas.io Python SDK
This repository contains Netlas.io Python SDK package with CLI Tool.
The __Netlas Python SDK__ is a software development kit provided by the Netlas team to facilitate the integration of Netlas services into Python applications. The SDK provides a convenient way to interact with the API, performing tasks such as queries, routing and parsing the JSON responses from the Netlas API into Python objects, simplifying the process of integrating Netlas data into Python projects.
To access Netlas using the command line interface, the Netlas team has developed the __Netlas CLI Tool__. With it, you can use Netlas just like any other command line application. This utility is included in the Netlas Python SDK.
<span class="hidden">[![License: CC BY-NC-ND 4.0](https://img.shields.io/badge/License-CC%20BY--NC--ND%204.0-lightgrey.svg)](https://creativecommons.org/licenses/by-nc-nd/4.0/)</span>
## Installation
If you have Python installed, simply use the Python package installer to install the SDK and CLI Tool:
``` bash
pip install netlas
```
Or if you already have it installed and want to upgrade to the latest version:
``` bash
pip install --upgrade netlas
```
## Checking the installation
Now you can interact with the Netlas platform using command `netlas`.
``` bash
netlas
```
Try to get information about your external IP address:
``` bash
netlas host -a "YOUR_API_KEY"
```
The same data you should see in the web app if you open [https://app.netlas.io/host/](https://app.netlas.io/host/)
## Additional tools
We recommend using the Netlas CLI in conjunction with the `jq` utility. It is a lightweight and flexible command-line JSON processor, allowing you to perform various manipulations with the output.
Refer to [JQ website](https://jqlang.github.io/jq/download/) for installation instructions.
## Setting up API Key
There are two ways of API key usage when you work with Netlas CLI (command line interface). The first way is to enter the key each time you enter a command with the `-a` option. Another way is to save the key using `savekey` command.
``` bash
netlas savekey "YOUR_API_KEY"
```
## CLI Usage
Please refer to the built-in help for command and option information. To show help page:
```` bash
netlas --help
````
``` { class="no-copy" }
Usage: netlas [OPTIONS] COMMAND [ARGS]...
Options:
-h, --help Show this message and exit.
Commands:
count Calculate count of query results.
datastore Manage products in the datastore.
download Download data.
host Host (ip or domain) information.
indices Get available data indices.
profile Get user profile data.
savekey Save API key to the local system.
search (query) Search query.
stat Get statistics for query.
```
To view specific command help use `--help` key with `netlas command`, e.g.:
```` bash
netlas count --help
````
``` { class="no-copy" }
Usage: netlas count [OPTIONS] QUERYSTRING
Calculate count of query results.
Options:
-d, --datatype [response|cert|domain|whois-ip|whois-domain]
Query data type [default: response]
-a, --apikey TEXT User API key (can be saved to system using
command `netlas savekey`)
-f, --format [json|yaml] Output format [default: yaml]
--server TEXT Netlas API server [default:
https://app.netlas.io]
--indices TEXT Specify comma-separated data index
collections
-h, --help Show this message and exit.
```
Here are a few examples of CLI usage:
- Equivalent to [https://app.netlas.io/host/1.1.1.1/](https://app.netlas.io/host/1.1.1.1/)
``` bash
netlas host "1.1.1.1"
```
- Equivalent to [https://app.netlas.io/responses/?q=host%3A1.1.1.1](https://app.netlas.io/responses/?q=host%3A1.1.1.1)
``` bash
netlas search "host:1.1.1.1"
```
- Equivalent to [https://app.netlas.io/domains/?q=domain%3A%2A.netlas.io](https://app.netlas.io/domains/?q=domain%3A%2A.netlas.io)
``` bash
netlas search --datatype domain "domain:*.netlas.io"
```
You can find more bash examples on the [Netlas Docs →](https://docs.netlas.io/automation/).
## Python SDK Usage
The following code sample routes the request `port:7001` to the Netlas response search and prints search results to stdout.
``` python
import netlas
# you can access saved API key using this helper
apikey = netlas.helpers.get_api_key()
# create new connection to Netlas
netlas_connection = netlas.Netlas(api_key=apikey)
# retrieve data from responses by query `port:7001`
netlas_query = netlas_connection.query(query="port:7001")
# iterate over data and print: IP address, port, path and protocol
for response in netlas_query['items']:
print(f"{response['data']['ip']}:{response['data']['port']}{response['data']['path']} [{response['data']['protocol']}]")
pass
```
Please keep in mind that the example is simplified. When developing automation, it is necessary at least to provide procedures for exception handling. And it is also necessary to take into account that the API key may not be saved.
You can find more Python examples on the [Netlas Docs →](https://docs.netlas.io/automation/).
Raw data
{
"_id": null,
"home_page": "https://github.com/netlas-io/netlas-python",
"name": "netlas",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "security, network",
"author": "Netlas Team",
"author_email": "support@netlas.io",
"download_url": "https://files.pythonhosted.org/packages/bd/cd/09ae930c06579c606b4531bdbb4262ab6dccc2f1d8e13750667c38da1745/netlas-0.6.1.tar.gz",
"platform": null,
"description": "# Netlas.io Python SDK\n\nThis repository contains Netlas.io Python SDK package with CLI Tool.\n\nThe __Netlas Python SDK__ is a software development kit provided by the Netlas team to facilitate the integration of Netlas services into Python applications. The SDK provides a convenient way to interact with the API, performing tasks such as queries, routing and parsing the JSON responses from the Netlas API into Python objects, simplifying the process of integrating Netlas data into Python projects.\n\nTo access Netlas using the command line interface, the Netlas team has developed the __Netlas CLI Tool__. With it, you can use Netlas just like any other command line application. This utility is included in the Netlas Python SDK.\n\n<span class=\"hidden\">[![License: CC BY-NC-ND 4.0](https://img.shields.io/badge/License-CC%20BY--NC--ND%204.0-lightgrey.svg)](https://creativecommons.org/licenses/by-nc-nd/4.0/)</span>\n\n## Installation\n\nIf you have Python installed, simply use the Python package installer to install the SDK and CLI Tool:\n\n``` bash\npip install netlas\n```\n\nOr if you already have it installed and want to upgrade to the latest version:\n\n``` bash\npip install --upgrade netlas\n```\n\n## Checking the installation\n\nNow you can interact with the Netlas platform using command `netlas`.\n\n``` bash\nnetlas\n```\n\nTry to get information about your external IP address:\n\n``` bash\nnetlas host -a \"YOUR_API_KEY\"\n```\n\nThe same data you should see in the web app if you open [https://app.netlas.io/host/](https://app.netlas.io/host/)\n\n## Additional tools\n\nWe recommend using the Netlas CLI in conjunction with the `jq` utility. It is a lightweight and flexible command-line JSON processor, allowing you to perform various manipulations with the output.\n\nRefer to [JQ website](https://jqlang.github.io/jq/download/) for installation instructions.\n\n## Setting up API Key\n\nThere are two ways of API key usage when you work with Netlas CLI (command line interface). The first way is to enter the key each time you enter a command with the `-a` option. Another way is to save the key using `savekey` command.\n\n``` bash\nnetlas savekey \"YOUR_API_KEY\"\n```\n\n## CLI Usage\n\nPlease refer to the built-in help for command and option information. To show help page:\n\n```` bash\nnetlas --help\n````\n``` { class=\"no-copy\" }\nUsage: netlas [OPTIONS] COMMAND [ARGS]...\n\nOptions:\n -h, --help Show this message and exit.\n\nCommands:\n count Calculate count of query results.\n datastore Manage products in the datastore.\n download Download data.\n host Host (ip or domain) information.\n indices Get available data indices.\n profile Get user profile data.\n savekey Save API key to the local system.\n search (query) Search query.\n stat Get statistics for query.\n```\n\nTo view specific command help use `--help` key with `netlas command`, e.g.:\n\n```` bash\nnetlas count --help\n````\n``` { class=\"no-copy\" }\nUsage: netlas count [OPTIONS] QUERYSTRING\n\n Calculate count of query results.\n\nOptions:\n -d, --datatype [response|cert|domain|whois-ip|whois-domain]\n Query data type [default: response]\n -a, --apikey TEXT User API key (can be saved to system using\n command `netlas savekey`)\n -f, --format [json|yaml] Output format [default: yaml]\n --server TEXT Netlas API server [default:\n https://app.netlas.io]\n --indices TEXT Specify comma-separated data index\n collections\n -h, --help Show this message and exit.\n```\n\nHere are a few examples of CLI usage:\n\n- Equivalent to [https://app.netlas.io/host/1.1.1.1/](https://app.netlas.io/host/1.1.1.1/)\n ``` bash\n netlas host \"1.1.1.1\"\t\t\t\n ```\n- Equivalent to [https://app.netlas.io/responses/?q=host%3A1.1.1.1](https://app.netlas.io/responses/?q=host%3A1.1.1.1)\n ``` bash\n netlas search \"host:1.1.1.1\"\n ```\n- Equivalent to [https://app.netlas.io/domains/?q=domain%3A%2A.netlas.io](https://app.netlas.io/domains/?q=domain%3A%2A.netlas.io)\n ``` bash\n netlas search --datatype domain \"domain:*.netlas.io\"\n ```\n\nYou can find more bash examples on the [Netlas Docs →](https://docs.netlas.io/automation/).\n\n## Python SDK Usage\n\nThe following code sample routes the request `port:7001` to the Netlas response search and prints search results to stdout.\n\n``` python\nimport netlas\n\n# you can access saved API key using this helper\napikey = netlas.helpers.get_api_key()\n\n# create new connection to Netlas\nnetlas_connection = netlas.Netlas(api_key=apikey)\n\n# retrieve data from responses by query `port:7001`\nnetlas_query = netlas_connection.query(query=\"port:7001\")\n\n# iterate over data and print: IP address, port, path and protocol\nfor response in netlas_query['items']:\n print(f\"{response['data']['ip']}:{response['data']['port']}{response['data']['path']} [{response['data']['protocol']}]\")\npass\n```\n\nPlease keep in mind that the example is simplified. When developing automation, it is necessary at least to provide procedures for exception handling. And it is also necessary to take into account that the API key may not be saved.\n\nYou can find more Python examples on the [Netlas Docs →](https://docs.netlas.io/automation/).\n\n",
"bugtrack_url": null,
"license": null,
"summary": "Netlas.io API package",
"version": "0.6.1",
"project_urls": {
"Homepage": "https://github.com/netlas-io/netlas-python"
},
"split_keywords": [
"security",
" network"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "41b3cd9e6c9cdc5447c56a6586792269ac32b1dadbec9ee26f37bdbf5341ba27",
"md5": "15cd62ca14abb0dd98f6b0df21155b59",
"sha256": "729a68ff1596220d4af8fc388f7ffe82c0a65b8ba843b24e6935ee5330fdc54d"
},
"downloads": -1,
"filename": "netlas-0.6.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "15cd62ca14abb0dd98f6b0df21155b59",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 15829,
"upload_time": "2024-12-20T09:52:44",
"upload_time_iso_8601": "2024-12-20T09:52:44.787727Z",
"url": "https://files.pythonhosted.org/packages/41/b3/cd9e6c9cdc5447c56a6586792269ac32b1dadbec9ee26f37bdbf5341ba27/netlas-0.6.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "bdcd09ae930c06579c606b4531bdbb4262ab6dccc2f1d8e13750667c38da1745",
"md5": "6f3da37ac4bc590b05bfe41362577ec2",
"sha256": "bb85396c47c8535148e03d0b0946518960461d927fb06000e08aa4e57296e82c"
},
"downloads": -1,
"filename": "netlas-0.6.1.tar.gz",
"has_sig": false,
"md5_digest": "6f3da37ac4bc590b05bfe41362577ec2",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 19940,
"upload_time": "2024-12-20T09:52:47",
"upload_time_iso_8601": "2024-12-20T09:52:47.210059Z",
"url": "https://files.pythonhosted.org/packages/bd/cd/09ae930c06579c606b4531bdbb4262ab6dccc2f1d8e13750667c38da1745/netlas-0.6.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-20 09:52:47",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "netlas-io",
"github_project": "netlas-python",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "requests",
"specs": [
[
">=",
"2.12.5"
]
]
},
{
"name": "click",
"specs": [
[
">=",
"7.0"
]
]
},
{
"name": "PyYAML",
"specs": [
[
">=",
"3.13"
]
]
},
{
"name": "pygments",
"specs": [
[
">=",
"2.5.0"
]
]
},
{
"name": "tqdm",
"specs": [
[
">=",
"4.0.0"
]
]
},
{
"name": "appdirs",
"specs": [
[
">=",
"1.4.3"
]
]
},
{
"name": "rich",
"specs": [
[
">=",
"13.7.1"
]
]
}
],
"lcname": "netlas"
}