Open Astronomy Catalog API
API usage over the last 7 days:
The Open Astronomy Catalog API (OACAPI) offers a lightweight, simple way to access data available via the Open Astronomy Catalogs. The API is accessible via a route that works via any of the catalog domains,
where the only difference is preference in catalog when returning items that appear on multiple catalogs. For the examples below we will (usually) use the api.astrocats.space route. By default, all returned values are provided in JSON format, unless a format=
URL variable is provided.
The pattern for the API is one of the domains listed above (e.g. https://api.astrocats.space
) followed by
/OBJECT/QUANTITY/ATTRIBUTE?ARGUMENT1=VALUE1&ARGUMENT2=VALUE2&...
where OBJECT
is set to a transient’s name, QUANTITY
is set to a desired quantity to retrieve (e.g. redshift), ATTRIBUTE
is a property of that quantity, and the ARGUMENT
variables allow to user to filter data based upon various attribute values. The ARGUMENT
variables can either be used to guarantee that a certain attribute appears in the returned results (e.g. adding &time&e_magnitude
to the query will guarantee that each returned item has a time
and e_magnitude
attribute), or used to filter via a simple equality such as telescope=HST
(which would only return QUANTITY
objects where the telescope
attribute equals "HST"
), or they can be more powerful for certain filter attributes (examples being ra
and dec
for performing cone searches).
Key names that are usable in API calls can be found in the OAC schema. Below, we provide some example queries that demonstrate the API’s capabilities.
There are a few arguments that have special meaning and are only a part of the API, not the schema:
closest
: Return the quantities with the closest value to the specified attributes. If multiple attributes are specified, the closest to each will be returned (e.g., magnitude=15&time=56789&closest
would return both the observation with magnitude closest to 15 and time closest to 56789.complete
: Return only quantities containing all of the requested attributes.first
: Return only the first of each of the listed quantities.format=x
: Return data in the specified format x
, currently supports csv
and tsv
. Any other format specification will return JSON
.item=n
: Return only the n
th item of each of the listed quantities.radius=r
: Return objects within a distance r
(in arcseconds) of a given set of ra
and dec
coordinates. Note that this disables exact matches for ra
and dec
.width=w
: Return objects within a distance w
(in arcseconds) of a given ra
value (for box searches).height=h
: Return objects within a distance h
(in arcseconds) of a given dec
value (for box searches).sortby=s
: Sort the returned array by the attribute s
(only works when returning results in csv
/tsv
formats).https://api.astrocats.space/catalog?ra=21:23:32.16&dec=-53:01:36.08&radius=2
https://api.astrocats.space/catalog/sne?format=CSV
By default, queries such as the two above will return the catalog entries for objects that satisfy the search conditions. To return data from a specific catalog when searching by a criterion such as position, the user should insert catalog/
into the URL before the rest of the query of the specific catalog they are interested in, as shown in the example below:
If the user instead wishes to return info on all objects across all catalogs, the all/
route should be used instead (any URL can be used with this route):
Individual object queries can return more-detailed information about each object, including datafiles such as spectra. Below, we show some examples of this in action:
https://api.astrocats.space/SN2014J/redshift
https://api.astrocats.space/SN2014J/redshift?first, or
https://api.astrocats.space/SN2014J/redshift?item=0
magnitude
, e_magnitude
, and band
attributeshttps://api.astrocats.space/SN2014J/photometry/magnitude+e_magnitude+band
https://api.astrocats.space/SN2014J/photometry/magnitude+e_magnitude+band?format=csv
https://api.astrocats.space/SN2014J/photometry/magnitude+e_magnitude+band?complete
https://api.astrocats.space/SN2014J+SN2015F/photometry/time+magnitude+band?format=csv
e_magnitude
and band
)https://api.astrocats.space/SN2014J/photometry/time+magnitude+e_magnitude+band?e_magnitude&band
https://api.astrocats.space/SN2014J/photometry/magnitude+e_magnitude+band?band=B
In the following example, we filter upon the value
of claimedtype
, but note that this filters lumdist
as well, since the value
filter applies to both:
https://api.astrocats.space/all/lumdist+claimedtype?value=ia
Note that the above returns an empty result. Instead, we want to do:
https://api.astrocats.space/catalog/lumdist+claimedtype?lumdist&claimedtype=ia&format=tsv
Regular expressions are also supported in the ARGUMENT
fields, allowing users to perform more sophisticated matches to attribute values:
https://api.astrocats.space/catalog/claimedtype?claimedtype=Ia-(.*)&format=tsv
Note that many regular expression symbols must be URL-encoded to be passed properly to the API.
https://api.astrocats.space/SN2014J/spectra/time+data?time=56703.2&closest
The catalog/
route (combined with filtering) can also return data from the individual object files if data isn’t contained within the main OAC catalog files (i.e. the data that is visible on the main pages of the Open Supernova Catalog, etc.). Because these queries are expensive (the full dataset must be loaded for each object), they have some numeric limits to prevent overloading the server.