SDKs overview

Semantria provides a suite of software development kits (SDKs) and client libraries designed to facilitate interaction with its text analytics API. These SDKs abstract the underlying RESTful API endpoints, handling authentication, request formatting, and response parsing, thereby reducing the development effort required to integrate advanced natural language processing (NLP) features into applications. The primary goal of these SDKs is to enable developers to quickly implement sentiment analysis, entity extraction, text categorization, and other core Semantria functionalities without needing to manage raw HTTP requests or JSON serialization directly. The available SDKs support commonly used programming languages, ensuring broad compatibility across various development environments and project requirements Semantria documentation.

Developers who prefer not to use an SDK can interact directly with the Semantria API 2.0 reference using standard HTTP clients. The API is REST-based and typically communicates using JSON payloads. However, using the provided SDKs can often accelerate development due to their pre-built methods for common API operations and error handling routines. For instance, an SDK might offer a single method call to analyze a document, whereas a direct API integration would require constructing the HTTP POST request, adding authentication headers, and structuring the JSON body manually.

Official SDKs by language

Semantria offers official SDKs for several popular programming languages, each maintained to ensure compatibility with the latest API versions and functionalities. These SDKs are typically available through standard package managers for each respective language, simplifying installation and dependency management. Each SDK encapsulates the logic for authenticating requests, sending data to Semantria's API, and processing the structured JSON responses Semantria developer resources.

