INAF logo
TOCats − HiPS catalogues browser, V. 1.9 − Developed using DIF
In addition to the web interface, TOCats can be queried from any application using our HTTP services.
Data from catalogue queries are returned in VOTable format unless the &json or &tsv or &csv or &html selector is present in the URL.
Additionally:

Examples

Query using cURL

Note: you can also use wget, but curl is preferable.
curl -o mycat.vot 'https://cats.oas.inaf.it/gaiadr3/radius=0.1&ra=253.816&dec=-42.192&limit=100'

curl -H "Accept: application/json" -H "Content-Type: application/json" \
     -o mycat.json \
     -X GET "https://cats.oas.inaf.it/gaiadr3/radius=0.1&ra=253.816&dec=-42.192&limit=100&json"
or (better for use in a script - note the use of the -d option!)
curl -G https://cats.oas.inaf.it/gaiadr3/ \
  -o mycat.vot \
  -d radius=0.1 -d ra=253.816 -d dec=-42.192 -d limit=100

A simple Python script

#!/usr/bin/env python
# Python 2 using "urllib"
#
import urllib, json
url = "https://cats.oas.inaf.it/gaiadr3/radius=0.1&ra=253.816&dec=-42.192&limit=100&json"
response = urllib.urlopen(url)
output = json.loads(response.read())
print output
#!/usr/bin/env python
# Python 3 using "urllib"
#
from urllib.request import urlopen
url = "https://cats.oas.inaf.it/gaiadr3/radius=0.1&ra=253.816&dec=-42.192&limit=100&json"
response = urlopen(url)
print(response.read())
#!/usr/bin/env python
# Python 3 using "requests"
#
import requests
url = "https://cats.oas.inaf.it/gaiadr3/radius=0.1&ra=253.816&dec=-42.192&limit=100&json"
response = requests.get(url)
print(response.json())

# HTML output
#
url = "https://cats.oas.inaf.it/gaiadr3/radius=0.1&ra=253.816&dec=-42.192&limit=100&html"
response = requests.get(url)
print(response.text)

A simple Julia script

# Eventually first run `import Pkg; Pkg.add("HTTP")`
using HTTP
r = HTTP.get("https://cats.oas.inaf.it/gaiadr3/radius=0.1&ra=253.816&dec=-42.192&limit=100&json")
println(String(r.body))

A simple PHP script

1. Simplest ( requesting json)
echo file_get_contents("https://cats.oas.inaf.it/gaiadr3/radius=0.1&ra=253.816&dec=-42.192&limit=100&json");
2. Same request but using cURL functions
#!/usr/bin/env php
<?php
$ch = curl_init();
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_URL,
    'https://cats.oas.inaf.it/gaiadr3/radius=0.1&ra=253.816&dec=-42.192&limit=100&json'
);
$json = curl_exec( $ch );
echo $json;
curl_close( $ch );
?>
3. cURL programmatic, returning VOTable (default)
#!/usr/bin/env php
<?php
$url = 'https://cats.oas.inaf.it';
$cat = 'gaiadr3';

$qry = http_build_query(array(
   'radius' => '0.1',
   'ra'     => '253.816',
   'dec'    => '-42.192',
   'limit'  => '100'
));

$ch = curl_init();
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_URL, "$url/$cat/$qry" );
$vot = curl_exec( $ch );
echo $vot;
curl_close( $ch );
?>
L. Nicastro 2017 - 2023