Skip to content
Version 1.0.2

Search SciX with Python

A typed client for SciX, the successor to NASA/ADS. Write searches as Python expressions: scixplorer checks them as you write them, sends the Solr query SciX expects, and gives back typed results.

from scixplorer import Document

papers = (
    Document
    .select(
        Document.bibcode,
        Document.title,
    )
    .where((Document.author[0] == "Kewley, L") & (Document.year >= 2005))
    .order_by(Document.citation_count.desc())
    .limit(5)
)
[paper.title[0] for paper in papers]
# -> The host galaxies and classification of active galactic nuclei

Queries are Python expressions

Build a query from a model with select, where, order_by and limit, and combine conditions with &, | and ~. Nothing is sent until you read the results, and explain() shows exactly what would be sent. Raw Solr syntax is there when you need it.

Your first search →

print(papers.explain())
# -> q = pos(author:"Kewley, L", 1) AND year:[2005 TO *]
# -> sort = citation_count desc,id asc

Typed fields, with autocomplete

Every field is a typed attribute, so your editor completes Document. with all 101 document fields and offers only the operations each one supports. Type checkers such as mypy and pyright know the type of every value, and flag a misspelt field or Document.year.like(...) before the code runs. Values are checked as you build a condition: Document.year == "2015" raises QueryError at once.

Results and types →

paper = Document.get(bibcode="2000ApJ...537..916S")
paper.pubdate
# -> datetime.date(2000, 7, 1)
paper.journal
# -> <Journal: abbreviation='ApJ'>
Document.year == "2015"

Search by institution and country

SciX identifies the institutions in authors’ affiliations. scixplorer packages that curated data (7382 institutions, with their hierarchy), so you can search by country or institution without looking up an identifier, and with no request until the search itself.

Affiliations →

australian = (
    Document
    .select(Document.bibcode)
    .where(Document.affiliation.country_code == "AU")
)
[paper.bibcode for paper in australian]
# -> ['2001ApJ...556..121K', '2001ApJ...553...47F']

Several conditions on the same author

Everything inside one Document.authors.any(...) is about one author. This finds papers on which J. Dalcanton lists the University of Washington, not papers by J. Dalcanton with some co-author there. You can also ask about the first author, or about every author.

Authors →

from scixplorer import Author

dalcanton_at_uw = (
    Document
    .select(Document.bibcode)
    .where(
        Document.authors.any(
            (Author.name == "Dalcanton, J")
            & Author.affiliation.canonical_name.startswith("University of Washington")
        )
    )
)
[paper.bibcode for paper in dalcanton_at_uw]
# -> ['2007ApJ...658..941D']

Async

Every way of running a query has an asynchronous form (async for, aall(), acount() and the rest), so you can send several searches at once from asyncio code.

Async →

import asyncio


async def counts(years):
    queries = [
        Document
        .select()
        .where(Document.year == year)
        for year in years
    ]
    return await asyncio.gather(*(query.acount() for query in queries))


asyncio.run(counts([2000, 2003, 2015]))
# -> [1, 1, 1]

Also in scixplorer

A community project, with thanks

scixplorer is a community project, and it stands on the work of the NASA Astrophysics Data System team, now the SciX team. For more than thirty years they have gathered, curated and linked the scientific literature, and kept it open to everyone, so that any of us can find a paper, everything it cites and everything that cites it, in seconds. It is easy to forget how remarkable that is.

The index, the API, the curated affiliations and the links between papers are all their work. scixplorer only tries to make that work a little easier to reach from Python. If it helps your research, the credit belongs to them.

The best place to give that credit is in your papers. If SciX helped your research, through scixplorer or any other way, please say so in your acknowledgements. It is how the team can show what their work makes possible. They suggest this wording:

This research has made use of SciX, a scientific literature search and discovery platform, funded by NASA under Cooperative Agreement 80NSSC21M0056.

Thank you ❤️