scanii
Official Rust SDK for the Scanii content security API.
SDK Principles
- Light. Zero runtime dependencies, stdlib only.
- Up to date. Always current with the latest Scanii API.
- Integration-only. Wraps the REST API — retries, concurrency, and batching are the caller's responsibility.
About "Light" in Rust
The Rust standard library has no HTTP client and no TLS. True zero-dep is impossible for an HTTPS SDK. This crate uses the smallest viable dependency set:
ureq— synchronous HTTP client, designed for minimal deps. Pullsrustlstransitively via thetlsfeature.serde+serde_json— the de-facto JSON standard.
That's the entire runtime dependency surface. No tokio, no hyper, no reqwest, no openssl. rustls is intentionally not a direct dependency — it is pulled by ureq's tls feature so the version stays in lockstep with ureq's transitive choice.
Install
Targets current stable Rust.
Quickstart
use ScaniiClient;
findings is a Vec<String>. An empty vector means the content is clean.
A runnable version is at examples/quickstart.rs — invoke with:
SCANII_KEY=key SCANII_SECRET=secret SCANII_ENDPOINT=http://localhost:4000 \
Scanning from any Read source
use ScaniiClient;
use Cursor;
#
process and process_async accept any impl Read and stream the body without buffering, so memory use is independent of content length.
API
| Method | REST | Returns |
|---|---|---|
process(reader, filename, content_type, metadata, callback) |
POST /files |
Result<ScaniiProcessingResult> |
process_file(path, metadata, callback) |
POST /files |
Result<ScaniiProcessingResult> |
process_async(reader, filename, content_type, metadata, callback) |
POST /files/async |
Result<ScaniiPendingResult> |
process_async_file(path, metadata, callback) |
POST /files/async |
Result<ScaniiPendingResult> |
process_from_url(location, metadata) (preview) |
POST /files |
Result<ScaniiProcessingResult> |
fetch(url, metadata, callback) |
POST /files/fetch |
Result<ScaniiPendingResult> |
retrieve(id) |
GET /files/{id} |
Result<ScaniiProcessingResult> |
retrieve_trace(id) (preview) |
GET /files/{id}/trace |
Result<Option<ScaniiTraceResult>> |
ping() |
GET /ping |
Result<()> |
create_auth_token(timeout_seconds) |
POST /auth/tokens |
Result<ScaniiAuthToken> |
retrieve_auth_token(id) |
GET /auth/tokens/{id} |
Result<ScaniiAuthToken> |
delete_auth_token(id) |
DELETE /auth/tokens/{id} |
Result<()> |
Full API reference: https://scanii.github.io/openapi/v22/.
Regional endpoints
use ScaniiClient;
let client = builder
.key
.secret
.endpoint
.build
.unwrap;
| Region | Endpoint |
|---|---|
| Auto (default) | https://api.scanii.com |
| US 1 | https://api-us1.scanii.com |
| EU 1 | https://api-eu1.scanii.com |
| EU 2 | https://api-eu2.scanii.com |
| AP 1 | https://api-ap1.scanii.com |
| AP 2 | https://api-ap2.scanii.com |
| CA 1 | https://api-ca1.scanii.com |
Errors
use ;
#
Per SDK Principle 3, the SDK does not retry on the caller's behalf — backoff and retry policy belong to your application.
Local testing with scanii-cli
The SDK ships integration tests against scanii-cli, a local mock server. No real Scanii credentials are needed.
Override the endpoint by exporting SCANII_TEST_ENDPOINT=... before cargo test. Tests self-skip when scanii-cli is not reachable, so cargo test is safe to run in any environment.
Auth tokens
Mint a short-lived token server-side and authenticate with it from a less-trusted client:
# use ScaniiClient;
#
Contributing
Bug reports and PRs welcome at https://github.com/scanii/scanii-rust/issues.