com um clique
develop-search-translator
// Develop a search translator that looks up items by identifier (DOI, ISBN, PMID, arXiv ID, etc.) via an external API. NOT for websites with search pages — use develop-web-translator for those.
// Develop a search translator that looks up items by identifier (DOI, ISBN, PMID, arXiv ID, etc.) via an external API. NOT for websites with search pages — use develop-web-translator for those.
Analyze a website's API by capturing network traffic (HAR) and generating an OpenAPI spec via mitmproxy2swagger.
Create or update test cases for a Zotero translator by running it against live URLs and capturing the output.
Develop an export translator that converts Zotero items into a file format (JSON, XML, CSV, etc.).
Develop an import translator that parses a file format (JSON, XML, RIS, BibTeX, CSV, etc.) into Zotero items.
Develop a web translator that scrapes bibliographic data from a website. This is the most common translator type.
Inspect a live web page using headless Chrome. Gets screenshots, meta tags, accessibility tree, and runs CSS selectors or JS expressions against the rendered DOM.
| name | develop-search-translator |
| description | Develop a search translator that looks up items by identifier (DOI, ISBN, PMID, arXiv ID, etc.) via an external API. NOT for websites with search pages — use develop-web-translator for those. |
A search translator takes a structured identifier (DOI, ISBN, PMID, arXiv ID, etc.) and looks up metadata from an external API. It does NOT receive a web page or document.
Common confusion: if the user wants to translate items from a website that has a search page, that's a web translator, not a search translator. Use develop-web-translator for that. Search translators are for identifier-based lookup services (like Crossref, OpenAlex, Library of Congress, etc.).
Fetch and read the Zotero translator documentation:
Also read index.d.ts for type definitions.
Look for existing search translators for patterns:
grep -l "detectSearch\|doSearch" *.js
node .bin/init-translator.mjs --label "<Label>" --creator "<Creator>" --type search
Search translators have no target regex. They're triggered by identifier lookups in Zotero.
detectSearch(items)Return true if the input contains identifiers this translator handles. The items parameter is an object (or array of objects) with identifier fields.
function detectSearch(items) {
if (Array.isArray(items)) {
return items.some(item => item.DOI || item.ISBN);
}
return !!(items.DOI || items.ISBN);
}
Valid search fields: DOI, ISBN, PMID, arXiv, identifiers, contextObject, adsBibcode, ericNumber, openAlex.
doSearch(item)Look up the identifier via the service's API and create Zotero items.
async function doSearch(item) {
let doi = item.DOI;
if (!doi) return;
let url = `https://api.example.com/works/${encodeURIComponent(doi)}`;
let data = await requestJSON(url);
let newItem = new Zotero.Item('journalArticle');
newItem.title = data.title;
newItem.date = data.published_date;
newItem.DOI = doi;
for (let author of data.authors) {
newItem.creators.push({
firstName: author.given,
lastName: author.family,
creatorType: 'author',
});
}
// ... map other fields ...
newItem.complete();
}
Key APIs:
requestJSON(url), requestText(url), request(url) — make HTTP requests to the external API.new Zotero.Item(itemType) — create an item, set fields, call .complete().ZU.cleanDOI(), ZU.cleanISBN(), ZU.cleanISSN() — normalize identifiers.ZU.cleanAuthor(name, creatorType) — parse author name strings.node .bin/create-test.mjs "<Label>.js" --search '{"DOI":"10.1234/example"}'
Test with multiple identifier types if supported.
Update lastUpdated every time you modify translator code.
node .bin/update-metadata.mjs "<Label>.js"
npm run lint -- "<Label>.js"
node .bin/run-tests.mjs "<Label>.js"