Quickstart
Python API
Basic Search
from openalex_local import search, get, count, info
# Check database status
db = info()
print(f"Works: {db['work_count']:,}")
# Full-text search
results = search("machine learning", limit=10)
print(f"Found {results.total:,} matches in {results.elapsed_ms:.1f}ms")
for work in results:
print(f"- {work.title} ({work.year})")
Get by ID or DOI
# By OpenAlex ID
work = get("W2741809807")
# By DOI
work = get("10.1038/nature12373")
if work:
print(f"Title: {work.title}")
print(f"Authors: {', '.join(work.authors)}")
print(f"Abstract: {work.abstract[:200]}...")
print(f"Concepts: {[c['name'] for c in work.concepts]}")
Work Attributes
The Work object has these attributes:
openalex_id- OpenAlex ID (e.g., W2741809807)doi- Digital Object Identifiertitle- Work titleabstract- Abstract textauthors- List of author namesyear- Publication yearsource- Journal/venue namecited_by_count- Number of citationsconcepts- OpenAlex concepts with scorestopics- OpenAlex topicsis_oa- Open access statusoa_url- Open access URL
Configuration
from openalex_local import configure, configure_http, get_mode
# Configure database path
configure("/path/to/openalex.db")
# Configure HTTP mode
configure_http("http://localhost:31292")
# Check current mode
print(get_mode()) # "db" or "http"
CLI Usage
# Search
openalex-local search "CRISPR genome editing" -n 5
# Get by ID
openalex-local search-by-doi W2741809807
openalex-local search-by-doi 10.1038/nature12373
# Show abstracts
openalex-local search "neural networks" -a
# JSON output
openalex-local search "machine learning" --json
# Status
openalex-local status
MCP Integration
For Claude Desktop or other MCP clients:
{
"mcpServers": {
"openalex-local": {
"command": "openalex-local",
"args": ["mcp", "start"],
"env": {
"OPENALEX_LOCAL_DB": "/path/to/openalex.db"
}
}
}
}
Available MCP tools:
search- Full-text searchsearch_by_id- Get work by ID or DOIstatus- Database statisticsenrich_ids- Batch lookup