Skip to content

zotero_tools

Programmatic access to Zotero libraries.

create_zot_client

create_zot_client(
    api_key, library_id, library_type="group"
)

Create a Zotero client bound to a library.

The item methods of the client only operate on this library.

Parameters:

Name Type Description Default
api_key str

Zotero API key with read access to the library.

required
library_id int

id of the user or group library.

required
library_type str

group or user.

'group'

Returns:

Type Description
Zotero

The client.

get_items

get_items(zot, show=False, limit=None)

Get the top level items of the library.

Parameters:

Name Type Description Default
zot Zotero

client of the library, see create_zot_client.

required
show bool

print the items to the console.

False
limit int | None

maximal number of items; all items if None.

None

Returns:

Type Description
list[dict[str, Any]]

The items as returned by the Zotero API.

pmid_from_extra

pmid_from_extra(extra)

Get the PubMed id from the extra field of a Zotero item.

Parameters:

Name Type Description Default
extra str | None

extra field with one key: value per line, e.g., PMID: 27267043 and PMCID: PMC4895977.

required

Returns:

Type Description
str | None

The PubMed id or None.

create_tag_table

create_tag_table(items, tags_set, tag_prefixes)

Create a table of the items with the selected tags.

A tag is selected if it is in tags_set or starts with one of the tag_prefixes. Every selected tag is a boolean column, which is True for the items with the tag.

Parameters:

Name Type Description Default
items Iterable[dict[str, Any]]

items of a library, see get_items.

required
tags_set Iterable[str]

tags to select.

required
tag_prefixes Iterable[str]

prefixes of the tags to select, e.g., "species:".

required

Returns:

Type Description
DataFrame

The table with the columns key, doi, pubmed and one column per

DataFrame

selected tag.