Skip to main content

Official Python SDK for InstantAPI

Project description

InstantAPI Python SDK

The official Python SDK for InstantAPI — AI-powered text processing in a single API call.

Installation

pip install instantapi-sdk

Quick Start

from instantapi import InstantAPI

api = InstantAPI("your-api-key")

# Summarize text
result = api.summarize("Your long article text here...")
print(result["summary"])

Authentication

Sign up at instantapis.net to get your API key, then pass it when creating the client:

api = InstantAPI("your-api-key")

The key is sent via the Authorization: Bearer header on every request.

Methods

summarize(text, length="medium")

Summarize a block of text.

result = api.summarize(
    "Artificial intelligence has transformed industries across the globe...",
    length="short",   # "short", "medium", or "long"
)
print(result["summary"])

extract(text, fields=None)

Extract structured data from unstructured text.

result = api.extract(
    "John Smith, john@example.com, joined on 2024-01-15",
    fields=["name", "email", "date"],
)
print(result)
# {"name": "John Smith", "email": "john@example.com", "date": "2024-01-15"}

When fields is omitted the API auto-detects relevant fields.

analyze(text)

Perform comprehensive text analysis (themes, entities, tone).

result = api.analyze("The quarterly earnings exceeded expectations...")
print(result["themes"])
print(result["entities"])

translate(text, target_language)

Translate text into any language.

result = api.translate("Hello, world!", target_language="es")
print(result["translation"])  # "Hola, mundo!"

sentiment(text)

Analyze text sentiment.

result = api.sentiment("I absolutely love this product!")
print(result["sentiment"])   # "positive"
print(result["confidence"])  # 0.97

code(prompt, language=None)

Generate code from a natural-language description.

result = api.code(
    "Sort a list of dicts by the 'age' key",
    language="python",
)
print(result["code"])

Error Handling

The SDK raises typed exceptions so you can handle specific failure modes:

from instantapi import (
    InstantAPI,
    AuthenticationError,
    InsufficientCreditsError,
    RateLimitError,
    InstantAPIError,
)

api = InstantAPI("your-api-key")

try:
    result = api.summarize("Some text...")
except AuthenticationError:
    print("Invalid API key. Check your credentials.")
except InsufficientCreditsError:
    print("Out of credits. Top up at https://instantapis.net.")
except RateLimitError:
    print("Too many requests. Please slow down.")
except InstantAPIError as e:
    print(f"API error [{e.status_code}]: {e.message}")
Exception HTTP Status When
AuthenticationError 401 Invalid or missing API key
InsufficientCreditsError 402 Account has no credits left
RateLimitError 429 Too many requests
InstantAPIError Any Base class for all API errors

Advanced Configuration

# Custom base URL (e.g., for self-hosted instances)
api = InstantAPI("your-api-key", base_url="https://my-instance.example.com")

# Custom timeout (default is 30 seconds)
api = InstantAPI("your-api-key", timeout=60)

Full Documentation

For complete API reference, guides, and examples visit https://instantapis.net/docs.

License

MIT

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

instantapi_sdk-1.0.0.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

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

instantapi_sdk-1.0.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file instantapi_sdk-1.0.0.tar.gz.

File metadata

  • Download URL: instantapi_sdk-1.0.0.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for instantapi_sdk-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e10dca9ea43e101c1a3e2a9bfef16e64c0ef8c1f2e2c6fed4422883dd1fd482a
MD5 d1b45d325444ccc6e1c79ba13c9fcc23
BLAKE2b-256 402766cd59ea16829aad0f6237ac6f56ffc287df2230a6334c25241a7cf25c2d

See more details on using hashes here.

File details

Details for the file instantapi_sdk-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: instantapi_sdk-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for instantapi_sdk-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cf28e294c28f7d1f9ef13f41b8ac373ee4252f348071654c3a6229d392a835e0
MD5 64bfa490a8c61bf4237924bfa5414d1d
BLAKE2b-256 50446012478c91bf1e74d774551d1c2f23e9152bae062938c650972a90744ced

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