Skip to main content

Official Python SDK for the Sentor API — entity-based sentiment analysis, document clustering, and topic naming

Project description

Sentor Python SDK

Official Python SDK for the Sentor API — entity-based sentiment analysis, document clustering, and topic naming.

PyPI Python License GitHub Stars
Website Dashboard Docs

Stop guessing why ratings drop. Sentor pinpoints exactly how customers feel about specific entities — brands, products, features, competitors — using fine-tuned BERT models trained for aspect-based sentiment analysis.


Table of Contents


📦 Installation

pip install sentor-python-sdk

Get a free API key at dashboard.sentor.app.


🚀 Quick Start

from sentor import SentorClient

client = SentorClient("your_api_key")

results = client.predict([
    {
        "doc_id": "review-1",
        "doc": "Apple's new iPhone is amazing but the price is ridiculous.",
        "entities": ["Apple", "iPhone", "price"]
    }
])

for item in results["results"]:
    print(item["doc_id"], item["predicted_label"])
    for es in item.get("entity_sentiments", []):
        print(f"  {es['entity']}: {es['sentiment']} ({es['score']:.2f})")

📖 API Reference

predict(documents, language="en")

Score sentiment toward named entities in one or more documents.

results = client.predict(
    documents=[
        {
            "doc_id": "r1",
            "doc": "Samsung's camera is great but battery life is poor.",
            "entities": ["Samsung", "camera", "battery life"]
        }
    ],
    language="en"  # "en" or "nl"
)

Response shape:

{
    "results": [
        {
            "doc_id": "r1",
            "predicted_class": 0,        # 0=negative, 1=neutral, 2=positive
            "predicted_label": "negative",
            "probabilities": {"negative": 0.72, "neutral": 0.18, "positive": 0.10},
            "details": [...],            # per-sentence breakdown
            "entity_sentiments": [
                {"entity": "Samsung", "sentiment": "neutral", "score": 0.61},
                {"entity": "camera", "sentiment": "positive", "score": 0.88},
                {"entity": "battery life", "sentiment": "negative", "score": 0.91}
            ]
        }
    ]
}

Supported languages: en (English), nl (Dutch)


cluster(documents, language="en")

Group 5+ documents into thematic clusters using BERTopic + HDBSCAN.

results = client.cluster(
    documents=[
        {"doc_id": "r1", "text": "Shipping was incredibly fast.", "entities": ["shipping"]},
        # ... at least 5 documents
    ],
    language="en"
)

for cluster in results["clusters"]:
    print(cluster["cluster_id"], cluster["document_count"], cluster["top_words"])
# Cluster -1 = outliers that did not fit any topic

generate_topic_name(cluster_id, documents, ...)

Generate a 3–5 word label for a cluster using an LLM.

result = client.generate_topic_name(
    cluster_id=0,
    documents=cluster["documents"],
    top_words=cluster["top_words"],
    entities=["BrandName"],
    language="en"
)
print(result["topic_name"])  # e.g. "Shipping Delay Complaints"

check_health()

health = client.check_health()
# {"status": "healthy", "version": "...", "llm_status": "available"}

⚠️ Error Handling

from sentor import SentorClient
from sentor.exceptions import SentorAPIError, RateLimitError, AuthenticationError

client = SentorClient("your_api_key")

try:
    results = client.predict([...])
except AuthenticationError:
    print("Invalid API key")
except RateLimitError as e:
    print(f"Rate limit hit. Retry after {e.retry_after}s")
except SentorAPIError as e:
    print(f"API error: {e.message} (code: {e.code})")

📊 Rate Limits

Plan Per Minute Per Day Per Month
Free 5 100 1,000
Starter 20 600 5,000
Growth 60 3,000 25,000
Business 200 10,000 100,000
Enterprise 500 30,000 500,000

View full pricing →


🔄 Migration from sentor-ml

This package replaces sentor-ml. The import name (sentor) and all method signatures are unchanged — only the install command changes:

pip uninstall sentor-ml
pip install sentor-python-sdk

🔗 Links


Built by NIKX Technologies B.V.

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

sentor_python_sdk-2.0.0.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

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

sentor_python_sdk-2.0.0-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file sentor_python_sdk-2.0.0.tar.gz.

File metadata

  • Download URL: sentor_python_sdk-2.0.0.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sentor_python_sdk-2.0.0.tar.gz
Algorithm Hash digest
SHA256 53befeabad788103f5a09d8709986e157a7a692761fdbf14b1b1eda5c0430827
MD5 9ed0367ba8a2d016c82e585fc331a5a9
BLAKE2b-256 cf34d41d2cf96d63a7d36f2ea60d451cb6f05fb9451209a7e7e2eac5ba7c8ee7

See more details on using hashes here.

Provenance

The following attestation bundles were made for sentor_python_sdk-2.0.0.tar.gz:

Publisher: publish.yml on NIKX-Tech/sentor-python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sentor_python_sdk-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sentor_python_sdk-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a9448815453917a489f42c2eda32c139dd457d44d16b2b75823a55231391fa44
MD5 ed966c332bbc13a6bb087689d17b4cf3
BLAKE2b-256 0db03ff8b6c7839996e548a0c6c6fac8b317aa7df5e08f2d41688a2a0068e0e5

See more details on using hashes here.

Provenance

The following attestation bundles were made for sentor_python_sdk-2.0.0-py3-none-any.whl:

Publisher: publish.yml on NIKX-Tech/sentor-python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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