Quickstart

Python API

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 Identifier

  • title - Work title

  • abstract - Abstract text

  • authors - List of author names

  • year - Publication year

  • source - Journal/venue name

  • cited_by_count - Number of citations

  • concepts - OpenAlex concepts with scores

  • topics - OpenAlex topics

  • is_oa - Open access status

  • oa_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 search

  • search_by_id - Get work by ID or DOI

  • status - Database statistics

  • enrich_ids - Batch lookup