npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

zotero-ts-api

v1.0.11

Published

A TypeScript API wrapper for Zotero

Readme

Zotero-TS-API

Introduction

Zotero-TS-API is a TypeScript library that provides an intuitive interface for interacting with the Zotero API. Zotero is a reference management platform used by researchers, students, and professionals to organize their sources. This library allows you to manage libraries, collections, items, tags, and creators directly via API calls.

Key Features:

Connect to a Zotero library (user or group). Manage collections: create, update, delete, and retrieve. Manage items: create, update, delete, and retrieve. Manipulate metadata: creators and tags. Quick Start

Installation

Ensure you have Node.js installed, then install the library via npm:

npm install zotero-ts-api

Configuration

Create a .env file at the root of your project to store your Zotero credentials:

ZOTERO_API_KEY=your_api_key
ZOTERO_GROUP_ID=your_group_id

Example Usage

Here is a simple example to connect to a Zotero library and retrieve collections and items:

import { config } from 'dotenv';
import { Library } from 'zotero-ts-api';

// Load environment variables
config();

const apiKey = process.env.ZOTERO_API_KEY;
const groupId = process.env.ZOTERO_GROUP_ID;
const libraryType = 'groups'; // or 'users', then use a user API Key

(async () => {
  const library = new Library(apiKey, id, type);
  await library.connect();

  console.log(`Connected to library: ${library.name}`);

  const collections = await library.getCollections();
  console.log(`Found ${collections.length} collections`);

  const items = await library.getAllItems();
  console.log(`Found ${items.length} items`);

  items.forEach(item => {
    console.log(`Item Key: ${item.key}`);
    console.log(`Title: ${item.title}`);
    console.log(`Item Type: ${item.itemType}`);
    // item.delete(); // Suppression de l'élément    
  });
})();

References

Main Classes

Library

Represents a Zotero library.

  • Constructor :
constructor(apiKey: string, libId: string, libraryType: 'users' | 'groups')
  • Methods:
    • connect(): Promise: Connect to the library.
    • getCollections(): Promise<ZCollection[]>: Retrieve all collections.
    • getAllItems(): Promise<Item[]>: Retrieve all items.
    • createCollection(name: string, parentCollection?: string): Promise: - Create a new collection.
    • createItem(itemData: Partial): Promise: Create a new item.

ZCollection

Represents a collection in Zotero.

  • Constructor
constructor(data: ICollectionData, apiKey: string, id: string, type: 'users' | 'groups')
  • Methods:
    • getItems(): Promise<Item[]>: Retrieve items in the collection.
    • update(): Promise: Update the collection.
    • delete(): Promise: Delete the collection.

Item

Represents an item (bibliographic reference).

  • Constructor
constructor(data: IItemData, apiKey: string, id: string, type: 'users' | 'groups')
  • Methods:
    • update(): Promise: Update the item.
    • delete(): Promise: Delete the item.
    • addCreator(creator: ZCreator): void: Add a creator.
    • addTag(tag: ZTag): void: Add a tag.

ZCreator

Represents a creator (author, editor, etc.).

  • Constructor :
constructor(data: ICreatorData)

ZTag

Represents a tag associated with an item.

  • Constructor :
constructor(data: ITagData)

Below is a diagram illustrating the relationships between the main entities:

classDiagram
    class Library {
        +connect(): Promise<void>
        +getCollections(): Promise<ZCollection[]>
        +getAllItems(): Promise<Item[]>
        +createCollection(name: string, parentCollection?: string): Promise<ZCollection>
        +createItem(itemData: Partial<IItemData>): Promise<Item>
    }

    class ZCollection {
        +getItems(): Promise<Item[]>
        +update(): Promise<void>
        +delete(): Promise<void>
    }

    class Item {
        +update(): Promise<void>
        +delete(): Promise<void>
        +addCreator(creator: ZCreator): void
        +addTag(tag: ZTag): void
    }

    class ZCreator {
        +creatorType: string
        +firstName: string
        +lastName: string
    }

    class ZTag {
        +tag: string
        +type: number
    }

    Library --> ZCollection : "has many"
    ZCollection --> Item : "contains"
    Item --> ZCreator : "has many"
    Item --> ZTag : "has many"