NCBI
Access NCBI's suite of databases — Gene, PubMed, Nucleotide, Protein, and more — via the ncbi_search and ncbi_fetch tools.
TOOL
ncbi_searchSearch any NCBI database using Entrez query syntax. Returns structured records.
| Parameter | Type | Description |
|---|---|---|
| database * | string | gene, pubmed, nucleotide, protein, snp, clinvar. |
| query * | string | Entrez query string, e.g. BRCA1[Gene] AND Homo sapiens[Organism]. |
| maxResults | integer | Records to return (default 10, max 100). |
| sort | string | relevance or date. |
Gene search
from smartsbio import SmartsBio
client = SmartsBio(api_key="sk_live_...")
result = client.tools.run(
tool_id="ncbi_search",
input={
"database": "gene",
"query": "BRCA1[Gene Name] AND Homo sapiens[Organism]",
"maxResults": 1,
},
)
gene = result["results"][0]
print(f"Gene ID : {gene['id']}")
print(f"Symbol : {gene['symbol']}")
print(f"Name : {gene['name']}")
print(f"Location : chr{gene['chromosome']}:{gene['start']}-{gene['stop']}")
print(f"Summary : {gene['summary'][:300]}")import { SmartsBio } from '@smartsbio/sdk';
const client = new SmartsBio({ apiKey: 'sk_live_...' });
const result = await client.tools.run('ncbi_search', {
input: {
database: 'gene',
query: 'BRCA1[Gene Name] AND Homo sapiens[Organism]',
maxResults: 1,
},
});
const gene = result.results[0];
console.log('Gene ID :', gene.id);
console.log('Symbol :', gene.symbol);
console.log('Location:', `chr${gene.chromosome}:${gene.start}-${gene.stop}`);
console.log('Summary :', gene.summary.slice(0, 300));curl -X POST https://api.smarts.bio/v1/tools/ncbi_search/run \
-H "Authorization: Bearer sk_live_..." \
-H "Content-Type: application/json" \
-d '{
"input": {
"database": "gene",
"query": "BRCA1[Gene Name] AND Homo sapiens[Organism]",
"maxResults": 1
}
}'# Search NCBI Gene for BRCA1 smarts tool run ncbi_search \ --param database=gene \ --param "query=BRCA1[Gene Name] AND Homo sapiens[Organism]" \ --param maxResults=1
PubMed literature search
from smartsbio import SmartsBio
client = SmartsBio(api_key="sk_live_...")
ws_id = client.workspaces.list()[0].id
result = client.tools.run(
tool_id="ncbi_search",
input={
"database": "pubmed",
"query": "IDH1 R132H glioma AND 2020:2025[PDAT]",
"maxResults": 10,
"sort": "date",
"workspace_id": ws_id,
"output_format": "bibtex",
"output_path": "literature/",
},
)
print(f"Total hits : {result['total_hits']}")
for p in result["articles"][:5]:
print(f" PMID {p['pmid']} ({p['year']}) {p['title'][:65]}...")
# Download BibTeX
bib = client.files.download(result["output_path"], workspace_id=ws_id, dest="./refs/")
print(f"BibTeX saved to {bib}")import { SmartsBio } from '@smartsbio/sdk';
const client = new SmartsBio({ apiKey: 'sk_live_...' });
const [workspace] = await client.workspaces.list();
const result = await client.tools.run('ncbi_search', {
input: {
database: 'pubmed',
query: 'IDH1 R132H glioma AND 2020:2025[PDAT]',
maxResults: 10,
sort: 'date',
workspaceId: workspace.id,
outputFormat: 'bibtex',
outputPath: 'literature/',
},
});
console.log('Total hits:', result.totalHits);
result.articles.slice(0, 5).forEach((p: { pmid: string; year: number; title: string }) => {
console.log(` PMID ${p.pmid} (${p.year}) ${p.title.slice(0, 65)}...`);
});
const bib = await client.files.download(result.outputPath, workspace.id, './refs/');
console.log('BibTeX saved to', bib);curl -X POST https://api.smarts.bio/v1/tools/ncbi_search/run \
-H "Authorization: Bearer sk_live_..." \
-H "Content-Type: application/json" \
-d '{
"input": {
"database": "pubmed",
"query": "IDH1 R132H glioma AND 2020:2025[PDAT]",
"maxResults": 10,
"sort": "date"
}
}' | jq '{total_hits, articles: [.articles[:3][] | {pmid, year, title}]}'# Search PubMed and save BibTeX to the workspace smarts tool run ncbi_search \ --param database=pubmed \ --param "query=IDH1 R132H glioma AND 2020:2025[PDAT]" \ --param maxResults=10 \ --param sort=date \ --param output_format=bibtex \ --param output_path=literature/ # Download the BibTeX file smarts file download literature/ ./refs/
Nucleotide sequence fetch
Download a nucleotide record by accession and save the FASTA to your workspace.
from smartsbio import SmartsBio
client = SmartsBio(api_key="sk_live_...")
ws_id = client.workspaces.list()[0].id
# Fetch NM_007294 (BRCA1 mRNA, RefSeq)
result = client.tools.run(
tool_id="ncbi_fetch",
input={
"database": "nucleotide",
"accession": "NM_007294",
"format": "fasta",
"workspace_id": ws_id,
"output_path": "sequences/",
},
)
print(f"Length : {result['sequence_length']} bp")
print(f"Path : {result['file_path']}")
# Download FASTA
fasta = client.files.download(result["file_path"], workspace_id=ws_id, dest="./sequences/")
print(f"FASTA saved to {fasta}")import { SmartsBio } from '@smartsbio/sdk';
const client = new SmartsBio({ apiKey: 'sk_live_...' });
const [workspace] = await client.workspaces.list();
const result = await client.tools.run('ncbi_fetch', {
input: {
database: 'nucleotide',
accession: 'NM_007294',
format: 'fasta',
workspaceId: workspace.id,
outputPath: 'sequences/',
},
});
console.log('Length:', result.sequenceLength, 'bp');
const fasta = await client.files.download(result.filePath, workspace.id, './sequences/');
console.log('FASTA saved to', fasta);curl -X POST https://api.smarts.bio/v1/tools/ncbi_fetch/run \
-H "Authorization: Bearer sk_live_..." \
-H "Content-Type: application/json" \
-d '{
"input": {
"database": "nucleotide",
"accession": "NM_007294",
"format": "fasta",
"workspace_id": "ws_abc123",
"output_path": "sequences/"
}
}' | jq '{sequence_length, file_path}'# Fetch NM_007294 (BRCA1 mRNA, RefSeq) as FASTA smarts tool run ncbi_fetch \ --param database=nucleotide \ --param accession=NM_007294 \ --param format=fasta \ --param output_path=sequences/ # Download the FASTA smarts file download sequences/ ./sequences/