IRSA VO Table Access Protocol (TAP) Instructions
IRSA offers program-friendly interfaces to all of its catalogs. An Application Programming Interface (API) allows access to IRSA catalogs (within a script or on the command line) without the need to go through a browser. IRSA accepts three kinds of APIs for catalogs (more on IRSA's Catalog Search APIs).
This page describes IRSA's implementation of the International Virtual Observatory Alliance (IVOA)'s Table Access Protocol, or TAP. IRSA's TAP supports many features of IVOA's Astronomical Data Query Language ADQL. It facilitates a rich variety of customized searches, including cone, box, polygon, and all-sky, and it offers the option of uploading a table containing multiple positions so that the user can search multiple sky regions in a single query. The output can be returned in various formats, including VO Table, IPAC table, and FITS.
Page contents:
- TAP services from Python
- TAP services from the command line
- Catalog & column names
- Constructing a TAP query
- Examples
Using IRSA TAP services from Python
An introduction to running TAP queries from Python is available here, and various additional examples can be found in the IRSA Python Notebook Tutorials. Once you are set up to run TAP queries from Python, you can return to this page for a guide to customizing queries to meet your specific search requirements.
Using IRSA TAP services from the command line
Below are examples of a cone search with center at (RA=66.76957 deg, Dec=26.10453 deg) and radius 0.01 deg against the 2MASS Point Source Catalog ("fp_psc") using the commonly available command-line tools curl and wget. Coordinates and angular sizes are always measured in decimal degrees. The results table, which will be written to the file "out.xml", is by default in VOTable format.
Using curl:- curl -o out.xml "https://irsa.ipac.caltech.edu/TAP/sync?QUERY=SELECT+*+FROM+fp_psc+WHERE+CONTAINS(POINT(ra,dec),CIRCLE(66.76957,26.10453,0.01))=1"
- wget -O out.xml "https://irsa.ipac.caltech.edu/TAP/sync?QUERY=SELECT+*+FROM+fp_psc+WHERE+CONTAINS(POINT(ra,dec),CIRCLE(66.76957,26.10453,0.01))=1"
Curl is preferred as it handles table upload more easily. Note the "+" signs which indicate spaces within a URL. These will be omitted in the descriptions below for clarity. They are not needed when using the "-F" option, as in examples 8 and 9 below.
A detailed description of the full query syntax is given below, but to help the reader get started, we give here a heuristic description of the query.
A detailed description of the syntax can be found in the Constructing a TAP query section and several examples of various types of queries are given in the Examples section. All of these queries are presented as URLs that can be run and downloaded from the command line. Alternatively, all of these queries can also be run from Python as described in the Using IRSA TAP services from Python section above.
How do I get IRSA's Catalog Names and Column Names?
Ready to go and just need the IRSA catalog and/or column names? See the sections labeled "table" and "columns" in blue, below. You can also explore the table and column names interactively here.
Constructing a TAP Query
The syntax for the TAP query depends upon whether you make a synchronous or asynchronous query. A successful synchronous query is straightforward; it runs until it has obtained the results you requested and then provides you with those results. This form of query either completes or times out within 5 minutes and is suitable for simple searches of small areas. An asynchronous query, in contrast, lasts only long enough to kick off a background job and provide you with links you can click to monitor the progress of that job and eventually to retrieve the results. This form of query will not directly provide the results to you. The timeout limit for asynchronous queries is 3 days.
For both forms of the TAP query, the main parameters are QUERY, FORMAT (optional), and UPLOAD (for table upload), described below.
For synchronous calls (small-area searches):
For asynchronous calls (large searches): You will be given a web address that you can use to check on your job. For example, if the address is:- https://irsa.ipac.caltech.edu/TAP/async/35
Then you can check the progress of your job by checking the "phase" associated with this job:
- https://irsa.ipac.caltech.edu/TAP/async/35/phase
This will return either QUEUED, EXECUTING, COMPLETED, ERROR, or ABORT. When the job is completed, you get your results like this:
- https://irsa.ipac.caltech.edu/TAP/async/35/results/result
QUERY:
The QUERY clause follows this pattern:
QUERY=SELECT {columns} FROM {table} WHERE {geometric constraint} AND ({sql constraints}) {order by}{group by} {having}
In particular,
| keyword | description | ||||||||||||
| columns | Comma-separated list of column names, or functions of columns to be returned. Supported functions are those that are both defined in ADQL 2.0 and implemented by database software providers Oracle (IRSA catalogs) or PostgreSQL (other IRSA tables). Examples (just for illustration -- don't run without constraints): 1. Output all columns.
2. Output selected columns.
3. Output the date of observation from the main 2MASS catalog, but round to the nearest day.
4. Rename the output column returned by "round(jdate,0)" to rounded_jdate.
5. Prefix the ra with the table name. This is advisable when performing operations on multiple tables.
6. Limit the number of rows in the results table. This can be done either with a "SELECT TOP" command within the "QUERY" clause or by means of the MAXREC parameter. If both "TOP" and "MAXREC" are present, the number of rows returned is no more than the minimum of the two limits. If the value of "MAXREC" is less than the number of records matching the search criteria, the value of the "QUERY_STATUS" element of a votable response will be OVERFLOW.
Note on Column Names: To get the available column names, say for the catalog "fp_psc" (retrieving the catalog table name is described in the following section):
Column names can also be browsed interactively here. | ||||||||||||
|
Specifies the catalog table to search. Example (just for illustration): Select all columns from the COSMOS Photometry catalog.
Note on Catalog Table Names: To obtain the string needed for the "table" parameter, you can download a VOTable of IRSA's available catalogs. The string needed is in the column labeled "table_name". There is also a useful column called "description".
Some Popular Catalogs
|
|||||||||||||
| geometric constraint |
The geometric constraint is typically a CONTAINS function (= 1 for true) operating on a POINT and a shape. Note that only a single geometric constraint is supported per query. Please see tip below. The POINT's two elements must be (possibly qualified) column names of which the final unqualified parts are "ra" and "dec" respectively. There are no restrictions on column names in the shape clause. There are three supported shape functions: CIRCLE, BOX, and POLYGON. All coordinates and angular sizes are in decimal degrees. Shape arguments may be constants or names of columns. Binary arithmetic expressions, i.e. "A op B" where "op" is one of '+', '-', '*', and '/', may be supplied in many places where constants are expected. Depending on how the call is made, a '+' might have to be encoded as "%2B". For more examples of how common characters can be encoded in URLs, see the table on this page. As of ADQL version 2.1, specifying a coordinate system in geometry constructors is deprecated. IRSA catalogs use equatorial coordinates with ra and dec usually consistent with the J2000 system. If another coordinate system such as ICRS was used in the catalog creation, the search will assume the search parameters are ICRS. Circle This requires the coordinates of the center and the radius. A 1-degree cone search around M101 would be:
Box This requires the coordinates of the center of the box, the width, and the height. The box will be aligned with the coordinate system. A 1 degree by 1 degree box around M101 would be:
Polygon This requires the concatenated coordinates of the vertices of the polygon. A triangle search around M101 would be:
The region searched is the convex hull of the supplied coordinates, so the order of coordinates does not matter. This is different from the ADQL specification, which allows arbitrary polygons. Note: Some functions (e.g. count()) do not work when there is a {geometric constraint}. As mentioned above, no more than one geometric constraint is supported per query. Therefore, queries like the one below, in which the user tries to query two locations on the sky at once, will not succeed. Users wishing to query more than one location on the sky must submit multiple queries. For example, this query will fail...
...but the combined results of these two queries will provide the desired data:
|
||||||||||||
| sql constraints | SQL constraints can be any constraints expressible in ADQL 2.0, with the restriction that functions must be supported by the Oracle (most tables) or Informix (some WISE tables) backend. Note: If the WHERE clause contains a geometric constraint as well as multiple SQL constraints, the SQL constraints must be grouped together and enclosed within parenthesis. Examples: Query the 2MASS Point Source Catalog, and return all columns for records that fall within a certain time range.
Perform a 1-degree cone search around M101, restricting to records that fall within a certain time range.
|
||||||||||||
| order by | A comma-separated list of column names specifying which to use for sorting the output table rows, in order of priority. Example: Query the 2MASS Point Source Catalog. Return all columns for records within a specified time range, and order the results by the observation date. If multiple records have identical observation dates, then order by right ascension.
|
||||||||||||
| group by | Groups the returned records by the specified columns, which allows you
to perform functions on that group.
Example: Query the 2MASS Point Source Catalog. Return all columns for records within a specified time range, and group the records by date.
| ||||||||||||
| having | Constrains selections after an aggregate function such as "group by".
Quicker than a WHERE since it acts on the smaller group.
Example: Query the 2MASS Point Source Catalog. Return all columns for records within a specified time range, group the records by date, then select those in the group with a certain brightness.
Note: Other ADQL 2.0 functions may also be implemented, but this page is not meant to be a complete description of SQL functions. |
MAXREC:
Limit the number of rows in the results table. This can be done either with a "SELECT TOP" command within the "QUERY" clause (please see columns) or by means of the "MAXREC" parameter. Only "MAXREC" triggers the OVERFLOW indicator.
- QUERY=SELECT+ra+FROM+fp_psc&MAXREC=5
To retrieve only the highest ranked N rows meeting the search criteria, specify both (1) a ranking or sort order (via SQL's "ORDER BY" keyword), and (2) the limit N (via either SQL's "SELECT TOP" or the "MAXREC" parameter).
-
QUERY=SELECT+ra,dec,DISTANCE(POINT(ra,dec),POINT(210.80225,54.34894))+as+my_dist+FROM+fp_psc+WHERE+
CONTAINS(POINT(ra,dec),CIRCLE(210.80225,54.34894,1.0))=1+ORDER+BY+my_dist,ra&MAXREC=10&FORMAT=HTML
-
QUERY=SELECT+TOP+10+ra,dec,DISTANCE(POINT(ra,dec),POINT(210.80225,54.34894))+as+my_dist+FROM+fp_psc+WHERE+
CONTAINS(POINT(ra,dec),CIRCLE(210.80225,54.34894,1.0))=1+ORDER+BY+my_dist,ra&FORMAT=HTML
FORMAT:
The TAP service will by default return a VOTable. Other formats may be requested via the FORMAT keyword. The supported output formats are:
| keyword | description |
| VOTABLE | VO Table - a type of XML |
| CSV | Comma Separated Value table |
| TSV | Tab Separated Value table |
| IPAC_TABLE | IPAC Table Format |
| HTML | HyperText Markup Language |
| FITS | Flexible Image Transport System Binary Table |
UPLOAD:
| keyword | description |
| name | The name of the table within TAP for the purposes of the present query (e.g. my_favorite_quasars). Prefix this name with TAP_UPLOAD to refer to columns in the query (e.g. TAP_UPLOAD.my_favorite_quasars.ra). Currently the uploaded table needs to be a VOTable, though a special syntax allows an IPAC table on the local machine. See Example 8 below. |
| URI | Location of table to upload. If it is an http or https URL, then the TAP service will attempt to fetch it over the network. To upload a file along with the query, use the special URL scheme "param". This indicates that the value after the colon will be the name of the inline content. The content type used is multipart/form-data, using a "file" type input element, e.g. the -F option of curl. The "name" attribute in the file input must match that used in the UPLOAD parameter. See Example 8 below. |
Examples
Cone Search
-
https://irsa.ipac.caltech.edu/TAP/sync?QUERY=SELECT+*+FROM+fp_psc+WHERE+CONTAINS(POINT(ra,dec),
CIRCLE(210.80225,54.34894,1.0))=1
-
https://irsa.ipac.caltech.edu/TAP/sync?QUERY=SELECT+*+FROM+fp_psc+WHERE+CONTAINS(POINT(ra,dec),
Cone Search returning a FITS table file
-
https://irsa.ipac.caltech.edu/TAP/sync?QUERY=SELECT+*+FROM+fp_psc+WHERE+CONTAINS(POINT(ra,dec),
CIRCLE(210.80225,54.34894,1.0))=1&format=fits
-
https://irsa.ipac.caltech.edu/TAP/sync?QUERY=SELECT+*+FROM+fp_psc+WHERE+CONTAINS(POINT(ra,dec),
- Cone Search with only ra, dec, and date rounded to the nearest day
-
https://irsa.ipac.caltech.edu/TAP/sync?QUERY=SELECT+ra,dec,round(jdate,0)+as+rounded_jdate+FROM+fp_psc+
WHERE+CONTAINS(POINT(ra,dec),CIRCLE(210.80225,54.34894,1.0))=1 Cone Search with a date filter, ordered by date
-
https://irsa.ipac.caltech.edu/TAP/sync?QUERY=SELECT+*+FROM+fp_psc+WHERE+CONTAINS(POINT(ra,dec),
CIRCLE(210.80225,54.34894,1.0))=1+and+(jdate>=2451500+and+jdate<=2451700)+order+by+jdate
-
https://irsa.ipac.caltech.edu/TAP/sync?QUERY=SELECT+*+FROM+fp_psc+WHERE+CONTAINS(POINT(ra,dec),
Cone Search with a distance column, ordered by distance (measured in arcsec)
-
https://irsa.ipac.caltech.edu/TAP/sync?QUERY=SELECT+ra,dec,DISTANCE(POINT(ra,dec),POINT(210.80225,54.34894))+as+my_dist+
FROM+fp_psc+WHERE+CONTAINS(POINT(ra,dec),CIRCLE(210.80225,54.34894,1.0))=1+ORDER+BY+my_dist,ra,dec
-
https://irsa.ipac.caltech.edu/TAP/sync?QUERY=SELECT+ra,dec,DISTANCE(POINT(ra,dec),POINT(210.80225,54.34894))+as+my_dist+
Box Search
-
https://irsa.ipac.caltech.edu/TAP/sync?QUERY=SELECT+*+FROM+fp_psc+WHERE+CONTAINS(POINT(ra,dec),
BOX(210.80225,54.34894,1.0,1.0))=1
-
https://irsa.ipac.caltech.edu/TAP/sync?QUERY=SELECT+*+FROM+fp_psc+WHERE+CONTAINS(POINT(ra,dec),
Polygon Search
-
https://irsa.ipac.caltech.edu/TAP/sync?QUERY=SELECT+*+FROM+fp_psc+WHERE+CONTAINS(POINT(ra,dec),
POLYGON(209.80225,53.34894,209.80225,55.34894,211.80225,54.34894))=1
-
https://irsa.ipac.caltech.edu/TAP/sync?QUERY=SELECT+*+FROM+fp_psc+WHERE+CONTAINS(POINT(ra,dec),
Upload local file
If you have a file "upload.vo", then this command will run a match against objects in the 2MASS catalog. Note that the POINT clause refers to columns from the catalog and the CIRCLE clause to columns from the uploaded table.
- curl -o fp_psc.xml -F "UPLOAD=my_table,param:table" -F "table=@upload.vo" -F "QUERY=SELECT fp_psc.ra, fp_psc.dec FROM fp_psc WHERE CONTAINS(POINT(ra,dec), CIRCLE(TAP_UPLOAD.my_table.ra, TAP_UPLOAD.my_table.dec, 0.01)) =1" https://irsa.ipac.caltech.edu/TAP/sync
If you have an IPAC table "upload.tbl" with "ra" and "dec" columns named "my_ra" and "my_dec" respectively, then this command will run a match against objects in the 2MASS catalog, returning an IPAC table.
- curl -o fp_psc.tbl -F "UPLOAD=my_table,param:table.tbl" -F "table.tbl=@upload.tbl" -F "FORMAT=IPAC_TABLE" -F "QUERY=SELECT fp_psc.ra, fp_psc.dec FROM fp_psc WHERE CONTAINS(POINT(ra,dec), CIRCLE(TAP_UPLOAD.my_table.my_ra, TAP_UPLOAD.my_table.my_dec, 0.01)) =1" https://irsa.ipac.caltech.edu/TAP/sync
Note that the name of the uploaded table is omitted from the FROM clause in this section's examples. Including the uploaded table's name in that clause is not incorrect and is required if you wish to introduce an alias for the upload table.
- curl -o fp_psc.tbl -F "UPLOAD=my_table,param:table.tbl" -F "table.tbl=@upload.tbl" -F "FORMAT=IPAC_TABLE" -F "QUERY=SELECT cat_table.ra, cat_table.dec FROM TAP_UPLOAD.my_table AS my_table, fp_psc AS cat_table WHERE CONTAINS(POINT(ra,dec), CIRCLE(my_table.my_ra, my_table.my_dec, 0.01)) =1" https://irsa.ipac.caltech.edu/TAP/sync
- Upload remote file
This will run a simple cone search on WISE and pipe it directly into a cross match with 2MASS.
- curl -o fp_psc.xml -F "UPLOAD=my_table,https://irsa.ipac.caltech.edu/SCS?table=allwise_p3as_psd&RA=210.80225&DEC=54.34894&SR=0.01" -F "QUERY=SELECT fp_psc.ra, fp_psc.dec FROM fp_psc WHERE CONTAINS(POINT(ra,dec), CIRCLE(TAP_UPLOAD.my_table.ra, TAP_UPLOAD.my_table.dec, 0.01)) =1" https://irsa.ipac.caltech.edu/TAP/sync
- Asynchronous Cone Search
Submit the query, using curl's "-v" option.
- curl -v "https://irsa.ipac.caltech.edu/TAP/async?QUERY=SELECT+*+FROM+fp_psc+WHERE+CONTAINS(POINT(ra,dec),CIRCLE(210.80225,54.34894,1.0))=1"
The output should include a line like:
- > Location: https://irsa.ipac.caltech.edu/TAP/async/10
Check the progress of the job.
- curl "https://irsa.ipac.caltech.edu/TAP/async/10/phase"
This query completes fairly quickly, so you should see "COMPLETED". To get the results:
- curl -o fp_psc.xml "https://irsa.ipac.caltech.edu/TAP/async/10/results/result"