Skybot3D

getSso

Heliocentric state vectors of SSOs

The method getSso is intended to people who want to retrieve in one request the heliocentric J2000 state vectors of planets, their major satellites, comets and asteroids at a reference epoch. The state vectors are those provided by the methods getPlanet, getComet and getAster respectively.

HTTP Request

If you are a software/solutions developer, you might want to include the Skybot3D getSso method into your application. This can be done by using the web service method or by using the following HTTP request:
https://ssp.imcce.fr/webservices/skybot3d/api/getSso.php?[parameters]
where [parameters] is a list of parameters separated by the character &. The allowed parameters are:
ParameterDefinitionLimits
-ep=<dateTime> Requested epoch, expressed in Julian period, ISO format,
or formatted as any English textual datetime
2411320.0 .. 2473540.0
1889-11-13 12h .. 2060-03-21 12h
-class=<string> Population class to filter-out the SSOs. Comma separated list admitted, or leave empty to get all bodies Ex.: NEA>Apollo,trojan,Short-Period,Planet
-limit=<integer> Maximum number of SSOs to retrieve Leave empty or put 0 to retrieve all objects (default)
-observer=<string> Code of the observer's location Ex.: 500 (geocenter), 007 (Paris), @kepler, ...
-coord=<string> Type of coordinates: rectangular for cartesian coordinates or spherical for RA and DEC rectangular (default) | spherical
-mime=<string> Mime type of the results votable | html | text | json
-getFile=<0|1> Active only if arguments class or limit are defined and not null. 0 (default) | 1
-from=<string> Word which define the name of the caller application,
or which describes the request
any short string
(no space character)

The output results are described in the following section, and are available in VOTable (default), HTML, plain text format, and JSON object (cf. examples). All input arguments are optional, and their value can be omitted, e.g. ...&-limit=&-mime=&...

Web service

The Skybot3D Web service provides methods based on SOAP and HTTP POST verb which allow one to interact between its own application and the Skybot3D service. Here is the useful information to invoke the getSso method:
Web Service URI:
https://ssp.imcce.fr/webservices/skybot3d/skybot3d.php
Namespace:
https://ssp.imcce.fr/webservices/skybot3d
WSDL:
https://ssp.imcce.fr/webservices/skybot3d/skybot3d.php?wsdl
SOAP header:
name of the SOAP header element: clientID
SOAP header's content: array('from' => 'YourName', 'hostip'=>'')
Methods:
getSso (inputArray)
The input parameter of the method is an array which must contained the following parameter:
VariableTypeUnitsLimits or valuesDefaultComment
epoch string dateTime 2411320.0 .. 2473540.0
1889-11-13 12h .. 2060-03-21 12h
none Requested epoch (julian period, ISO format, English textual datetime)
class string - Class or comma separated list of classes empty Requested population classes of objects
limit integer - ≥ 0 0 Maximum number of objects to retrieve
observer string - Code of observer's location 500 IAU observatory code or observer's location code
coord string - rectangular | spherical rectangular Requested type of coordinates of the targets: cartesian or spherical
mime string - votable | html | text | json votable Mime type of the results

The output of the methods is an object containing the following attributes:

'flag'
the status of the response: flag=1 means ok; flag=0 or flag=-1 mean that an error occured
'ticket'
the Unix timestamp of the response which can be useful to stamp the request
'status'
the HTTP status-code of the response (e.g. 400: bad request, 422: Unprocessable Entity, 500: internal error)
'nbsso'
the number of objects contained in the result file
'refdate'
the epoch of the ephemeris, in julian day
'file'
the URL of a Bzipped file containing the requested data (extension .bz2)
'filesize'
the size of the result file, in bytes

To get the result file, use a network downloader, such as wget or curl, or download the file by using your preferred Web browser. You will need to (b)unzip the file before to read it with any text editor.

Depending on the selected mime type, the output is formatted as:

votable
the data are written in the IVOA standard VOTable format
html
the data are transformed from VOTable to HTML by XSLT processing (Skybot3D XSL style sheet)
text
the data are returned in plain text where each value is separated by the pipe '|' character
json
the data are written in a JSON object.

Query examples

Output results

The output results depend on the context of the request:
  • If one of the arguments class or limit, or both, are defined and not null then the output results are composed of the output results of the getAster, getComet and getPlanet methods. According to the mime type:
    • text: the data are provided in a ZIP archive containing one file by object type (asteroids, comets and planets+satellites). If the argument getFile=1 then the archive is directly sent to the user.
    • json: the data are provided in a single file containing one object by object type (asteroids, comets and planets+satellites). The result file is compressed with the BZIP2 compression algorithm.
    • votable: the data are provided in a single VOTable containing one table of data by object type (asteroids, comets and planets+satellites). The result file is compressed with the BZIP2 compression algorithm.
  • If the both arguments class and limit are not defined or null, which means that all the population of SSOs is requested, then the output results are provided in a ZIP archive containing XML files for the asteroids and comets, and a file with the state vectors of the planets and their satellites.

Structure of the output JSON object

When the output mime type is the JSON data-interchange format, the output of the getSso method is encapsulated in a structure defined as follows:
{
  "flag": (int),
  "ticket": (long),
  "status": (int),
  "nbsso": (int),
  "refdate": (float),
  "file": (URL),
  "size(bytes)": (int)
}

And the data are encapsulated in a structure defined as:

{
  "nbsso": (int),
  "refdate": (float),
  "asteroids": [ [ ASTER1 ], [ ASTER2 ], ... ]
  "comets": [ [ COMET1 ], [ COMET2 ], ... ]
  "planets": [ [ PLANET1 ], [ PLANET2 ], ... ]
}
where [SSOi] is an array which contains the parameters described in the Output results section.

