Skip to main content

Python SDK for the LinkShieldAI URL safety API.

Project description

LinkShieldAI Python SDK

Python wrapper for the LinkShieldAI API at https://api.linkshieldai.com.

The SDK supports:

  • Basic URL safety checks
  • Detailed checks with screenshot URL and detected tag
  • Screenshot download
  • NSFW site checks
  • Chimera AI classification
  • Sync and async clients
  • Retry/backoff for transient API failures
  • A small command-line tool

Install

pip install linkshieldai

Authentication

The API uses a query parameter named key.

Pass the API key directly:

from linkshieldai import LinkShieldAI

client = LinkShieldAI(api_key="YOUR_API_KEY")

Or set an environment variable:

$env:LINKSHIELDAI_API_KEY = "YOUR_API_KEY"
from linkshieldai import LinkShieldAI

client = LinkShieldAI()

Basic Check

Wraps:

GET https://api.linkshieldai.com/?key={key}&url={url}
from linkshieldai import LinkShieldAI

client = LinkShieldAI(api_key="YOUR_API_KEY")
result = client.basic_check("https://example.com")

print(result.result)
print(result.is_malicious)
print(result.raw)

Detailed Check

Wraps:

GET https://api.linkshieldai.com/classify_link?key={key}&url={url}
result = client.detailed_check("https://example.com")

print(result.result)
print(result.screenshot_url)
print(result.tag)

The API field "screenshot url" is normalized to screenshot_url.

Download Screenshot

Wraps:

GET https://api.linkshieldai.com/screenshot/{file_name}
image_bytes = client.get_screenshot("05046f.png")
client.get_screenshot("https://api.linkshieldai.com/screenshot/05046f.png", "site.png")

NSFW Check

Wraps:

GET https://api.linkshieldai.com/nsfw/site?key={key}&url={url}
result = client.nsfw_check("https://example.com")
print(result.is_nsfw)

Chimera Check

Wraps:

GET https://api.linkshieldai.com/chimera?key={key}&url={url}
result = client.chimera("https://google.com")

print(result.result)
print(result.probability)
print(result.detection_method)
print(result.matched_signatures)

Async Usage

import asyncio
from linkshieldai import AsyncLinkShieldAI


async def main():
    async with AsyncLinkShieldAI(api_key="YOUR_API_KEY") as client:
        result = await client.chimera("https://google.com")
        print(result.result, result.probability)


asyncio.run(main())

Custom API Host

The default host is:

https://api.linkshieldai.com

You can override it for staging or testing:

client = LinkShieldAI(base_url="https://api.linkshieldai.com")

Timeouts, Retries, and Logging

By default the SDK uses:

  • timeout=10.0
  • max_retries=2
  • backoff_factor=0.5

Retries are applied to temporary connection failures and HTTP 429, 502, 503, and 504.

import logging
from linkshieldai import LinkShieldAI

logging.basicConfig(level=logging.DEBUG)

client = LinkShieldAI(
    timeout=15.0,
    max_retries=3,
    backoff_factor=1.0,
)

CLI

After installation, use:

linkshieldai --api-key YOUR_API_KEY basic https://example.com
linkshieldai --api-key YOUR_API_KEY detailed https://example.com
linkshieldai --api-key YOUR_API_KEY nsfw https://example.com
linkshieldai --api-key YOUR_API_KEY chimera https://google.com
linkshieldai --api-key YOUR_API_KEY screenshot 05046f.png --output site.png

You can omit --api-key if LINKSHIELDAI_API_KEY is set.

Errors

from linkshieldai import (
    APIConnectionError,
    APIResponseError,
    APIStatusError,
    AuthenticationError,
    RateLimitError,
)
  • AuthenticationError: missing API key.
  • RateLimitError: HTTP 429.
  • APIStatusError: non-success HTTP status.
  • APIResponseError: malformed JSON or API payload with Error / error.
  • APIConnectionError: timeout, DNS, or connection failure.

Raw API payloads are preserved on result objects through .raw.

Production Notes

  • Keep API keys server-side. Do not expose them in browser JavaScript.
  • Use max_retries with a small non-zero value for bots, moderation pipelines, and web apps.
  • Catch RateLimitError when running near the documented limits.

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

linkshieldai-0.2.2.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

linkshieldai-0.2.2-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file linkshieldai-0.2.2.tar.gz.

File metadata

  • Download URL: linkshieldai-0.2.2.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.10

File hashes

Hashes for linkshieldai-0.2.2.tar.gz
Algorithm Hash digest
SHA256 1302d6a7327b6046485ffe4858e249fc2cf9d3c0cac330ca42d8046275173f2b
MD5 25449ac5729b69a677ba43391e2373a1
BLAKE2b-256 f403e43e5183f329381603a5e8d48e63fbb2aab69a5dd1a24b3071ead56d2f25

See more details on using hashes here.

File details

Details for the file linkshieldai-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: linkshieldai-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.10

File hashes

Hashes for linkshieldai-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cd905a80e5a829ea233f3c01510114b0e8eaa6f5ea3f60ea1af7d2248d2380a0
MD5 fb8778ddb321d572289349ec4ded7f6e
BLAKE2b-256 9f1dfcd223427c9a1379038a088315afa2d558e8c54419e320bf2d658ee594a9

See more details on using hashes here.

Supported by

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