larsgw / citation.js

Citation.js converts formats like BibTeX, Wikidata JSON and ContentMine JSON to CSL-JSON to convert to other formats like APA, Vancouver and back to BibTeX.
https://citation.js.org/
MIT License
222 stars 30 forks source link

error when requesting more than 50 Wikidata qids #176

Closed egonw closed 5 years ago

egonw commented 5 years ago

My Groovy Cheminformatics books has more than 50 citations using Wikidata now, and I just got this error:

getEntities accepts 50 ids max to match Wikidata API limitations:
      this request won't get all the desired entities.
      You can use getManyEntities instead to generate several request urls
      to work around this limitation

The patch seems trivial: s/getEntities/getManyEntities/ ?

larsgw commented 5 years ago

The patch seems trivial: s/getEntities/getManyEntities/ ?

Mostly yep, but also (from wikidata-sdk):

:warning: This limitation policy was probably there for a reason, right? This should be the exception, make sure to set an interval between your requests (500ms, 1s?)


This code:

const parseWikidata = function (data) {
  const list = Array.isArray(data) ? data : data.trim().split(/(?:[\s,]\s*)/g)
  return [].concat(wdk.getEntities(list, ['en']))
}

Also this and the async counterpart, although that should happen less often and should be modified anyway.

larsgw commented 5 years ago

Closed in https://github.com/citation-js/citation-js/pull/11