1.0.98 • Published 2 months ago

zotero-lib v1.0.98

Weekly downloads
616
License
ISC
Repository
github
Last release
2 months ago

zotero-lib

Introduction

Tools for working with the APIs of Zotero and Zenodo (zotzen)

This repository is part of a set of repositories, see here. Currently, this set contains a number of libraries

(The above tools can also be installed as command-line tools (CLI) with npm -g.)

And a web application

This code builds on earlier code for zotero-cli, which was developed by @bjohas, @retorquere and @a1diablo.

Installation

Install this library in a module with

npm install zotero-lib
yarn add zotero-lib

or as global CLI

npm install -g zotero-lib
yarn global add zotero-lib

View entry on npm

Use of the library and the CLI

The directory tests/ contains a number of tests that illustrate the use of the npm library. The file tests/test_cli.sh has examples for use of the library from the command line.

CLI Documentation

The zotero-cli allows you to access zoter from cmd line, it allows you to automate redundant taskse easily

Basic usage

Help

zotero-lib -h
zotero-lib --help

This will print help for all commands and options accepted by zotero-lib

Version

zotero-lib -v
zotero-lib --version

This will print the version of cli you have installed

create

This allows you to create item(s). You can create items in two different ways either by providing file containg json or json items as string

Both of these options can be used by providing following arguments

  • --files - this accepts text files containing json
  • --items - this accepts items as json string

Note: You must use only one of these at a time

Examples

zotero-lib create --files filepath.txt
zotero-lib create --items '{"title": "zotero item 1", "itemType": "book"}' '{"title": "zotero item 2", "itemType": "book"}'

update

This sub-command can be used to update existing items

zotero-lib update --key key-here --json '{"title": "zotero item 1 updat", "itemType": "book"}'
zotero-lib update --key key-here --file filepath.txt

You can also specify option replace which completely replace existing item and only keep provided information

zotero-lib update --replace --key key-here --json '{"title": "zotero item 1 updat", "itemType": "book"}'

item

This sub-command has various use cases

To fetch item

zotero-lib item --key key-here

To add files

zotero-lib item --key key-here --addfiles test.json

items

This sub-command can be used to fetch items with various filters

zotero-lib items --filter '{"limit": 10}'

collection

collections

publications

tags

attachment

types

groups

fields

searches

key

field

update-url

get-doi

update-doi

enclose-item

attach-link

attach-note

kciaka

bibliography

Local Database Syncing

You can use this cli to locally backup your online zotero library. The db cmd allows you to sync online library in local sqlite database. On first run all online records are synced into local database. On subsequent runs only those records are fetched, which were modifed since last sync.

The underlying database is SQLite. You dont need to install any server or anything it will work out of box as SQLite comes bundled with this cli.

To use this cmd you need to provide your db name along with one or more options. The options which you can specify are detailed below.

--sync make local db synced with online library
--lookup allow you to lookup specific items in the local db
--keys this must be used with --lookup to specify specfic keys you want to locate
--lockfile name of lock file to be used, default is "sync.lock" --lock-timeout if a lock file already exist, how much older it should be to classify it as outdated, if its outdated it will be removed and a new one will be generated --export-json=<file-name.json> export localdb as json with given file-name.json
--demon=<valid-cron-pattern this will make the sync process run in demon mode, where it will peridically sync by itself, see https://crontab.guru to learn about crontab pattern
--errors this will list all inconsistent items which have non zero children and non zero references

These options are optional and can be combined as required. If all options are specified then they will be read/applied in above order.

Examples

To sync given db file backup.db with online version

zotero-cli db backup.db --sync

To export give db file backup.db as json file ./backup.json

zotero-cli db backup.db --export-json="./backup.json"

You can combine previous two steps in one cmd

zotero-cli db backup.db --sync --export-json="./backup.json"

Also see

zotero-api-client (With hindsight we might have built on zotero-api-client - we might still rebuild our code to use zotero-api-client.)

1.0.98

2 months ago

1.0.97

2 months ago

1.0.96

2 months ago

1.0.91

6 months ago

1.0.90

6 months ago

1.0.95

5 months ago

1.0.93

5 months ago

1.0.92

6 months ago

1.0.84

1 year ago

1.0.87

12 months ago

1.0.86

1 year ago

1.0.85

1 year ago

1.0.89

12 months ago

1.0.83

2 years ago

1.0.80

2 years ago

1.0.81

2 years ago

1.0.77

3 years ago

1.0.79

2 years ago

1.0.78

2 years ago

1.0.76

3 years ago

1.0.75

3 years ago

1.0.74

3 years ago

1.0.73

3 years ago

1.0.69

3 years ago

1.0.72

3 years ago

1.0.71

3 years ago

1.0.70

3 years ago

1.0.67

3 years ago

1.0.66

3 years ago

1.0.62

3 years ago

1.0.61

3 years ago

1.0.60

3 years ago

1.0.64

3 years ago

1.0.63

3 years ago

1.0.59

3 years ago

1.0.58

3 years ago

1.0.57

3 years ago

1.0.56

3 years ago

1.0.55

3 years ago

1.0.54

3 years ago

1.0.51

3 years ago

1.0.53

3 years ago

1.0.52

3 years ago

1.0.48

3 years ago

1.0.49

3 years ago

1.0.50

3 years ago

1.0.47

3 years ago

1.0.46

3 years ago

1.0.45

3 years ago

1.0.43

3 years ago

1.0.42

3 years ago

1.0.39

3 years ago

1.0.38

3 years ago

1.0.40

3 years ago

1.0.41

3 years ago

1.0.37

3 years ago

1.0.36

3 years ago

1.0.35

3 years ago

1.0.34

3 years ago

1.0.33

3 years ago

1.0.32

3 years ago

1.0.31

3 years ago

1.0.30

3 years ago

1.0.29

3 years ago

1.0.28

3 years ago

1.0.27

3 years ago

1.0.26

3 years ago

1.0.25

3 years ago

1.0.24

3 years ago

1.0.23

3 years ago

1.0.22

3 years ago

1.0.21

3 years ago

1.0.20

3 years ago

1.0.19

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.9

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.2

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.1

3 years ago