Unattended export through a script

Hello,

I would like to create a script that would run on a linux server (without GUI) and that would export (in Bibtex format) all zotero entries of some public zotero group library to a file. Preferably the script should be portable (Windows / Linux).

That would be used to connect our new zotero managed DB to a legacy website requiring bibtex files. The script should ideally be run each time the content changes, or simply every day. Hence the need to run it on a server. Also the script needs to update a secure location on our web site directory, so it needs special privileges and need to be secured itself. Result of running the script should be the same as when a zotero user selects in its zotero firefox pane the given public group library, clicks "export library", and selects the bibtex format and UTF-8 encoding.

Reading through the dev doc http://www.zotero.org/support/dev/start, I guess I should start by looking at the REST API documentation http://www.zotero.org/support/dev/server_api, but I'd prefer having some general, high-level, advices on how to proceed before embarking into potentially not-the-easiest-possible path... (Also does the REST API give access to an export-to-bibtex functionality?)

So I'd be happy to read any advice concerning which general approach to take; which programming language to use (anything from javascript to C++ or Java including Perl, Python etc. is possible). Code snippets for a fast-start would be much appreciated!
  • The server API you had would not require you to run the client: you'd get data from the sync server. It will not presently work directly for your needs, as BibTeX is not yet supported. You can probably transform the atom xml to BibTeX. Arbitrary CSL style support is coming & there is an experimental BibTeX CSL style file, so this may work for you soon (though plain text out is also not yet supported, so you'd have to strip html tags, which shouldn't be too hard).
  • We're also working on making all formats supported by export translators work server-side, although there's no ETA on this.
  • Mmh that's more work than I expected, and also seems a bit too much experimental IMHO. TBH I was expecting to have to write only a few trivial lines of code. I guess we're going to stick to the manual export when needed in the meantime, I hope some easier way to do this will soon be available.

    By allowing the script to run on the client side, would I be able to somehow easily access the Bibtex export function that is already embedded into zotero?
  • Finally I'd like to try it anyhow, even if somewhat experimental!

    I tried:
    wget -O- https://api.zotero.org/groups/1/collections/42ZCTF3U/items?content=bib\&style=apa | less

    which works.

    But:
    wget -O- https://api.zotero.org/groups/1/collections/42ZCTF3U/items?content=bib\&style=bibtex
    --2011-01-07 19:01:09-- https://api.zotero.org/groups/1/collections/42ZCTF3U/items?content=bib&style=bibtex
    Resolving api.zotero.org... 209.51.184.206
    Connecting to api.zotero.org|209.51.184.206|:443... connected.
    HTTP request sent, awaiting response... 500 Internal Server Error
    2011-01-07 19:01:14 ERROR 500: Internal Server Error.

    Is bibtex not supported yet? The doc mentions, if I understood correctly, that styles in the Zotero Style Repository may be used, and bibtex is listed in http://www.zotero.org/styles...
  • First, BibTeX in the Zotero client isn't a style—it's an export format. You're referring to the unofficial BibTeX CSL in the styles repository, but that's not maintained or recommended.

    But even if you wanted to use it, from the API docs:
    Can be the file name (without the '.csl' extension) of any default style in the Zotero Style Repository (e.g., 'apa' for 'http://www.zotero.org/styles/apa'). Support for other repository styles and arbitrary styles is forthcoming.
    Default styles are the styles at the top of the page.
  • Ok, thanks for the clarification.

    So one way to go for me, correct me if I'm wrong, would be to write a script that:
    1) download the references from the group library in atom format using a simple HTML "get";
    2) change these to bibtex, maybe using the csl provided in the zotero styles repository.

    Achieving 1) should be easy using standard libraries but I'm not sure about 2).

    A few questions:
    - What do you mean by "not recommended" when talking about using the bibtex csl style in the repository?
    - Any alternative implementation suggestion in mind?
    - Would zotero people recommend me to rather wait for the forthcoming "arbitrary style support"? (One question naturally linked is: when?, but I guess that's hard to say. The other linked question is the difficulty of writing the code sketched above.)
    - If any one has got some code snippet to get me started or pointers to good libraries I could use (esp. for 2)), it would most certainly be helpful.
  • The BibTeX CSL style is not recommended because it's simply not as robust as the export translator.

    There is little in the way of example code out there for working with the Atom data-- but it is fairly self-explanatory (if limited).
Sign In or Register to comment.