How to consume

You have two ways to use the Sbybot3D Web service: by writting a client to send requests to the Skybot3D server and to receive and analyze the response, or by using a command line interface and a data transfert program such as curl or wget. For that, just execute one of the following commands in a console:
$> curl "<URL>"
or
$> wget "<URL>"
where <URL> is described in section HTTP request.

In order to help you to invoke the Skybot3D web service, we provide some clients written in differents languages. Here are some detailed explanations to write a client with PHP and SOAP which invokes the getSso method:

1/ Provide the input parameters which are mandatory for the service:

// Client's ID: provide the name of your project or organisation or yourself
$from = 'MyName';
// Input parameters
$param = array('epoch'    => 'now',
               'class'    => '',
               'limit'    => 10,
               'observer' => 500
               'coord'    => 'spherical',
               'mime'     => 'json');
// Boolean to download (1) or not (0) the result file
$getFile = 0;

2/ Define the SOAP options, the namespace and the WSDL URI of SkyBoT web service:

// Enables or disables the WSDL caching feature
ini_set('soap.wsdl_cache_enabled', 1);
// Skybot3D namespace
$namespace = 'https://ssp.imcce.fr/webservices/skybot3d';
// Skybot3D WSDL
$uriwsdl = $namespace.'/skybot3d.wsdl';

3/ Create a SoapClient object in WSDL mode, set the SOAP header, then call the method and catch exceptions:

try {
  // Constructs the client
  $client = new SoapClient($uriwsdl, array('exceptions'=>1));
  // SOAP header
  $header = array('from'=>$from, 'hostip'=>'');
  $client->__setSoapHeaders(array(new SOAPHeader($namespace, 'clientID', $header)));  
  // Call the getSso method
  $response = $client->__soapCall('getSso',$param);
  // Display the results
  if ($param['mime'] == 'text')
  {
    if ($response->flag > 0) {
      if ($getFile == 0) {
        header("HTTP/1.0 ".$response->status);
        header("Content-Type: text/plain");
        echo "# Flag     : ".$response->flag.PHP_EOL;
        echo "# Ticket   : ".$response->ticket.PHP_EOL;
        echo "# nbAster  : ".$response->nbsso.PHP_EOL;
        echo "# refDate  : ".$response->refdate.PHP_EOL;
        echo "# fileName : ".$response->file.PHP_EOL;
        echo "# fileSize : ".$response->size." bytes".PHP_EOL;
      } else {
        header("HTTP/1.0 ".$response->status);
        header('Content-Type: application/zip');
        readfile($response->file);
      }
    } else {
      header("HTTP/1.0 ".$response->status);
      header("Content-Type: text/plain");
      echo "# Flag    : ".$response->flag.PHP_EOL;
      echo "# Ticket  : ".$response->ticket.PHP_EOL;
      echo "# Message : ".$response->result.PHP_EOL;
    }
  }
  else if ($param['mime'] == 'json')
  {
    if ($response->flag > 0) {
      if ($getFile == 0) {
        $js = json_decode($response->result);
        header("HTTP/1.0 ".$js->status);
        header("Content-Type: application/json");
        echo $response->result;
      } else {
        $js = json_decode($response->result);
        $status = $js->status;
        $bz = bzopen($js->file,'r');
        $jsdata = '';
        while (!feof($bz)) {
          $buffer = bzread($bz);
          if ($buffer === FALSE) {
            header("Content-Type: text/plain");
            echo 'Error: Skybot3d getSso: Cannot read the bzipped file: '.$js->file;
            exit();
          } else if (bzerrno($bz) !== 0) {
            $error = bzerror($bz);
            header("Content-Type: text/plain");
            echo 'Error: Skybot3d getSso: Cannot read the bzipped file: '.$js->file.', Error: '.$error['errstr'];
            exit();
          } else {
            $jsdata .= $buffer;
          }
        }
        bzclose($bz);
        header("HTTP/1.0 ".$status);
        header("Content-Type: application/json");
        echo $jsdata;
      }
    } else {
      header("HTTP/1.0 ".$js->status);
      header("Content-Type: application/json");
      echo $response->result;
    }
  }
  else
  {
    if ($response->flag > 0) {
      if ($getFile == 0) {
        header("HTTP/1.0 ".$response->status);
        header("Content-Type: text/xml;content=x-votable");
        echo $response->result;
      } else {
        $fdata = Data::getSkybot3DFileFromVOtable($response->result);
        $bz = bzopen(str_replace('${Filename}', $fdata['filename'], $fdata['link']), 'r');
        $votdata = '';
        while (!feof($bz)) {
          $buffer = bzread($bz);
          if ($buffer === FALSE) {
            header("Content-Type: text/plain");
            echo 'Error: Skybot3d getSso: Cannot read the bzipped file: '.$js->file;
            exit();
          } else if (bzerrno($bz) !== 0) {
            $error = bzerror($bz);
            header("Content-Type: text/plain");
            echo 'Error: Skybot3d getSso: Cannot read the bzipped file: '.$js->file.', Error: '.$error['errstr'];
            exit();
          } else {
            $votdata .= $buffer;
          }
        }
        bzclose($bz);
        header("HTTP/1.0 ".$response->status);
        header("Content-Type: text/xml;content=x-votable");
        echo $votdata;
      }
    } else {
      header("HTTP/1.0 ".$response->status);
      header("Content-Type: text/xml;content=x-votable");
      echo $response->result;
    }
  }
} 
catch (SoapFault $fault) 
{
   trigger_error("SOAP Fault: {$fault->getTraceAsString()} (faultcode: {$fault->faultcode},
                               faultstring: {$fault->faultstring})", E_USER_ERROR);
}