Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ npm link
| **devto** | `top` `tag` `user` | 公开 |
| **dictionary** | `search` `synonyms` `examples` | 公开 |
| **arxiv** | `search` `paper` | 公开 |
| **pubmed** | `search` `article` `author` `citations` `related` | 公开 |
| **openreview** | `search` `venue` `paper` `reviews` | 公开 |
| **paperreview** | `submit` `review` `feedback` | 公开 |
| **wikipedia** | `search` `summary` `random` `trending` | 公开 |
Expand Down
323 changes: 323 additions & 0 deletions cli-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -15181,6 +15181,329 @@
"modulePath": "producthunt/today.js",
"sourceFile": "producthunt/today.js"
},
{
"site": "pubmed",
"name": "article",
"aliases": [
"paper",
"read"
],
"description": "Get detailed information for a PubMed article by PMID",
"access": "read",
"domain": "pubmed.ncbi.nlm.nih.gov",
"strategy": "public",
"browser": false,
"args": [
{
"name": "pmid",
"type": "str",
"required": true,
"positional": true,
"help": "PubMed ID, e.g. 37780221"
},
{
"name": "full-abstract",
"type": "boolean",
"default": false,
"required": false,
"help": "Do not truncate the abstract in table output"
}
],
"columns": [
"field",
"value"
],
"type": "js",
"modulePath": "pubmed/article.js",
"sourceFile": "pubmed/article.js"
},
{
"site": "pubmed",
"name": "author",
"description": "Search PubMed articles by author name and optional affiliation",
"access": "read",
"domain": "pubmed.ncbi.nlm.nih.gov",
"strategy": "public",
"browser": false,
"args": [
{
"name": "name",
"type": "str",
"required": true,
"positional": true,
"help": "Author name, e.g. \"Smith J\""
},
{
"name": "limit",
"type": "int",
"default": 20,
"required": false,
"help": "Max results (1-100)"
},
{
"name": "affiliation",
"type": "str",
"required": false,
"help": "Filter by author affiliation"
},
{
"name": "position",
"type": "str",
"default": "any",
"required": false,
"help": "Author position: any, first, or last",
"choices": [
"any",
"first",
"last"
]
},
{
"name": "year-from",
"type": "int",
"required": false,
"help": "Filter publication year from"
},
{
"name": "year-to",
"type": "int",
"required": false,
"help": "Filter publication year to"
},
{
"name": "sort",
"type": "str",
"default": "date",
"required": false,
"help": "Sort by date or relevance",
"choices": [
"date",
"relevance"
]
}
],
"columns": [
"rank",
"pmid",
"title",
"authors",
"journal",
"year",
"article_type",
"doi",
"url"
],
"type": "js",
"modulePath": "pubmed/author.js",
"sourceFile": "pubmed/author.js"
},
{
"site": "pubmed",
"name": "citations",
"description": "Get PubMed citation relationships for an article",
"access": "read",
"domain": "pubmed.ncbi.nlm.nih.gov",
"strategy": "public",
"browser": false,
"args": [
{
"name": "pmid",
"type": "str",
"required": true,
"positional": true,
"help": "PubMed ID, e.g. 37780221"
},
{
"name": "direction",
"type": "str",
"default": "citedby",
"required": false,
"help": "citedby or references",
"choices": [
"citedby",
"references"
]
},
{
"name": "limit",
"type": "int",
"default": 20,
"required": false,
"help": "Max results (1-100)"
}
],
"columns": [
"rank",
"pmid",
"title",
"authors",
"journal",
"year",
"article_type",
"doi",
"url"
],
"type": "js",
"modulePath": "pubmed/citations.js",
"sourceFile": "pubmed/citations.js"
},
{
"site": "pubmed",
"name": "related",
"description": "Find articles related to a PubMed article",
"access": "read",
"domain": "pubmed.ncbi.nlm.nih.gov",
"strategy": "public",
"browser": false,
"args": [
{
"name": "pmid",
"type": "str",
"required": true,
"positional": true,
"help": "PubMed ID, e.g. 37780221"
},
{
"name": "limit",
"type": "int",
"default": 20,
"required": false,
"help": "Max results (1-100)"
},
{
"name": "score",
"type": "boolean",
"default": false,
"required": false,
"help": "Show similarity scores when available"
}
],
"columns": [
"rank",
"pmid",
"title",
"authors",
"journal",
"year",
"article_type",
"score",
"doi",
"url"
],
"type": "js",
"modulePath": "pubmed/related.js",
"sourceFile": "pubmed/related.js"
},
{
"site": "pubmed",
"name": "search",
"description": "Search PubMed articles with advanced filters",
"access": "read",
"domain": "pubmed.ncbi.nlm.nih.gov",
"strategy": "public",
"browser": false,
"args": [
{
"name": "query",
"type": "str",
"required": true,
"positional": true,
"help": "Search query, e.g. \"machine learning cancer\""
},
{
"name": "limit",
"type": "int",
"default": 20,
"required": false,
"help": "Max results (1-100)"
},
{
"name": "author",
"type": "str",
"required": false,
"help": "Filter by author name"
},
{
"name": "journal",
"type": "str",
"required": false,
"help": "Filter by journal name"
},
{
"name": "year-from",
"type": "int",
"required": false,
"help": "Filter publication year from"
},
{
"name": "year-to",
"type": "int",
"required": false,
"help": "Filter publication year to"
},
{
"name": "article-type",
"type": "str",
"required": false,
"help": "Filter by publication type, e.g. Review or Clinical Trial"
},
{
"name": "has-abstract",
"type": "boolean",
"default": false,
"required": false,
"help": "Only include articles with abstracts"
},
{
"name": "free-full-text",
"type": "boolean",
"default": false,
"required": false,
"help": "Only include free full text articles"
},
{
"name": "humans-only",
"type": "boolean",
"default": false,
"required": false,
"help": "Only include human studies"
},
{
"name": "english-only",
"type": "boolean",
"default": false,
"required": false,
"help": "Only include English articles"
},
{
"name": "sort",
"type": "str",
"default": "relevance",
"required": false,
"help": "Sort by relevance, date, author, or journal",
"choices": [
"relevance",
"date",
"author",
"journal"
]
}
],
"columns": [
"rank",
"pmid",
"title",
"authors",
"journal",
"year",
"article_type",
"doi",
"url"
],
"type": "js",
"modulePath": "pubmed/search.js",
"sourceFile": "pubmed/search.js"
},
{
"site": "quark",
"name": "ls",
Expand Down
50 changes: 50 additions & 0 deletions clis/pubmed/article.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { cli, Strategy } from '@jackwener/opencli/registry';
import { CommandExecutionError, EmptyResultError } from '@jackwener/opencli/errors';
import { eutilsFetch, parseArticleXml, requirePmid, truncateText } from './utils.js';

cli({
site: 'pubmed',
name: 'article',
aliases: ['paper', 'read'],
access: 'read',
description: 'Get detailed information for a PubMed article by PMID',
domain: 'pubmed.ncbi.nlm.nih.gov',
strategy: Strategy.PUBLIC,
browser: false,
args: [
{ name: 'pmid', positional: true, required: true, help: 'PubMed ID, e.g. 37780221' },
{ name: 'full-abstract', type: 'boolean', default: false, help: 'Do not truncate the abstract in table output' },
],
columns: ['field', 'value'],
func: async (args) => {
const pmid = requirePmid(args.pmid);
const xml = await eutilsFetch('efetch', {
id: pmid,
rettype: 'abstract',
}, { retmode: 'xml', label: 'pubmed article' });
const article = parseArticleXml(xml, pmid);
if (!article) {
throw new EmptyResultError('pubmed article', `No article found for PMID ${pmid}.`);
}
if (!article.title) {
throw new CommandExecutionError(`pubmed article ${pmid} did not include a title`, 'PubMed EFetch response shape may have changed.');
}
const abstract = args['full-abstract'] ? article.abstract : truncateText(article.abstract, 500);
return [
{ field: 'PMID', value: article.pmid },
{ field: 'Title', value: article.title },
{ field: 'Authors', value: article.authors.join(', ') },
{ field: 'Journal', value: article.journal },
{ field: 'Year', value: article.year },
{ field: 'Date', value: article.date },
{ field: 'Article Type', value: article.article_type },
{ field: 'Language', value: article.language },
{ field: 'DOI', value: article.doi || null },
{ field: 'PMC ID', value: article.pmc || null },
{ field: 'MeSH Terms', value: article.mesh_terms || null },
{ field: 'Keywords', value: article.keywords || null },
{ field: 'Abstract', value: abstract || null },
{ field: 'URL', value: article.url },
];
},
});
Loading
Loading