Stellarium 0.15.2
|
The RemoteControl plugin provides an HTTP-based interface to Stellarium, implemented on the server-side through implementations of AbstractAPIService. The APIController maintains the list of registered services, and dispatches HTTP requests to the right service. The API is accessible under the server path /api/
. For example, if you have the server running on the default port of 8090, you can access the operation find of the ObjectService to look for objects with moon
in their name by accessing
Instead of the HTTP remote interface you can also use tools like cURL to access the API remotely. For POST operations, you would use the flag -d
to pass parameters. For GET operations, you should use the additional flag -G
if parameters are required. Examples:
If authentication is enabled (see RemoteControl class), HTTP Basic access authentication is expected, with an empty username. HTTPS configuration is currently not implemented, even if the underlying QtWebApp library would allow it.
Most operations return data in the JSON format, allowing it to be easily used in web applications. The format of the returned JSON data is described for each operation below. Some operations return plain text if only simple data is requested, or to confirm the success of an operation: to indicate success "ok" may be returned, in an error case an HTTP error code may be returned together with a string "error: error message" in the response body. Other operations may return HTML or even image data, you can check the returned Content-Type header if you are not sure what to expect.
The simplest way to expose new data through the API is by using the StelProperty system for a property you want to access. In this way, the data is available through the MainService (allowing tracking of changes) and the StelPropertyService (giving a snapshot of current values, metadata information and allowing to change values). You do not need to change/implement a new service in any way for this case.
If you want to expose more complex behaviour, you may need to implement your own AbstractAPIService and register it with the APIController.
The default services are registered in the RequestHandler::RequestHandler() constructor. They are:
Service | Path | Description |
---|---|---|
MainService | main | Implements the main API services, including the status operation which can be repeatedly polled to find the current state of the main program, including time, view, location, StelAction and StelProperty state changes, movement, script status ... |
ObjectService | objects | Provides operations to look up objects in the Stellarium catalogs. |
ScriptService | scripts | Contains services related to script execution. |
SimbadService | simbad | Allows SIMBAD object lookups like SearchDialog uses. |
StelActionService | stelaction | Provides services related to StelAction. |
StelPropertyService | stelproperty | Provides services related to StelProperty. |
LocationService | location | Provides methods to look up location-related information, and change the current location. |
LocationSearchService | locationsearch | Provides predefined location search functionality, using the StelLocationMgr. |
ViewService | view | Provides services related to the view (landscape, sky culture, projection). |
Implemented by MainService::getImpl
Parameters: [actionId (Number)] [propId (Number)]
This operation can be polled every few moments to find out if some primary Stellarium state changed. It returns a JSON object with the following format:
The actionChanges
and propertyChanges
sections allow a remote interface to track boolean StelAction and/or StelProperty changes. On the initial poll, you should pass -2 as propId
and actionId
. This indicates to the service that you want a full list of properties/actions and their current values. When receiving the answer, you should set your local propId
/actionId
to the id contained in actionChanges
and propertyChanges
, and re-send it with the next request as parameter again. This allows the MainService to find out which changes must be sent to you (it maintains a queue of action/property changes internally, incrementing the ID with each change), and you only have to process the differences instead of everything.
Returns the list of all known plugins, as a JSON object of format:
Implemented by MainService::postImpl
Parameters: time (Number) timerate (Number)
Sets the current Stellarium simulation time and/or timerate. The time
parameter defines the current time (Julian day) as passed to StelCore::setJD. The timerate
parameter allows to change the speed at which the simulation time moves (in JDay/sec) as passed to StelCore::setTimeRate.
Parameters: [target (String) | position (JSON Number Array of size 3, i.e. Vec3d)]
Sets the current app focus/selection. If no parameters are given, the current selection is cleared. If the target
parameter was given, the object to be selected is looked up by name (first the localized name is tried, then the english name). If the position
parameter is used, it is interpreted as a coordinate in the J2000 frame, and focused using StelMovementMgr::moveToJ2000
Parameters: x (Number) y (Number)
Allows viewport movement, like using the arrow keys in the main program. This allows interfaces to create a "virtual joystick" to move the view manually. This operation defines the intended move direction. x
and y
define the intended move speed in azimuth and altitude (i.e. a negative x
means left). Values of +-1.0 correspond to the same speed as used for the arrow keys. This operation works in conjunction with the update() method - until the movement is stopped (i.e. x
and y
are zero), or no move
command has been received for a specified time (about a second), the movement is performed in the given directions.
Parameters: az (Number) alt (Number)
Sets the view direction in altitude/azimut coordinates. az
and alt
must be given in radians. Omitting one value will keep the relevant coordinate unchanged.
Parameters: fov (Number)
Sets the current field-of-view using StelCore::setFov
Implemented by ObjectService::getImpl
Parameters: str (String)
Finds objects which match the search string str
, which may contain greek/unicode characters like in the SearchDialog. Returns a JSON String array of search matches
Parameters: [name (String)]
Returns a HTML info string (StelObject::getInfoString) about the object identified by name
. If no parameter is given, the currently selected object is used.
Returns all object types available in the internal catalogs as a JSON array of objects of format
Parameters: type (String) [english (Number)]
Returns all objects of the specified type
. If english
is given and it evaluates to a "true" value, the english names will be returned, otherwise the localized names will be returned. Returns a JSON string array.
Implemented by ScriptService::getImpl
Lists all known script files, as a JSON string array.
Parameters: id (String) [html (any type)]
Returns information about the script identified by id
. If the optional parameter html
is present (its value is ignored), the info is formatted using StelScriptMgr::getHtmlDescription and suitable for inclusion into an iframe
element, otherwise this operation returns a JSON object of format:
Returns the current script status as a JSON object of format:
StelScriptMgr.runningScriptId
that can be used to find out the active script.Implemented by ScriptService::postImpl
Parameters: id (String)
Runs the script with the given id
. Will fail if a script is currently running.
Parameters: code (String) [useIncludes (Bool)]
Directly executes the given script code
. If useIncludes
is given and evaluates to true, the standard include folder will be used. Script execution will fail if a script is already running.
Stops the execution of a running script.
Implemented by SimbadService::getImpl
Parameters: str (String)
Performs a SIMBAD lookup for the string str
using the Stellarium-configured server and returns the results as a JSON object of format
Implemented by StelActionService::getImpl
Lists all registered StelActions, in the format
Implemented by StelActionService::postImpl
Parameters: id (String)
Triggers or toggles the StelAction specified by id
. If it was a boolean action, returns the new state of the action (strings "true"/"false").
Implemented by StelPropertyService::getImpl
Lists all registered StelProperties, in the format
Implemented by StelPropertyService::postImpl
Parameters: id (String) value (String)
Sets the StelProperty identified by id
to the value value
. The value is converted to the StelProperty type using QVariant logic, an error is returned if this is somehow not possible.
Implemented by LocationService::getImpl
Returns the list of all stored location IDs (keys of StelLocationMgr::getAllMap) as JSON string array
Returns the list of all known countries (StelLocaleMgr::getAllCountryNames), as a JSON array of objects of format
Returns the list of all solar system planet names (SolarSystem::getAllPlanetEnglishNames), as a JSON array of objects of format
Parameters: planet (String)
Returns the planet texture image for the planet
(english name)
Implemented by LocationService::postImpl
Parameters: id (String) | ( [latitude (Number)] [longitude (Number)] [altitude (Number)] [name (String)] [country (String)] [planet (String)] )
Changes and moves to a new location. If id
is given, all other parameters are ignored, and a location is searched from the named locations using StelLocationMgr::locationForString with the id
. Else, the other parameters change the specific field of the current StelLocation.
Implemented by LocationSearchService::getImpl
Parameters: term (String)
Searches the term
in the list of predefined locations of the StelLocationMgr, and returns a JSON string array of the results.
Parameters: [planet (String)] [latitude (Number)] [longitude (Number)] [radius (Number)]
Searches near the location defined by planet
, latitude
and longitude
for predefined locations (inside the given radius
) using StelLocationMgr::pickLocationsNearby, returns a JSON string array.
Implemented by ViewService::getImpl
Lists the installed landscapes as a JSON object of format
Note that the slash at the end is mandatory!
Provides virtual filesystem access to the current landscape directory. The operation can take a longer path in the URL. The remainder is used to access files in the landscape directory. If no longer path is given, the current HTML landscape description (as per LandscapeMgr::getCurrentLandscapeHtmlDescription) is returned. An example: landscapedescription/image.png
returns image.png
from the current landscape directory.
This operation allows to set up an HTML iframe
or similar for the landscape description, including all images, etc. embedded in the HTML description.
Lists the installed sky cultures as a JSON object of format
Note that the slash at the end is mandatory!
Provides virtual filesystem access to the current skyculture directory. The operation can take a longer path in the URL. The remainder is used to access files in the skyculture directory. If no longer path is given, the current HTML skyculture description (as per StelSkyCultureMgr::getCurrentSkyCultureHtmlDescription) is returned. An example: skyculturedescription/image.png
returns image.png
from the current skyculture directory.
This operation allows to set up an HTML iframe
or similar for the skycultures description, including all images, etc. embedded in the HTML description.
Lists the available projection types as a JSON object of format
Returns the HTML description of the current projection (StelProjector::getHtmlSummary)