Registry / data / astroquery

astroquery

JSON →
library0.4.11pypypi✓ verified 85d ago

Astroquery provides a uniform interface to query astronomical web services and archives, making it easier to access online astronomical data resources. It is part of the Astropy Project and integrates seamlessly with Astropy's data structures. The current version is 0.4.11, and it maintains an active development cycle with frequent releases to add new services and fix issues.

pip install astroquery
INSTALL
IMPORT
SIG · ASTROQUERY
A
astroquery
datapythonv0.4.11
Install
10.0s avg
Import
2791ms
Disk
216MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.4.11 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 2.871s · 208.3MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 10.0s · import 2.712s · 209MB
216MB installed
● package 216MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Simbad
from astroquery.simbad import Simbad
Mast
from astroquery.mast import Mast
Gaia
from astroquery.gaia import Gaia
Ned
from astroquery.ned import Ned

This quickstart demonstrates how to query the Simbad database for an object by name and perform a cone search around specific coordinates. It shows basic data retrieval and interaction with Astropy's units and coordinates.

from astroquery.simbad import Simbad import astropy.units as u # Query Simbad for a celestial object result_table = Simbad.query_object("M1") if result_table: print(f"Object Name: {result_table['MAIN_ID'][0]}") print(f"RA: {result_table['RA'][0]}, Dec: {result_table['DEC'][0]}") # Example of a cone search around a coordinate from astropy.coordinates import SkyCoord coord = SkyCoord('10h00m00s +10d00m00s', frame='icrs') radius = 5 * u.arcmin cone_search_results = Simbad.query_region(coord, radius=radius) if cone_search_results: print(f"\nObjects found near {coord.ra.deg:.2f}, {coord.dec.deg:.2f} (radius {radius.value:.0f} arcmin):") for row in cone_search_results[:3]: # Print first 3 results print(f" - {row['MAIN_ID']} (RA: {row['RA']}, Dec: {row['DEC']})") else: print("\nNo objects found for the cone search.")
Debug
Known issues
gotchaMany Astroquery services (e.g., MAST, Gaia, ESO) require authentication (login with API tokens or credentials) for full functionality or to bypass rate limits. Failing to authenticate will result in `HTTPError` (e.g., 401 Unauthorized or 403 Forbidden) or limited access.
fix
Use the respective service's login method, e.g., `Mast.login(token=os.environ.get('MAST_API_TOKEN'))` or `Gaia.login()`, before making queries. Tokens are often preferred for scripting.
affects: All versions
gotchaQueries can return extremely large datasets, especially for broad searches. This can lead to long download times, high memory consumption, and potential system instability. Always be mindful of the scope of your query.
fix
Use parameters like `max_results`, `top`, `limit`, or specific coordinate/time range filters where available. Preview query results (e.g., by checking the size of a preliminary query) before downloading the full data.
affects: All versions
breakingWhen using the `TapPlus` class, the `upload_table` method no longer allows table names that contain a dot ('.'). This was introduced as a security and consistency measure.
fix
Ensure that any table names passed to `TapPlus.upload_table` do not contain a period. Replace dots with underscores or remove them.
affects: >=0.4.8
gotchaAstroquery results are typically `astropy.table.Table` objects, with columns often carrying `astropy.units`. Mixing or ignoring these units can lead to `astropy.units.UnitsError` or incorrect calculations.
fix
Always check the units of table columns (e.g., `table['column_name'].unit`) and use `astropy.units` for any subsequent calculations or conversions to ensure dimensional consistency. Convert to plain numerical values only when needed and safe to do so.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'astroquery.<service>'
The astroquery library or a specific submodule was not installed, or the import path is incorrect.
fix
Ensure `astroquery` is installed (`pip install astroquery`). Verify the exact module name for the service you are trying to use (e.g., `astroquery.simbad`, `astroquery.mast`).
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: ...
The query to a remote service failed due to a lack of proper authentication (missing API key/token or invalid credentials).
fix
Authenticate with the respective service using its `login()` method (e.g., `Mast.login(token='YOUR_API_TOKEN')`). Check documentation for required authentication methods for the specific service.
astroquery.exceptions.RemoteServiceError: No results found for query: ...
The query parameters provided did not match any data in the remote service, or the service returned an empty set of results.
fix
Review your query parameters (object name, coordinates, radius, filters, etc.) for typos or logical errors. Try a broader query first, then narrow it down. Check the service's own web interface to confirm data existence.
TypeError: 'Table' object is not callable
Attempted to access rows or columns of an `astropy.table.Table` object using function-call syntax (e.g., `table(0)` or `table('column')`) instead of indexing syntax.
fix
Access rows and columns using square bracket indexing: `table[0]` for the first row, `table['column_name']` for a column. For specific cells, use `table['column_name'][0]`.
Upgrade
Version history
0.4.11latest on PyPI · released Sep 20, 2025
Audit
Dependencies
astropyrequiredAstroquery is built on Astropy, using its Table, Units, and Coordinates functionalities for data handling and interoperability.
Agent activity
33 hits · last 30 days
node
30
OpenAI (training)
1
Resources
astroquery — pip install astroquery · libregistry