Feature request: URL scheme to get citation/bibliography for an item

Hi! I would like to offer citing based on csl files in my LaunchBar action. But it seems like quite an undertaking. So I was wondering if it would be possible to expose this functionality with an url scheme. I guess other plugins and tools could benefit from that as well.
  • Any hope for this? ;)
  • edited June 19, 2023
    An upcoming version of Zotero will offer a version of the web API over localhost. If you can make HTTP requests in LaunchBar actions, you'll be able to use that to generate citations and bibliographies.
  • Oh, sure. That works. Thanks!
  • Hi Dan! What would be the best way to stay up to date on the progress of the web API you mentioned?
  • The local API is available in Zotero 7.

    Enable "Allow other applications on this computer to communicate with Zotero" from the Advanced pane of the Zotero settings. You can then run, e.g., curl 'http://localhost:23119/api/users/0/items?limit=10&sort=dateAdded' to see your 10 most recent items.

    More details: https://github.com/zotero/zotero/blob/main/chrome/content/zotero/xpcom/localAPI/server_localAPI.js#L28
  • edited 17 days ago
    Nice. Thanks!

    I tried to use a local custom CSL file for citation but that does not seem to work (yet?). It did work with styles from the standard repository (e.g., apa) or the URL of a remote CSL file. Locally would be nice though.

    const url = `http://localhost:23119/api/users/0/items/${itemKey}?format=json&include=bib,citation&style=${style}`;
  • edited 16 days ago
    Oh, never mind. I think I just found the issue myself. The id in my custom CSL file did not start with http://www.zotero.org/styles/
  • It shouldn't need to.
  • In my testing, it really seems to make a difference. I'm not using the http://www.zotero.org/styles/ prefix in the API call. However, if the local CSL file does not have it in the ID, I get an error 500 internal server error.
  • Thanks, we'll fix that.
  • edited 15 days ago
    Thank you! I have another quick question related to receiving a formatted citation or bibliography reference for an item via the local API.

    Is it possible to get those in Markdown instead of HTML?

    No problem if not. I can convert the HTML into Markdown in my script, but I wonder if I am doing work I don't need to do. ;)

    Looking at https://www.zotero.org/support/dev/web_api/v3/basics it seems like a no.
  • edited 9 days ago
    Local style URLs should be fixed in the latest beta.
    Is it possible to get those in Markdown instead of HTML?
    No, there's no such thing as Markdown citations — many/most styles require CSS to be formatted correctly, so the actual difference would generally be minimal. (Also, HTML is valid Markdown.) See this thread for a longer explanation. But if you're using some style that really doesn't need CSS, you could trivially script it yourself, yes.
Sign In or Register to comment.