SDKs overview
Irisnet offers a suite of Software Development Kits (SDKs) and client libraries designed to simplify integration with its content moderation API. These tools abstract the complexities of HTTP requests, authentication, and data parsing, allowing developers to focus on implementing content policy enforcement and identifying illicit content within their applications. The primary goal of these SDKs is to provide a language-specific interface for interacting with the core Irisnet API, which processes images and videos for detection of graphic material and other policy violations.
The available SDKs are developed and maintained by Irisnet to ensure compatibility and leverage the latest API features. They typically include methods for uploading media, configuring moderation checks, and retrieving analysis results. Utilizing an SDK can reduce development time and potential errors compared to making raw HTTP requests directly to the Irisnet API reference documentation. Furthermore, community-contributed libraries may extend functionality or provide support for additional programming languages, though their maintenance status can vary.
Official SDKs by language
Irisnet provides official SDKs for several popular programming languages, ensuring robust and supported integration paths for developers. These SDKs are designed to align with the Irisnet API's capabilities for automated image and video moderation. They typically handle tasks such as API key management, request serialization, and response deserialization, streamlining the process of sending media for analysis and receiving moderation feedback. The official SDKs are regularly updated to reflect new API features and improvements, providing a consistent and reliable development experience.
| Language | Package Name | Installation Command | Maturity |
|---|---|---|---|
| Python | irisnet-python |
pip install irisnet-python |
Stable |
| Node.js | irisnet-nodejs |
npm install irisnet-nodejs |
Stable |
| PHP | irisnet-php |
composer require irisnet/php-sdk |
Stable |
Installation
Installing an Irisnet SDK typically involves using the package manager specific to your chosen programming language. These commands fetch the necessary libraries and their dependencies from their respective repositories, making them available for use in your project. Ensure you have the correct package manager installed and configured for your development environment before proceeding.
Python SDK Installation
To install the official Python SDK, use pip, Python's package installer. This command retrieves the irisnet-python package from the Python Package Index (PyPI).
pip install irisnet-python
After installation, you can import the library into your Python scripts and begin interacting with the Irisnet API. For detailed usage instructions, refer to the Irisnet Python SDK documentation.
Node.js SDK Installation
For Node.js projects, the npm (Node Package Manager) command is used to install the SDK. This adds irisnet-nodejs to your project's node_modules directory and updates your package.json file.
npm install irisnet-nodejs
Once installed, you can require the module in your JavaScript or TypeScript files. The Irisnet Node.js SDK guide provides examples for common moderation tasks.
PHP SDK Installation
PHP developers can install the Irisnet SDK using Composer, the dependency manager for PHP. This command adds the irisnet/php-sdk package to your project.
composer require irisnet/php-sdk
After running this command, Composer's autoloader will make the SDK classes available in your PHP application. Consult the Irisnet PHP SDK examples for integration patterns.
Quickstart example
This Python quickstart demonstrates how to initialize the Irisnet SDK, configure an API key, and submit an image URL for moderation. The example focuses on a basic image analysis request, which is a common use case for content policy enforcement.
Before running this code, ensure you have an Irisnet API key, which can be obtained by signing up for an account on the Irisnet homepage. Irisnet offers a free tier with 100 credits to get started.
import os
from irisnet.client import IrisnetClient
from irisnet.models import ImageRequest
# Replace with your actual Irisnet API key
API_KEY = os.environ.get("IRISNET_API_KEY", "YOUR_IRISNET_API_KEY")
def moderate_image(image_url):
try:
client = IrisnetClient(api_key=API_KEY)
# Create an ImageRequest object with the URL of the image to moderate
image_request = ImageRequest(url=image_url)
# Submit the image for moderation
print(f"Submitting image for moderation: {image_url}")
result = client.check_image(image_request)
# Print the moderation results
print("\nModeration Results:")
print(f" Status: {result.status}")
print(f" Overall Score: {result.overall_score}")
if result.labels:
print(" Detected Labels:")
for label in result.labels:
print(f" - {label.name}: {label.score:.2f} (Category: {label.category})")
if result.raw_response:
print(" Raw Response (first 200 chars):", str(result.raw_response)[:200], "...")
return result
except Exception as e:
print(f"An error occurred during image moderation: {e}")
return None
# Example usage with a placeholder image URL
if __name__ == "__main__":
# Use a safe, publicly accessible image URL for testing
test_image_url = "https://www.example.com/safe_image.jpg"
# For a real scenario, replace with an actual image URL to be moderated
moderation_output = moderate_image(test_image_url)
if moderation_output:
print("\nImage moderation process completed.")
This example demonstrates the fundamental steps: client initialization, request object creation, and API call execution. The check_image method sends the image to Irisnet's servers for analysis. The response object, result, contains the moderation outcome, including status, overall score, and any detected labels for content categories like graphic material or hate speech. Developers can then use these results to implement automated actions within their applications, such as flagging content for review or blocking it entirely. For more advanced features, such as video moderation or custom rule sets, developers should consult the Irisnet developer documentation.
Community libraries
Beyond the official SDKs, the Irisnet ecosystem may include community-contributed libraries and integrations. These libraries are developed and maintained by third-party developers and can offer support for additional programming languages, frameworks, or specialized use cases not covered by the official offerings. While community libraries can provide flexibility and extend accessibility, their maintenance, support, and feature set may vary compared to official SDKs.
Developers considering community libraries should evaluate their active development status, documentation quality, and community support channels. Checking the project's GitHub repository or other public code platforms for recent commits, open issues, and pull requests can provide insight into its health and reliability. For instance, a project with numerous open issues and infrequent updates might not be suitable for production environments requiring high stability.
As Irisnet's core service focuses on machine learning for content moderation, developers in the broader machine learning community often utilize general-purpose tools for data handling and API interaction. For example, Python's requests library is a popular choice for direct HTTP requests when an official SDK is not available or a custom integration is preferred, as detailed in the Mozilla Developer Network's HTTP status codes guide. Similarly, for JavaScript environments, the fetch API or libraries like axios are commonly used to interact with RESTful services. While these are not Irisnet-specific, they form the foundation upon which many custom or community-driven integrations are built. Developers are encouraged to explore community forums or GitHub for any publicly available Irisnet-related projects that align with their specific needs.