Language Package Manager Typical Install Command Maturity / Support
.NET (C#) NuGet Install-Package Semantria.API Official, Actively Maintained
Java Maven / Gradle Add dependency to pom.xml or build.gradle Official, Actively Maintained
PHP Composer composer require semantria/semantria Official, Actively Maintained
Python pip pip install semantria Official, Actively Maintained
Ruby RubyGems gem install semantria Official, Actively Maintained
Node.js npm npm install semantria Official, Actively Maintained

The choice of SDK often depends on the existing technology stack of a project. For instance, developers working on a backend service built with Java would find the Java SDK most suitable, while front-end Node.js applications might benefit from the Node.js client library. Each SDK aims to provide an idiomatic interface consistent with the conventions of its respective programming language, minimizing the learning curve for developers already familiar with that ecosystem.

Installation

Installation of Semantria SDKs typically follows the standard practices for each language's ecosystem. The examples below cover the most common installation methods. Before installing, ensure you have the correct package manager and language runtime configured for your development environment.

.NET (C#)

For .NET projects, the Semantria SDK is distributed via NuGet. You can install it using the NuGet Package Manager Console in Visual Studio or via the .NET CLI.

# NuGet Package Manager Console
Install-Package Semantria.API

# .NET CLI
dotnet add package Semantria.API

Java

Java developers can add the Semantria SDK as a dependency using Maven or Gradle, integrating it into their project's build process.

Maven: Add the following to your pom.xml:

<dependency>
    <groupId>com.semantria</groupId>
    <artifactId>semantria-api</artifactId>
    <version>[latest_version]</version> <!-- Replace with actual latest version -->
</dependency>

Gradle: Add the following to your build.gradle:

implementation 'com.semantria:semantria-api:[latest_version]' // Replace with actual latest version

PHP

The PHP SDK is available via Composer, PHP's dependency manager.

composer require semantria/semantria

Python

Python developers can install the SDK using pip, the standard package installer for Python.

pip install semantria

Ruby

The Ruby SDK is published as a RubyGem and can be installed using the gem command.

gem install semantria

Node.js

For Node.js applications, the SDK is available through npm, the Node.js package manager.

npm install semantria

After installation, the SDK typically requires configuration with your Semantria API key and secret, which are obtained from your Semantria account dashboard Semantria pricing and plans. These credentials authenticate your requests and ensure proper billing and access control.

Quickstart example

This Python quickstart demonstrates basic document processing using the Semantria SDK. The example initializes the Semantria client, configures language, queues a document for analysis, and retrieves the results. Before running, replace placeholder API keys with your actual Semantria credentials.

import semantria
import time

# Replace with your actual API Key and API Secret
CONSUMER_KEY = "YOUR_SEMANTRIA_API_KEY"
CONSUMER_SECRET = "YOUR_SEMANTRIA_API_SECRET"

# Initialize Semantria client
# The 'analyze' method takes a document or a list of documents
# The 'batch' method can be used for larger collections of text
session = semantria.Session(CONSUMER_KEY, CONSUMER_SECRET)

# Configure session settings (optional, e.g., language)
# You can check available configurations via session.getConfigurations()
# session.setLanguage("English") # Example: set language

# Example document for analysis
document_text = "Semantria's sentiment analysis is very accurate and helpful for understanding customer feedback. However, their pricing structure could be clearer."

print(f"Analyzing document: '{document_text[:70]}...'\n")

# Queue document for analysis
# The 'id' field is optional but useful for tracking documents
doc_id = "test_document_123"
queue_status = session.queueDocument({"id": doc_id, "text": document_text})

if queue_status:
    print("Document queued successfully. Awaiting processing...")
else:
    print("Failed to queue document.")
    exit()

# Poll for results (Semantria processes asynchronously)
results = []
MAX_RETRIES = 10
retries = 0

while len(results) < 1 and retries < MAX_RETRIES:
    time.sleep(2) # Wait 2 seconds before polling again
    results = session.getProcessedDocuments()
    print(f"Polling for results... Found {len(results)} processed documents. (Attempt {retries+1}/{MAX_RETRIES})")
    retries += 1

if results:
    for doc in results:
        if doc['id'] == doc_id:
            print("\n--- Analysis Results ---")
            print(f"Document ID: {doc['id']}")
            print(f"Overall Sentiment Score: {doc.get('sentiment_score', 'N/A')}")

            # Extract entities
            if 'entities' in doc:
                print("Entities:")
                for entity in doc['entities']:
                    print(f"  - {entity['title']} (Type: {entity.get('entity_type', 'N/A')}, Sentiment: {entity.get('sentiment_score', 'N/A')})")
            else:
                print("No entities found.")

            # Extract themes
            if 'themes' in doc:
                print("Themes:")
                for theme in doc['themes']:
                    print(f"  - {theme['title']} (Sentiment: {theme.get('sentiment_score', 'N/A')})")
            else:
                print("No themes found.")

            # Extract opinions (if available)
            if 'opinions' in doc:
                print("Opinions:")
                for opinion in doc['opinions']:
                    print(f"  - Target: {opinion.get('target', 'N/A')}, Category: {opinion.get('category', 'N/A')}, Sentiment: {opinion.get('sentiment_score', 'N/A')}")
            else:
                print("No opinions found.")

else:
    print("\nNo results retrieved after multiple attempts. Check API keys and document processing status.")

This example illustrates how to submit text and retrieve structured analysis results, including sentiment, entities, and themes. The asynchronous nature of Semantria's processing means applications must poll for results after queuing documents, as shown by the time.sleep and polling loop. Efficient polling strategies are crucial for applications processing large volumes of text Google's explanation of asynchronous processing in ML, as they prevent unnecessary API calls and manage resource consumption.

Community libraries

While Semantria maintains a set of official SDKs, the broader developer community may contribute additional client libraries, integrations, or tools. These community-driven projects can sometimes offer experimental features, specialized wrappers for specific frameworks, or alternative implementations that cater to niche requirements. However, community libraries are not officially supported by Semantria and may not always be up-to-date with the latest API changes or fully cover all features.

Developers interested in community contributions should typically search platforms like GitHub, PyPI (for Python), npm (for Node.js), or other language-specific package repositories using keywords such as "semantria client," "semantria API wrapper," or "semantria integration." Before integrating any community-developed library into a production environment, it is advisable to assess its active maintenance, community support, and compatibility with the official Semantria API documentation to ensure stability and security. The official SDKs are generally recommended for mission-critical applications due to direct vendor support and guaranteed compatibility official Semantria documentation.