Written and maintained by CASRAI Editorial Board
Published
On this page
Astroquery is the Python package that lets researchers query astronomical archives and catalogues, such as SIMBAD, VizieR and MAST, from a script instead of a web form. This guide explains what it is, how its modules work, which versions and settings to record, and how to cite it.
Short answer
Astroquery is an open-source Python package for querying astronomical web services and databases from code. It is an astropy-affiliated project: each service, such as SIMBAD, VizieR, MAST, NED, IRSA, Gaia or the ESA archives, has its own module, and most modules accept either object names or sky coordinates and return results as tables. It replaces manual form-filling on archive websites with scripted, repeatable queries.
Definition and scope
The astroquery documentation describes the package as a set of tools for querying astronomical web forms and databases. It is coordinated by the Astropy project and is released under a 3-clause BSD licence. Its design goal, stated in the 2019 paper by Ginsburg, Sipőcz, Brasseur and colleagues (The Astronomical Journal, DOI 10.3847/1538-3881/aafc33), is to support reproducible workflows from data acquisition to publication, including for services that have no formal programming interface. The modules are built on the requests library and astropy, and each mirrors the web interface of the service it wraps.
Astroquery is not an archive and holds no data itself. It is a client: every result comes from a remote service that is run by an observatory, data centre or mission team, and each of those services keeps its own access rules, data policies and release schedule. For the services themselves, see the CASRAI guides on the CDS services SIMBAD, VizieR and Aladin and the NASA Exoplanet Archive.
The documentation also positions astroquery relative to pyvo: pyvo is the general-purpose client for Virtual Observatory protocols, while astroquery covers astronomy services through modules written for each one. The two are complementary, and astroquery lists pyvo among its requirements.
How queries work in practice
You import the module for the service you need, not the top-level package; importing astroquery on its own gives you nothing to query. The documentation’s own example uses SIMBAD: Simbad.query_object("m1") returns a table for the named object, and Simbad.query_region(c, radius=r) runs a cone search around a position held in an astropy SkyCoord. Both calls share the pattern the project aims for across modules: pass an object name or coordinates, receive an astropy table.
Installation
The documentation gives python -m pip install -U --pre astroquery for the development releases that are published after each merged pull request, and conda install -c conda-forge astroquery for conda users. Tagged releases are also distributed on PyPI, where version 0.4.11 (released 20 September 2025) was the latest stable release when we checked on 20 November 2026. An [all] extra installs the optional dependencies.
Caching and logging
By default astroquery caches query results for one week. Each service module has its own cache location and a clear_cache() method, and a global cache_conf module controls caching across modules. For debugging, setting the log level to DEBUG records the HTTP requests that were sent, and TRACE records requests and responses.
Base classes
Under the hood, the documentation lists three base classes: BaseQuery, the base for all query classes; BaseVOQuery, whose session header identifies both astroquery and pyvo; and QueryWithLogin, for services that require a login. Services that need an account therefore behave differently from open ones, which matters when a script is meant to run unattended.
The three base classes
| Base class | Role according to the documentation | What it means for a script |
|---|---|---|
BaseQuery |
Base for all query classes | Shared behaviour such as caching and logging comes from here. |
BaseVOQuery |
Virtual Observatory queries; the session header identifies astroquery and pyvo | Services that answer Virtual Observatory protocols report the client as astroquery and pyvo. |
QueryWithLogin |
Services that need a login | An account is needed, so unattended runs need a plan for credentials. |
Scripting a service that has no formal interface
Many astronomy services were built as web forms for people, not as programming interfaces. The 2019 paper explains that astroquery’s modules mirror each service’s web interface, which is how the package can offer scripted access to services that have no formal API. The trade-off is that a module depends on the service’s current behaviour, so a redesign of a web form can break a module until its maintainers update it. The package’s issue tracker on GitHub is where such breakages are reported, and checking it is a sensible first step when a query that worked last month suddenly fails.
The paper is the work of a collaboration: its author list includes Ginsburg, Sipőcz, Brasseur, Cowperthwaite, Craig, Deil, Guillochon, Guzman, Liedtke, Lim, Lockhart, Mommert, Morris, Norman, Parikh, Persson, Robitaille, Segovia, Singer, Tollerud, de Val-Borro, Valtchanov and Woillez, together with the Astroquery collaboration. When you cite astroquery, cite that paper rather than a web page, so the credit reaches the people who maintain the modules.
Module families
The documentation groups the dozens of modules into catalogs, archives, simulations, line lists and a remaining “other” group. Examples it names include ALMA, Gaia, MAST, SIMBAD, VizieR, NED, IRSA and ESA archives. The practical point for a research group is that each module is a separate piece of code that tracks a separate external service, so a change at one data centre can break one module while the rest keep working.
Not every module follows the common pattern. The documentation notes that some, JPL Horizons among them, do not follow the common API, so a script written for one module cannot be assumed to transfer to another unchanged. Row limits are one example of service-specific behaviour: the CASRAI guide on VizieR, SIMBAD and Aladin describes the default 50-row limit of astroquery.vizier.
Reproducibility and citation checklist
Because astroquery returns whatever a live service says today, a result is only as reproducible as the record you keep of how it was obtained. The checklist below uses only facts stated in the astroquery documentation, its PyPI page and its repository. The data table below the article lists the same items with their sources.
- Record the astroquery version. Quote the exact release (for example 0.4.11), not “the latest”. The project publishes per-version DOIs on Zenodo, so a specific release can be cited precisely.
- Record the dependency versions. The documentation names numpy, astropy, pyvo, requests, keyring, Beautiful Soup and html5lib among the requirements; astropy and pyvo in particular are scientific dependencies, not just plumbing.
- Record the query date. Services change independently of the package, and the default one-week cache means a second run within a week may return stored results rather than a fresh answer. Clear the cache with
clear_cache()when you need a fresh query, and note the date of the query in your methods. - Save the returned table. Store the table you analysed alongside the code, so a reader can check your analysis even if the remote service later changes.
- Cite the paper. The maintainers ask users to cite Ginsburg et al. (2019), The Astronomical Journal 157, 98. The package also exposes a BibTeX entry through
astroquery.__citation__. - Cite the data service too. Astroquery is the access tool; the catalogue, archive or mission behind each query has its own citation or acknowledgement request.
These steps are an application of general computational-reproducibility practice to astroquery; see the CASRAI dictionary entries for computational reproducibility and the FAIR4RS software principles for the broader frameworks.
Where it matters for labs and research groups
Observational astronomy groups, survey teams and archive-based projects use scripted queries to build target lists, cross-match catalogues and retrieve observation metadata. The value for a research office or lab manager is operational: a scripted query is a documented step that a student can rerun, review and hand over, while a series of manual clicks on a web form is not. Services that need a login, and the maintenance burden of services that change, are the main points to plan for in a project’s data-management plan.
The project itself is run in the open. Its code and issue tracker are on GitHub, with one sub-package per web service, a contributing guide and a BSD-3-Clause licence. The maintainers apply a limit on pull requests from existing contributors, introduced in response to LLM-generated pull requests, and new contributors from data centres or archives are asked to contact a maintainer on the Astropy Slack about exceptions.
A worked example: writing the query into the methods section
The example below is illustrative, not a record of a real study. Suppose a group uses the documented SIMBAD calls to build a target list from a sky position. A reproducible methods statement can name only what the group actually recorded: the package and its release, the module, the call, the position and radius used, the date the query ran, and whether the one-week cache was cleared first. For instance: “Targets were retrieved with Simbad.query_region from astroquery 0.4.11 (Ginsburg et al. 2019) on a stated date, using a stated position and search radius; the cache was cleared before the run.” Everything in that sentence is something the script can print or log, so the statement is verifiable by a reader who reruns it, and the group should also keep the returned table so the analysis does not depend on the service staying unchanged.
The same habit helps when a student leaves a project: the script, the environment (Python, astropy and pyvo versions) and the saved tables form a package that a successor can review. A research office reviewing a data-management plan can ask for exactly these items instead of asking in general terms whether the work is reproducible. Setting the log level to DEBUG during the run is a low-effort way to keep a record of which requests were sent.
Staying current: releases, development builds and support
PyPI lists 0.4.11 as the latest stable release, with development pre-releases numbered 0.4.12.dev followed by a build number. The documentation’s installation command uses the --pre flag so pip accepts those development builds, which are made after each merged pull request; anyone who needs a fixed, citable release should pin the stable version instead. The PyPI page states a Python requirement of 3.9 or later for the stable release, while the documentation for the development version states 3.10 or later, so check the page that matches the version you install.
Problems with a particular module belong in the GitHub issue tracker; the repository’s contributing guide explains how to propose changes. Because each service has its own sub-package, an issue usually names the module concerned, which makes it quick to see whether other users have already reported the same breakage at the same service.
Common misunderstandings
“Astroquery is a database.”
It is a client library. Availability, speed, row limits and licence terms of the data belong to the remote service.
“Astroquery and pyvo are alternatives.”
The documentation describes them as complementary: pyvo for general Virtual Observatory queries, astroquery for modules covering individual services, with pyvo as one of its dependencies.
“All modules work the same way.”
Most follow the common name-or-coordinates pattern, but the documentation states that some, such as JPL Horizons, do not follow the common API.
“A rerun will give the same answer.”
Not necessarily. Results are cached for a week by default, and after the cache expires the live service may return updated data.
“The pip version is the only version.”
Development releases appear after each merged pull request, so pip install --pre gives a different version than the stable release on PyPI. Record which one you used.
Sources
- Astroquery documentation, docs.astropy.org/projects/astroquery, and its query base classes page, read 20 November 2026.
- Ginsburg, A., Sipőcz, B. M., Brasseur, C. E., et al. (2019), “astroquery: An Astronomical Web-Querying Package in Python”, The Astronomical Journal, DOI 10.3847/1538-3881/aafc33; arXiv:1901.04520, read 20 November 2026.
- Python Package Index, astroquery project page, read 20 November 2026.
- GitHub, astropy/astroquery repository, read 20 November 2026.
Data: Astroquery reproducibility record: versions, requirements, cache and citation
Items an astroquery user should record for a reproducible query, compiled from the astroquery documentation, its PyPI page, its GitHub repository and the 2019 paper, as read on 2026-11-20.
Period covered: 2025/2026.
| Item | Value | Source |
|---|---|---|
| Latest stable release | 0.4.11 (released 2025-09-20) | PyPI project page |
| Python requirement on PyPI | Python >=3.9 | PyPI project page |
| Python requirement for the development version | Python >=3.10 | Astroquery documentation |
| Minimum astropy version | astropy >=5.0 | Astroquery documentation |
| Minimum numpy version | numpy >=1.22 | Astroquery documentation |
| Minimum pyvo version | pyvo >=1.5 | Astroquery documentation |
| Default result cache duration | One week | Astroquery documentation |
| Licence | 3-clause BSD | Astroquery documentation; GitHub repository |
| Paper to cite | Ginsburg et al. 2019, The Astronomical Journal, DOI 10.3847/1538-3881/aafc33 | arXiv:1901.04520; astroquery documentation |
| Log level that records HTTP requests | DEBUG | Astroquery documentation |
| Log level that records requests and responses | TRACE | Astroquery documentation |
Sources
- Astroquery documentation (accessed 2026-11-20)
- astroquery on PyPI (accessed 2026-11-20)
- astropy/astroquery on GitHub (accessed 2026-11-20)
- astroquery: An Astronomical Web-Querying Package in Python (arXiv:1901.04520) (accessed 2026-11-20)
Compiled by CASRAI from the sources above. Free to reuse under CC BY 4.0 with attribution.







