Command Line access

Here you can find some examples about how to interact with HREDA TAP+ server from command line. We are using the curl tool:

1. Non authenticated access

1.1. Getting all public tables
curl "https://hreda.esac.esa.int/hreda-sl-tap/tap/tables"
1.2. Synchronous query
curl "https://hreda.esac.esa.int/hreda-sl-tap/tap/sync?REQUEST=doQuery&LANG=ADQL&FORMAT=votable_plain&QUERY=SELECT+investigation_name,short_description,start_date,end_date+FROM+hreda.v_investigation+WHERE+(start_date+%3E+'2013-10-20')+AND+(end_date+%3C+'2016-12-31')"

Note that the URL is encoded. This query example searches for investigations performed during a time interval.

The retrieved results is a VO table by default (see '3.2. Synchronous Queries' section parameters to specify a different output format). The results can be saved in a file and inspected using any analysis tool like TOPCAT, for instance.

1.3. Asynchronous query
curl -i -X POST --data "PHASE=run&LANG=ADQL&LANG=ADQL&REQUEST=doQuery&QUERY=select+top+5+*+from+hreda.v_file_metadata" "https://hreda.esac.esa.int/hreda-sl-tap/tap/async"


Note that there is the possibility to use the optional parameters "JOBNAME" to assign a name to the job and "JOBDESCRIPTION"to add a description:

curl -i -X POST --data "PHASE=run&LANG=ADQL&JOBNAME=optionalJobName&JOBDESCRIPTION=optionalDescription&LANG=ADQL&REQUEST=doQuery&QUERY=select+top+5+*+from+hreda.v_experiment" "https://hreda.esac.esa.int/hreda-sl-tap/tap/async"

The response will contain the URL of the job running at server side (see Location header):

HTTP/1.1 303 
Date: Wed, 03 Jul 2019 11:51:48 GMT
Server: Apache/2.4.6 (Red Hat Enterprise Linux)
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
Location: https://hreda.esac.esa.int/hreda-sl-tap/tap/async/1562154708209DEV
Content-Type: text/plain;charset=ISO-8859-1
Set-Cookie: JSESSIONID=51B05D8ED52C912C9C7B196FCFB3E26D; Path=/hreda-sl-tap; HttpOnly
Transfer-Encoding: chunked

Location: https://hreda.esac.esa.int/hreda-sl-tap/tap/async/1562154708209DEV

To obtain the status of the running job:

curl "https://hreda.esac.esa.int/hreda-sl-tap/tap/async/1562154708209DEV"

The status response is something like:

<?xml version="1.0" encoding="UTF-8"?>
<uws:job xmlns:uws="http://www.ivoa.net/xml/UWS/v1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <uws:jobId><![CDATA[1578656224717DEV]]></uws:jobId>
        <uws:runId xsi:nil="true" />
        <uws:ownerId><![CDATA[anonymous]]></uws:ownerId>
        <uws:phase>COMPLETED</uws:phase>
        <uws:quote xsi:nil="true" />
        <uws:startTime>2019-10-30T16:44:40.766+0200</uws:startTime>
        <uws:endTime>2019-10-30T16:44:40.830+0200</uws:endTime>
        <uws:executionDuration>0</uws:executionDuration>
        <uws:destruction>2019-11-06T16:44:40.754+0200</uws:destruction>
        <uws:parameters>
                <uws:parameter id="format" esatapplus:parameter_type="COMMON" esatapplus:parameter_data_type="String">votable</uws:parameter>
                <uws:parameter id="jobdescription" esatapplus:parameter_type="COMMON" esatapplus:parameter_data_type="String">optionalDescription</uws:parameter>
                <uws:parameter id="jobname" esatapplus:parameter_type="COMMON" esatapplus:parameter_data_type="String">optionalJobName</uws:parameter>
                <uws:parameter id="lang" esatapplus:parameter_type="COMMON" esatapplus:parameter_data_type="String">ADQL</uws:parameter>
                <uws:parameter id="lib_sl_version" esatapplus:parameter_type="COMMON" esatapplus:parameter_data_type="String">4.14-SNAPSHOT</uws:parameter>
                <uws:parameter id="lib_tap_version" esatapplus:parameter_type="COMMON" esatapplus:parameter_data_type="String">4.14-SNAPSHOT</uws:parameter>
                <uws:parameter id="lib_uws_version" esatapplus:parameter_type="COMMON" esatapplus:parameter_data_type="String">4.14-SNAPSHOT</uws:parameter>
                <uws:parameter id="phase" esatapplus:parameter_type="COMMON" esatapplus:parameter_data_type="String">run</uws:parameter>
                <uws:parameter id="query" esatapplus:parameter_type="COMMON" esatapplus:parameter_data_type="String">select top 5 * from hreda.v_experiment</uws:parameter>
                <uws:parameter id="request" esatapplus:parameter_type="COMMON" esatapplus:parameter_data_type="String">doQuery</uws:parameter>
                <uws:parameter id="user_agent" esatapplus:parameter_type="COMMON" esatapplus:parameter_data_type="String">curl/7.64.1</uws:parameter>
        </uws:parameters>
        <uws:results>
                <uws:result id="result" xlink:type="simple" xlink:href="https://hredadev.esac.esa.int/hreda-sl-tap/tap/async/1578656224717DEV/results/result" mime="application/x-votable+xml" encoding="gzip" size="7619" rows="5"/>
        </uws:results>
        <uws:errorSummary xsi:nil="true"/>
</uws:job>

To obtain the results of the job (once the job is finished):

curl "https://hreda.esac.esa.int/hreda-sl-tap/tap/async/1578656224717DEV/results/result"

The retrieved results is a VO table by default (see '3.3 Asynchronous Queries' section parameters to specify a different output format).
The results can be saved in a file and inspected using any analysis tool like TOPCAT, for instance.


2. Authenticated access

2.1. Login
curl -k -c cookies.txt -X POST -d username=USERNAME -d password=PASSWORD -L "https://hreda.esac.esa.int/hreda-sl-tap/login"

The credentials are stored in the 'cookies.txt' file. This file will be required to access restricted data.

2.2. Logout
curl -k -b cookies.txt -X POST -L "https://hreda.esac.esa.int/hreda-sl-tap/logout"

3. Interface

See the following specifications:

3.1. TAP resources

https://hreda.esac.esa.int/hreda-sl-tap/tap/

Tables https://hreda.esac.esa.int/hreda-sl-tap/tap/tables
Synchronous access https://hreda.esac.esa.int/hreda-sl-tap/tap/sync
Asynchronous access https://hreda.esac.esa.int/hreda-sl-tap/tap/async
Jobs listing capability https://hreda.esac.esa.int/hreda-sl-tap/tap/jobs TAP+
Jobs removal capability https://hreda.esac.esa.int/hreda-sl-tap/tap/deletejobs TAP+
3.2. Synchronous Queries
Parameter Value Comments
REQUEST doQuery Requests to execute the provided query
LANG ADQL Query language
FORMAT - votable
- votable_plain
- csv
- json
- fits
Results output format
QUERY ADQL query query
3.3. Asynchronous Queries
Parameter Value Comments
Same parameters as defined in 3.2 Synchronous Queries and
PHASE run Query job initial phase

The response header will contain the location of the job.

3.4. TAP+ login
Parameter Value Comments
username user_name User name
password user_password User password

The response header will contain the session identifier.

3.5. TAP+ logout

ParameterValueComments
session identifier session identifier Session identifier provided by a login request
Must be added to the HTTP header