# ShodanKey - API Key Validator
ShodanKey is a Python package that helps validate Shodan API keys and retrieve important details about them, including usage limits, credits, and plan information.
## Features
- Validate Shodan API keys.
- Retrieve details like `scan_credits`, `query_credits`, `monitored_ips`, `usage_limits`, `plan`, and more.
- Handle both valid and invalid API keys.
- Provides detailed response for each API key validation.
## Installation
To install the package, simply run the following command:
```bash
pip install shodankey
```
## Usage Examples
### Example 1: Basic Usage
To validate a single Shodan API key and retrieve its associated information:
```python
from shodankey import token
# Replace with your actual Shodan API key
api_key = "your_shodan_api_key"
# Validate the API key
result = token(api_key)
# Check if the key is valid and print the information
if result["valid"]:
print(f"Plan: {result['plan']}")
print(f"Scan Credits: {result['scan_credits']}")
print(f"Query Credits: {result['query_credits']}")
print(f"Monitored IPs: {result['monitored_ips']}")
print(f"Unlocked Left: {result['unlocked_left']}")
print(f"Telnet Access: {result['telnet']}")
print(f"HTTPS Supported: {result['https']}")
print(f"Usage Limits: {result['usage_limits']}")
print(f"Timestamp: {result['timestamp']}")
else:
print(f"Invalid API Key: {result['error']}")
```
### Example 2: Loop Through Multiple API Keys
If you have multiple Shodan API keys and you want to validate each one in a loop, use the following code:
```python
from shodankey import token
# List of Shodan API keys to validate
api_keys = [
"your_shodan_api_key_1",
"your_shodan_api_key_2",
"your_shodan_api_key_3"
]
# Loop through the keys and check their validity
for api_key in api_keys:
print(f"Checking API Key: {api_key}")
result = token(api_key)
if result["valid"]:
print(f"Plan: {result['plan']}")
print(f"Scan Credits: {result['scan_credits']}")
print(f"Query Credits: {result['query_credits']}")
print(f"Monitored IPs: {result['monitored_ips']}")
print(f"Unlocked Left: {result['unlocked_left']}")
print(f"Telnet Access: {result['telnet']}")
print(f"HTTPS Supported: {result['https']}")
print(f"Usage Limits: {result['usage_limits']}")
print(f"Timestamp: {result['timestamp']}")
else:
print(f"Invalid API Key: {api_key}, Error: {result['error']}")
# Print a separator between results
print("-" * 40)
```
### Example 3: Detailed Information for Each Key
If you want to retrieve all available details for a given API key, including its plan, credits, and usage limits:
```python
from shodankey import token
# Replace with your actual Shodan API key
api_key = "your_shodan_api_key"
# Get the API key validation result
result = token(api_key)
# Check if the key is valid and print all detailed information
if result["valid"]:
print(f"API Key is valid!\n")
print(f"Plan: {result['plan']}")
print(f"Credits: {result['credits']}")
print(f"Scan Credits: {result['scan_credits']}")
print(f"Query Credits: {result['query_credits']}")
print(f"Monitored IPs: {result['monitored_ips']}")
print(f"Unlocked Left: {result['unlocked_left']}")
print(f"Telnet Access: {result['telnet']}")
print(f"HTTPS Supported: {result['https']}")
print(f"Usage Limits: {result['usage_limits']}")
print(f"Timestamp: {result['timestamp']}")
else:
print(f"Invalid API Key: {result['error']}")
```
### Example 4: Full API Response Details
To get the full response, including usage limits, plan, and credits, here’s an example of how you can extract everything:
```python
from shodankey import token
# Replace with your actual Shodan API key
api_key = "your_shodan_api_key"
# Get detailed information
result = token(api_key)
# Check for valid API key and print all available details
if result["valid"]:
print(f"API Key is valid!\n")
print(f"Plan: {result['plan']}")
print(f"Credits: {result['credits']}")
print(f"Scan Credits: {result['scan_credits']}")
print(f"Query Credits: {result['query_credits']}")
print(f"Monitored IPs: {result['monitored_ips']}")
print(f"Unlocked Left: {result['unlocked_left']}")
print(f"Telnet Access: {result['telnet']}")
print(f"HTTPS Supported: {result['https']}")
print(f"Usage Limits: {result['usage_limits']}")
print(f"Timestamp: {result['timestamp']}")
else:
print(f"Invalid API Key: {result['error']}")
```
### Example 5: Check for Token File
Before validating the API key, you can check whether a token file exists. If it doesn't exist, you can create one to store your API keys:
```python
import os
from shodankey import token
# File where the API keys are stored
token_file = "shodan_tokens.txt"
# Check if the file exists
if os.path.exists(token_file):
with open(token_file, "r") as file:
api_keys = file.readlines()
# Loop through the keys and check their validity
for api_key in api_keys:
api_key = api_key.strip() # Remove extra spaces/newlines
print(f"Checking API Key: {api_key}")
result = token(api_key)
if result["valid"]:
print(f"Plan: {result['plan']}")
print(f"Scan Credits: {result['scan_credits']}")
print(f"Query Credits: {result['query_credits']}")
print(f"Monitored IPs: {result['monitored_ips']}")
print(f"Unlocked Left: {result['unlocked_left']}")
print(f"Telnet Access: {result['telnet']}")
print(f"HTTPS Supported: {result['https']}")
print(f"Usage Limits: {result['usage_limits']}")
print(f"Timestamp: {result['timestamp']}")
else:
print(f"Invalid API Key: {api_key}, Error: {result['error']}")
# Print a separator between results
print("-" * 40)
else:
print(f"{token_file} does not exist. Please create the file and add your Shodan API keys.")
```
## Handling Invalid API Keys
If the API key is invalid, you will receive a message with the error description, like so:
```json
{
"valid": false,
"error": "Unauthorized - Invalid API Key"
}
```
This error message helps you identify whether the issue is related to the API key or something else.
## Thank You
Thank you for using **ShodanKey**! If you have any questions or need further assistance, please feel free to open an issue or contribute to the project. Your support means a lot to us!
## License
This project is licensed under the MIT License. See the LICENSE file for more information.
---
Raw data
{
"_id": null,
"home_page": "https://github.com/ByteBreach/shodankey",
"name": "shodankey",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "shodan, MrFidal, api, security, network-scanning, information-gathering, api-key-validation",
"author": "Fidal",
"author_email": "mrfidal@proton.me",
"download_url": "https://files.pythonhosted.org/packages/16/bc/7123811d8ed19bfc25ae7304d0cb25f49ff6adbe24f2fa546d976634bdac/shodankey-1.0.0.tar.gz",
"platform": null,
"description": "# ShodanKey - API Key Validator\r\n\r\nShodanKey is a Python package that helps validate Shodan API keys and retrieve important details about them, including usage limits, credits, and plan information.\r\n\r\n## Features\r\n\r\n- Validate Shodan API keys.\r\n- Retrieve details like `scan_credits`, `query_credits`, `monitored_ips`, `usage_limits`, `plan`, and more.\r\n- Handle both valid and invalid API keys.\r\n- Provides detailed response for each API key validation.\r\n\r\n## Installation\r\n\r\nTo install the package, simply run the following command:\r\n\r\n```bash\r\npip install shodankey\r\n```\r\n\r\n## Usage Examples\r\n\r\n### Example 1: Basic Usage\r\n\r\nTo validate a single Shodan API key and retrieve its associated information:\r\n\r\n```python\r\nfrom shodankey import token\r\n\r\n# Replace with your actual Shodan API key\r\napi_key = \"your_shodan_api_key\"\r\n\r\n# Validate the API key\r\nresult = token(api_key)\r\n\r\n# Check if the key is valid and print the information\r\nif result[\"valid\"]:\r\n print(f\"Plan: {result['plan']}\")\r\n print(f\"Scan Credits: {result['scan_credits']}\")\r\n print(f\"Query Credits: {result['query_credits']}\")\r\n print(f\"Monitored IPs: {result['monitored_ips']}\")\r\n print(f\"Unlocked Left: {result['unlocked_left']}\")\r\n print(f\"Telnet Access: {result['telnet']}\")\r\n print(f\"HTTPS Supported: {result['https']}\")\r\n print(f\"Usage Limits: {result['usage_limits']}\")\r\n print(f\"Timestamp: {result['timestamp']}\")\r\nelse:\r\n print(f\"Invalid API Key: {result['error']}\")\r\n```\r\n\r\n### Example 2: Loop Through Multiple API Keys\r\n\r\nIf you have multiple Shodan API keys and you want to validate each one in a loop, use the following code:\r\n\r\n```python\r\nfrom shodankey import token\r\n\r\n# List of Shodan API keys to validate\r\napi_keys = [\r\n \"your_shodan_api_key_1\",\r\n \"your_shodan_api_key_2\",\r\n \"your_shodan_api_key_3\"\r\n]\r\n\r\n# Loop through the keys and check their validity\r\nfor api_key in api_keys:\r\n print(f\"Checking API Key: {api_key}\")\r\n result = token(api_key)\r\n \r\n if result[\"valid\"]:\r\n print(f\"Plan: {result['plan']}\")\r\n print(f\"Scan Credits: {result['scan_credits']}\")\r\n print(f\"Query Credits: {result['query_credits']}\")\r\n print(f\"Monitored IPs: {result['monitored_ips']}\")\r\n print(f\"Unlocked Left: {result['unlocked_left']}\")\r\n print(f\"Telnet Access: {result['telnet']}\")\r\n print(f\"HTTPS Supported: {result['https']}\")\r\n print(f\"Usage Limits: {result['usage_limits']}\")\r\n print(f\"Timestamp: {result['timestamp']}\")\r\n else:\r\n print(f\"Invalid API Key: {api_key}, Error: {result['error']}\")\r\n \r\n # Print a separator between results\r\n print(\"-\" * 40)\r\n```\r\n\r\n### Example 3: Detailed Information for Each Key\r\n\r\nIf you want to retrieve all available details for a given API key, including its plan, credits, and usage limits:\r\n\r\n```python\r\nfrom shodankey import token\r\n\r\n# Replace with your actual Shodan API key\r\napi_key = \"your_shodan_api_key\"\r\n\r\n# Get the API key validation result\r\nresult = token(api_key)\r\n\r\n# Check if the key is valid and print all detailed information\r\nif result[\"valid\"]:\r\n print(f\"API Key is valid!\\n\")\r\n print(f\"Plan: {result['plan']}\")\r\n print(f\"Credits: {result['credits']}\")\r\n print(f\"Scan Credits: {result['scan_credits']}\")\r\n print(f\"Query Credits: {result['query_credits']}\")\r\n print(f\"Monitored IPs: {result['monitored_ips']}\")\r\n print(f\"Unlocked Left: {result['unlocked_left']}\")\r\n print(f\"Telnet Access: {result['telnet']}\")\r\n print(f\"HTTPS Supported: {result['https']}\")\r\n print(f\"Usage Limits: {result['usage_limits']}\")\r\n print(f\"Timestamp: {result['timestamp']}\")\r\nelse:\r\n print(f\"Invalid API Key: {result['error']}\")\r\n```\r\n\r\n### Example 4: Full API Response Details\r\n\r\nTo get the full response, including usage limits, plan, and credits, here\u00e2\u20ac\u2122s an example of how you can extract everything:\r\n\r\n```python\r\nfrom shodankey import token\r\n\r\n# Replace with your actual Shodan API key\r\napi_key = \"your_shodan_api_key\"\r\n\r\n# Get detailed information\r\nresult = token(api_key)\r\n\r\n# Check for valid API key and print all available details\r\nif result[\"valid\"]:\r\n print(f\"API Key is valid!\\n\")\r\n print(f\"Plan: {result['plan']}\")\r\n print(f\"Credits: {result['credits']}\")\r\n print(f\"Scan Credits: {result['scan_credits']}\")\r\n print(f\"Query Credits: {result['query_credits']}\")\r\n print(f\"Monitored IPs: {result['monitored_ips']}\")\r\n print(f\"Unlocked Left: {result['unlocked_left']}\")\r\n print(f\"Telnet Access: {result['telnet']}\")\r\n print(f\"HTTPS Supported: {result['https']}\")\r\n print(f\"Usage Limits: {result['usage_limits']}\")\r\n print(f\"Timestamp: {result['timestamp']}\")\r\nelse:\r\n print(f\"Invalid API Key: {result['error']}\")\r\n```\r\n\r\n### Example 5: Check for Token File\r\n\r\nBefore validating the API key, you can check whether a token file exists. If it doesn't exist, you can create one to store your API keys:\r\n\r\n```python\r\nimport os\r\nfrom shodankey import token\r\n\r\n# File where the API keys are stored\r\ntoken_file = \"shodan_tokens.txt\"\r\n\r\n# Check if the file exists\r\nif os.path.exists(token_file):\r\n with open(token_file, \"r\") as file:\r\n api_keys = file.readlines()\r\n\r\n # Loop through the keys and check their validity\r\n for api_key in api_keys:\r\n api_key = api_key.strip() # Remove extra spaces/newlines\r\n print(f\"Checking API Key: {api_key}\")\r\n result = token(api_key)\r\n \r\n if result[\"valid\"]:\r\n print(f\"Plan: {result['plan']}\")\r\n print(f\"Scan Credits: {result['scan_credits']}\")\r\n print(f\"Query Credits: {result['query_credits']}\")\r\n print(f\"Monitored IPs: {result['monitored_ips']}\")\r\n print(f\"Unlocked Left: {result['unlocked_left']}\")\r\n print(f\"Telnet Access: {result['telnet']}\")\r\n print(f\"HTTPS Supported: {result['https']}\")\r\n print(f\"Usage Limits: {result['usage_limits']}\")\r\n print(f\"Timestamp: {result['timestamp']}\")\r\n else:\r\n print(f\"Invalid API Key: {api_key}, Error: {result['error']}\")\r\n \r\n # Print a separator between results\r\n print(\"-\" * 40)\r\nelse:\r\n print(f\"{token_file} does not exist. Please create the file and add your Shodan API keys.\")\r\n```\r\n\r\n## Handling Invalid API Keys\r\n\r\nIf the API key is invalid, you will receive a message with the error description, like so:\r\n\r\n```json\r\n{\r\n \"valid\": false,\r\n \"error\": \"Unauthorized - Invalid API Key\"\r\n}\r\n```\r\n\r\nThis error message helps you identify whether the issue is related to the API key or something else.\r\n\r\n## Thank You\r\n\r\nThank you for using **ShodanKey**! If you have any questions or need further assistance, please feel free to open an issue or contribute to the project. Your support means a lot to us!\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License. See the LICENSE file for more information.\r\n\r\n---\r\n",
"bugtrack_url": null,
"license": null,
"summary": "A package to validate and retrieve information from the Shodan API",
"version": "1.0.0",
"project_urls": {
"Homepage": "https://github.com/ByteBreach/shodankey"
},
"split_keywords": [
"shodan",
" mrfidal",
" api",
" security",
" network-scanning",
" information-gathering",
" api-key-validation"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7a5d01494f0eb57b0fe1b288ffed721895cf73162150a8391b947c963fe149d0",
"md5": "6500377396e5bb122a30dd8075811294",
"sha256": "949e57bbcf940480c336b8051e0d6306655bfdce97cfa5ea30c1fcbde49e5c7e"
},
"downloads": -1,
"filename": "shodankey-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6500377396e5bb122a30dd8075811294",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 4117,
"upload_time": "2024-12-05T18:28:55",
"upload_time_iso_8601": "2024-12-05T18:28:55.683180Z",
"url": "https://files.pythonhosted.org/packages/7a/5d/01494f0eb57b0fe1b288ffed721895cf73162150a8391b947c963fe149d0/shodankey-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "16bc7123811d8ed19bfc25ae7304d0cb25f49ff6adbe24f2fa546d976634bdac",
"md5": "2e9d472c70d17fa000e296cabae8b05e",
"sha256": "0db6d40fd14928a3a6ccabfe8b64ed64b41c6228909609e0a8d59e5e53ccafb2"
},
"downloads": -1,
"filename": "shodankey-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "2e9d472c70d17fa000e296cabae8b05e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 4972,
"upload_time": "2024-12-05T18:28:57",
"upload_time_iso_8601": "2024-12-05T18:28:57.848251Z",
"url": "https://files.pythonhosted.org/packages/16/bc/7123811d8ed19bfc25ae7304d0cb25f49ff6adbe24f2fa546d976634bdac/shodankey-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-05 18:28:57",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ByteBreach",
"github_project": "shodankey",
"github_not_found": true,
"lcname": "shodankey"
}