SDKs overview

Scanii offers Software Development Kits (SDKs) to facilitate integration with its malware and content scanning API. These SDKs are designed to abstract the underlying HTTP requests and JSON parsing, allowing developers to interact with the Scanii service using native language constructs. The primary goal of these libraries is to simplify the process of submitting files or content for scanning and retrieving the results, thereby reducing the boilerplate code required for secure application development. Scanii's API is a RESTful service, and the SDKs provide a client-side wrapper for these interactions, handling authentication, request formatting, and response parsing automatically.

The availability of SDKs for multiple programming languages supports a broad range of development environments, from web applications built with Ruby on Rails or Node.js to backend services written in Java or Go. Each SDK is maintained to align with the latest API versions and best practices, ensuring compatibility and security for developers implementing Scanii's scanning capabilities. The official documentation provides detailed guides on how to use each SDK, including authentication methods and specific function calls for various scanning operations.

Official SDKs by language

Scanii provides official SDKs for several popular programming languages, each designed to offer a consistent and idiomatic interface for its API. These libraries are maintained by Scanii and are generally the recommended approach for integrating the service into new or existing applications. The official SDKs ensure compatibility with the latest API features and security standards, as detailed in the Scanii developer documentation.

Language Package Manager/Repository Installation Command Maturity
Ruby RubyGems gem install scanii-ruby Stable
Python PyPI pip install scanii-python Stable
Java Maven Central <dependency><groupId>com.scanii</groupId><artifactId>scanii-java</artifactId><version>[latest_version]</version></dependency> Stable
Node.js npm npm install scanii-nodejs Stable
PHP Composer composer require scanii/scanii-php Stable
Go Go Modules go get github.com/scanii/scanii-go Stable

Each SDK is developed to follow the conventions and practices of its respective language ecosystem, providing a familiar experience for developers. For instance, the Python SDK adheres to PEP 8 guidelines, while the Java SDK follows standard Java enterprise patterns. This commitment to idiomatic design helps developers quickly integrate Scanii's capabilities without significant learning curve overhead. For specific versioning and detailed API method calls, developers should consult the Scanii API reference.

Installation

Installing Scanii SDKs typically involves using the standard package manager for the target programming language. The process is designed to be straightforward, allowing developers to quickly add the library to their project dependencies. Below are common installation instructions for the officially supported SDKs:

Ruby

For Ruby projects, the Scanii SDK is distributed as a gem. You can install it using Bundler or directly via the gem command:

gem install scanii-ruby

Alternatively, add it to your Gemfile:

# Gemfile
gem 'scanii-ruby'

Then run bundle install.

Python

The Python SDK is available on PyPI and can be installed using pip:

pip install scanii-python

Java

For Java projects, the Scanii SDK is available via Maven Central. Add the following dependency to your pom.xml (for Maven) or build.gradle (for Gradle):

<!-- Maven -->
<dependency>
    <groupId>com.scanii</groupId>
    <artifactId>scanii-java</artifactId>
    <version>[latest_version]</version>
</dependency>
// Gradle
implementation 'com.scanii:scanii-java:[latest_version]'

Replace [latest_version] with the current stable version found on the Scanii Java SDK documentation page.

Node.js

The Node.js SDK can be installed using npm:

npm install scanii-nodejs

Or with Yarn:

yarn add scanii-nodejs

PHP

For PHP projects, the Scanii SDK is available via Composer:

composer require scanii/scanii-php

Go

The Go SDK can be installed using go get:

go get github.com/scanii/scanii-go

After installation, ensure your project dependencies are updated, and you can then import the Scanii client into your code.

Quickstart example

This quickstart example demonstrates how to use the Scanii Python SDK to submit a file for scanning and retrieve the results. The process generally involves initializing the client with your API key and secret, then calling a scan method, and finally processing the response. For more detailed examples across all languages, refer to the Scanii API documentation.

Python Quickstart

First, ensure you have the scanii-python SDK installed (pip install scanii-python).

import os
import scanii

# Replace with your actual API key and secret
SCANI_API_KEY = os.environ.get('SCANI_API_KEY', 'YOUR_API_KEY')
SCANI_API_SECRET = os.environ.get('SCANI_API_SECRET', 'YOUR_API_SECRET')

# Initialize the Scanii client
# For EU region, use scanii.ScaniiClient(api_key, api_secret, region='eu')
client = scanii.ScaniiClient(SCANI_API_KEY, SCANI_API_SECRET)

def scan_local_file(filepath):
    try:
        print(f"Scanning file: {filepath}")
        # Submit the file for scanning
        # The submit_file method handles reading the file content
        result = client.submit_file(filepath)

        print(f"Scan ID: {result.id}")
        print(f"Resource URL: {result.resource_url}")
        print(f"Content Type: {result.content_type}")
        print(f"File Size: {result.content_length} bytes")
        print(f"SHA1: {result.sha1}")
        print(f"MD5: {result.md5}")
        print(f"Findings: {result.findings}")
        print(f"Processed: {result.processed}")

        if result.findings:
            print("!!! WARNING: Malware detected !!!")
            for finding in result.findings:
                print(f"  - {finding}")
        else:
            print("File is clean.")

    except scanii.ScaniiException as e:
        print(f"An error occurred: {e}")
    except FileNotFoundError:
        print(f"Error: File not found at {filepath}")
    except Exception as e:
        print(f"An unexpected error occurred: {e}")

# Create a dummy file for testing
dummy_file_path = "test_file.txt"
with open(dummy_file_path, "w") as f:
    f.write("This is a test file for Scanii scanning.")

# Call the scan function
scan_local_file(dummy_file_path)

# Clean up the dummy file
os.remove(dummy_file_path)

This script initializes the Scanii client using environment variables for credentials, then creates a temporary text file, submits it for scanning, and prints the scan results. The result.findings attribute will contain any detected threats or policy violations. This example demonstrates a common pattern for integrating file scanning into an application, which is crucial for securing user-generated content, as highlighted by resources like the Cloudflare WAF documentation on User-Generated Content.

Community libraries

While Scanii provides a comprehensive set of official SDKs, the open nature of its RESTful API allows for the development of community-contributed libraries and integrations. These third-party tools can extend Scanii's reach into languages or frameworks not officially supported, or offer specialized functionalities built on top of the core API. Community libraries are typically hosted on platforms like GitHub and are developed and maintained by individual developers or organizations outside of Scanii's direct control.

When considering community libraries, it is important to evaluate their maintenance status, documentation quality, and community support. Unlike official SDKs, their compatibility with the latest Scanii API versions or adherence to security best practices may vary. Developers should consult the respective project repositories for details on usage, licensing, and contribution guidelines. While Scanii does not officially endorse or support these libraries, they can offer valuable alternatives for specific use cases or development preferences. Developers can often find such projects by searching GitHub or other code repositories for "Scanii" alongside their desired programming language or framework.

For example, a community library might offer a specific integration with a popular web framework, simplifying the process of uploading and scanning files directly within that framework's ecosystem. Another might focus on asynchronous processing or batch scanning capabilities tailored to specific performance requirements. Developers are encouraged to contribute to these projects or share their own, fostering a broader ecosystem around the Scanii API, similar to how many API providers benefit from community-driven tools, as seen with platforms documented on Google's API Client Libraries.

Before using any community library in a production environment, it is advisable to perform a thorough review of its source code and verify its security implications and reliability. Always prioritize libraries that are actively maintained and have clear documentation to ensure a stable and secure integration with the Scanii service.