Generating Key For Web API

The docs for the web API suggest that it is acceptable to generate your own key for new items before syncing them to the server (as long as you are keeping track of all the keys to avoid collisions). I want to make use of this feature as without it I would have to do a great deal of bookeeping to first sync any parent objects I want to create before I can fill in the parent key on any children I want to create.

However, I was unable to find any documentation about what properties the key must satisfy. Is it anything that matches [A-Z0-9]{8} or does it need to be of a certain form or what?

Any Thoughts,

  • You can generate an API key in your profile settings
  • edited December 19, 2016
    Not an API key. The unique sequence of (apparently 8) letters and numbers associated with each item.

    You know if you want{userid}/items/{itemkey}/children what you would fill in to {itemkey}.

    The question is if I am using the API to create multiple items at once and I want to fill the key into the JSON data I'm uploading rather than wait for a key to be generated for me what is a valid key, i.e., in my JSON dictionary I need to set key => somenewuniquevalue what are the restrictions on that?
  • edited December 19, 2016
    Sorry for the misunderstanding.

    By the looks of the code here the key should be [A-Z2-9]{8}.

    Also, questions regarding development for Zotero are better suited for the zotero-dev mailing list (it is okay to continue the thread here if you have further questions regarding this).
  • Ahh thanks, I will use the dev list in the future.

    Is it really [A-Z2-9]{8} not [A-Z0-9]{8}? Why?

    I really appreciate the info.
  • Actually this:

    $allowedKeyChars = "23456789ABCDEFGHIJKLMNPQRSTUVWXYZ";

    0, 1, and O aren't allowed to keep the keys more human-readable, though we might relax that restriction at some point.
  • (I should add that I'm not particularly happy about requiring client-side key generation in order to add parent and child items in the same request, so we might have a better solution in the future.)
Sign In or Register to comment.