Simple Python proxy that gets a bibliography from Zotero in BibTeX format for usage in Overleaf.
Instead of using the Overleaf Zotero integration we are using the Zotero API, because
- the Overleaf integration is a paid feature, and
- other than the official integration we are able to access sub-collections.
As the official API is limited to 100 entries per request (and Overleaf does just one request), you have to add a second file if you have more entries. This proxy simplifies this by:
- querying Zotero multiple times (if required) until all entries can be returned at once,
- allowing you to set various API parameters in the environment where the proxy is deployed, so you don't have to add them to every URL you are adding to Overleaf,
- allowing you to query a sub-collection by name instead of by ID (that you have to get from the web-view or the API), and
- returning errors as the result of the request, so you see it in Overleaf and can understand what went wrong.
All variables are considered defaults and can be overwritten for every request.
ZOTERO_KEY
the key to be used for the requests (should only be able to get the group that you are using this proxy for)ZOTERO_GROUP
group ID used by defaultZOTERO_INCLUSION_STRATEGY
if you want to get the items from the collection including (=all
, default) or excluding (=only-self
) sub-collectionsZOTERO_FORMAT
the format the API returns (bibtex
(default) orbiblatex
)
group_id
same asZOTERO_GROUP
key
same asZOTERO_KEY
format
same asZOTERO_FORMAT
inclusion_strategy
same asZOTERO_INCLUSION_STRATEGY
collection_id
the ID (not the name) of the accessed collectionremove_comments
can be set totrue
to not include the logs at the top of the file
Use the path (that means the /
part after the domain) to name the collection.
This is ignored if collection_id
is set in the query parameters.
Use /
to denote sub-collections. collection
with sub-collection a
is denoted as collection/a
Due to the way collections are accessed via name, there might be conflicts
collection/a
(that is the name of the collection)
is the same as
collection
with sub-collectiona
.
Assuming ZOTERO_KEY
and ZOTERO_GROUP
are set on the server with domain example.com
use
example.com/collection/a
to access a collection.
example.com
will simply return the full library.
If the environment variables are not set, use
example.com/collection/a?key=...&group_id=&...
for the same result
A docker file is provided that runs a production-ready HTTP server on port 5000. For a real-world deployment, you should secure external connections using HTTPS; for example, by using a reverse proxy like nginx.