Skip to main content

Karboni

Mirror a Zotero library into a SQL database.

Features

  • Fast one-way synchronization from Zotero to a SQL database.
  • Fetch library items, collections, tags, saved searches metadata.
  • Download file attachments.
  • Fetch formatted references in multiple bibliographic styles, for multiple locales.
  • Fetch multiple export formats.
  • Fetch the full text content of items.
  • Fetch the labels of item types, field names and creator types, for multiple locales.
  • Python API for managing synchronization.
  • Command line interface for managing synchronization.
  • Support for a wide range of database systems (through SQLAlchemy).

Installation

It is recommended that you install the package in a virtual environment.

The installation steps might look like the following. Replace DIR with the desired path for your new virtual environment.

Unix/macOS

Create the virtual environment:

python3 -m venv DIR

Activate the virtual environment:

source DIR/bin/activate

Install Karboni:

python3 -m pip install karboni

Windows

Create the virtual environment:

py -m venv DIR

Activate the virtual environment:

DIR\Scripts\activate

Install Karboni:

py -m pip install karboni

Command line interface

In order to use the command line interface, you must first configure your Zotero credentials. With a text editor, create a .env file in your working directory with the following content:

ZOTERO_LIBRARY_PREFIX=your_library_prefix
ZOTERO_LIBRARY_ID=your_library_id
ZOTERO_API_KEY=your_api_key

Replace your_library_prefix with users for a personal library, or groups for a group library.

Replace your_library_id with the identifier of your library. For a personal library the value is your user ID, as found on https://www.zotero.org/settings/keys (you must be logged-in). For a group library this value is the group ID of the library, as found in the URL of the library (e.g., the group ID of the library at https://www.zotero.org/groups/1234567/example is 1234567).

Replace your_api_key with your Zotero API key. You may create one for your library on https://www.zotero.org/settings/keys/new (you must be logged-in). Karboni does not need to write to your library. Thus, we recommend that your API key be read-only, and that it does not grant any more access to your Zotero data than strictly necessary.

By default, Karboni commands will manage data in a data/karboni directory under your current directory, and use SQLite as the relational database. You may change those defaults by setting the following variables in your .env file:

  • KARBONI_DATA_PATH. Defaults to ./data/karboni/ZOTERO_LIBRARY_PREFIX-ZOTERO_LIBRARY_ID/. If the directory does not already exists, Karboni will create it.
  • KARBONI_DATABASE_URL. Defaults to sqlite:///data/karboni/ZOTERO_LIBRARY_PREFIX-ZOTERO_LIBRARY_ID/library.sqlite. When using SQLite, the directory specified in the database URL must either exist prior to running the Karboni command, or match the directory specified by KARBONI_DATA_PATH. For other relational databases, see the SQLAlchemy documentation on database URLs. While SQLite support is readily available through the Python standard library, other database backends usually require that you install additional Python packages.

Once the required variables have been set, you may use Karboni commands. If you have installed Karboni in a virtual environment, make sure it is active before attempting to use the commands (see the activation command in the Installation section). Some example commands below.

Initialize the mirror database (create the tables):

karboni init

Synchronize from Zotero:

karboni sync

List the available commands and general options:

karboni --help

List the options of a specific command:

karboni COMMAND --help

A more complex example, synchronizing from Zotero with some data options enabled — format references in APA and Vancouver styles, fetch BibTeX and RIS formats, download file attachments, fetch any available full text:

karboni sync --style apa --style vancouver --export-format bibtex --export-format ris --files --fulltext

Once an initial synchronization has completed, subsequent invocations of the karboni sync command will perform incremental synchronization by default, i.e., fetching just the modified data from Zotero. However, that only works if you use the same data options as on the initial synchronization. To change the data options, add the --full option to force a full synchronization. For example:

karboni sync --style apa-5th-edition --full

For the formatting styles available for the --style option, refer to the Zotero Style Repository.

For the export formats available for the --export-format option, refer to the Zotero API documentation on export formats.

For the locales available for the --locale option, refer to the Citation Style Language locales. Note that some styles use a fixed locale and will ignore the --locale option.

Python interface

The karboni Python module provides the main entry points, with functions such as initialize() and synchronize().

If you wish to use the SQLAlchemy ORM to query the database, you might want to import models from karboni.database.schema.

Design choices

Here are some of the design choices that have guided the development of Karboni:

  • Perform Zotero API requests and file IO asynchronously to minimize idle time.
  • Use SQLite as the baseline database system (reducing the need for additional dependencies), but interface it through SQLAlchemy in order to support other databases as well.
  • Since Karboni itself only needs a few simple database operations, encapsulate SQLAlchemy under a thin abstraction layer to decouple the synchronization process from the database toolkit. Thus, only the database module has direct SQLAlchemy dependencies.
  • Stay close to the Zotero schema. Store data in the JSON format provided by the Zotero API whenever possible, for consistency and better adaptability to future Zotero schema changes. Add SQL columns where they can be useful to the synchronization process or to allow basic queries.
  • Don't fuss too much with database-level referential integrity constraints. Leave that to Zotero. In particular, the keys of parent items and parent collections are not validated (this simplifies the synchronization process).
  • Don't worry about database schema migrations. The database is just a mirror, thus its tables can be wiped when necessary and re-synchronized from Zotero.
  • Synchronization of file attachments is not atomic. If library synchronization finishes but file downloads fail, we accept that and don't rollback the database changes.

Known limitations

  • Database operations are synchronous because SQLAlchemy cannot (at least not easily) share a session between concurrent tasks.
  • During transactions, SQLite locks database access from other threads or processes. When synchronizing from Zotero, Karboni applies all changes in a single transaction (to allow rollback in case of failure), which means the database can remain locked for some time. To ensure availability during synchronization, use a database system that has more advanced locking mechanisms (such as PostgreSQL or MariaDB/MySQL).
  • Python 3.11+ is required (it facilitates exception handling with asynchronous tasks).

Metadata

Release files for Karboni 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Karboni 0.2.1
File Size Uploaded Provenance Actions
karboni-0.2.1.tar.gz 46.2 kB Without provenance Details for karboni-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for Karboni 0.2.1
File Interpreter ABI Platform Actions
karboni-0.2.1-py3-none-any.whl Python 3 none any Details for karboni-0.2.1-py3-none-any.whl

Total release size: 96.9 kB

Release files / karboni-0.2.1.tar.gz

Download URL karboni-0.2.1.tar.gz
Size 46.2 kB
Tags Source
SHA-256 checksum
How to use checksums
078055d786bb0449717984a764623dd2c1fe1a196ea682b5fff23114dfecaf1d
BLAKE2b-256 checksum
How to use checksums
915d0d1380d812ff509b711e49522fb13ee0fbf3707b4bdcc4fd223c9a5c0846
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Hatch/1.18.1 {"ci":null,"cpu":"x86_64","distro":{"id":"resolute","libc":{"lib":"glibc","version":"2.43"},"name":"Ubuntu","version":"26.04"},"implementation":{"name":"CPython","version":"3.14.4"},"installer":{"name":"hatch","version":"1.18.1"},"openssl_version":"OpenSSL 3.5.5 27 Jan 2026","python":"3.14.4","system":{"name":"Linux","release":"7.0.0-38-generic"}} HTTPX2/2.16.0

Release files / karboni-0.2.1-py3-none-any.whl

Download URL karboni-0.2.1-py3-none-any.whl
Size 50.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
30ed4d4a5631611874ad40e1a664f5eecf7fb6b2be4d5a403a49189c094cd1f9
BLAKE2b-256 checksum
How to use checksums
6ec30a17b73f2dc6decaa0404080c24106ed2b3baa5e7db8649b4cff0b0bce63
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Hatch/1.18.1 {"ci":null,"cpu":"x86_64","distro":{"id":"resolute","libc":{"lib":"glibc","version":"2.43"},"name":"Ubuntu","version":"26.04"},"implementation":{"name":"CPython","version":"3.14.4"},"installer":{"name":"hatch","version":"1.18.1"},"openssl_version":"OpenSSL 3.5.5 27 Jan 2026","python":"3.14.4","system":{"name":"Linux","release":"7.0.0-38-generic"}} HTTPX2/2.16.0

Security for Karboni 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page