Service#

Provides functionality to interact with Kerbal Space Program. This includes controlling the active vessel, managing its resources, planning maneuver nodes and auto-piloting.

GET /space-center/expansions#

The names of the installed expansions, for example "Serenity" (Breaking Ground) or "MakingHistory" (Making History).

Response JSON Object:
  • value (list<string>)

GET /space-center/science#

The current amount of science.

Response JSON Object:
  • value (float)

GET /space-center/funds#

The current amount of funds.

Response JSON Object:
  • value (double)

GET /space-center/reputation#

The current amount of reputation.

Response JSON Object:
  • value (float)

GET /space-center/active-vessel#

The currently active vessel.

Response JSON Object:
  • value (SpaceCenter.Vessel?)

PUT /space-center/active-vessel#

The currently active vessel.

Request JSON Object:
  • value (SpaceCenter.Vessel?) – The new value.

GET /space-center/vessels#

A list of all the vessels in the game.

Response JSON Object:
  • value (list<SpaceCenter.Vessel>)

GET /space-center/launch-sites#

A list of available launch sites.

Response JSON Object:
  • value (list<SpaceCenter.LaunchSite>)

GET /space-center/bodies#

A dictionary of all celestial bodies (planets, moons, etc.) in the game, keyed by the name of the body.

Response JSON Object:
  • value (dictionary<string, SpaceCenter.CelestialBody>)

GET /space-center/target-body#

The currently targeted celestial body.

Response JSON Object:
  • value (SpaceCenter.CelestialBody?)

PUT /space-center/target-body#

The currently targeted celestial body.

Request JSON Object:
  • value (SpaceCenter.CelestialBody?) – The new value.

GET /space-center/target-vessel#

The currently targeted vessel.

Response JSON Object:
  • value (SpaceCenter.Vessel?)

PUT /space-center/target-vessel#

The currently targeted vessel.

Request JSON Object:
  • value (SpaceCenter.Vessel?) – The new value.

GET /space-center/target-docking-port#

The currently targeted docking port.

Response JSON Object:
  • value (SpaceCenter.DockingPort?)

PUT /space-center/target-docking-port#

The currently targeted docking port.

Request JSON Object:
  • value (SpaceCenter.DockingPort?) – The new value.

POST /space-center/clear-target#

Clears the current target.

POST /space-center/launchable-vessels#

Returns a list of vessels from the given craft_directory that can be launched.

Request JSON Object:
  • craft_directory (string) – Name of the directory in the current saves “Ships” directory. For example "VAB" or "SPH".

Response JSON Object:
  • value (list<string>)

POST /space-center/launch-vessel#

Launch a vessel.

Note

The crew parameter controls how the craft is crewed:

  • If null, the craft’s default crew assignments are used.

  • If an empty list, the craft is launched with no crew.

  • Otherwise, the named Kerbals are placed in the craft in the order given: the first name takes the first seat, the second name the next seat, and so on, scanning the craft’s parts in order. No other Kerbals are hired to fill remaining seats. Throws an exception, without launching, if a name does not match an available Kerbal or the craft has too few seats for the requested crew.

Throws an exception if any of the games pre-flight checks fail.

Request JSON Object:
  • craft_directory (string) – Name of the directory in the current saves “Ships” directory, that contains the craft file. For example "VAB" or "SPH".

  • name (string) – Name of the vessel to launch. This is the name of the “.craft” file in the save directory, without the “.craft” file extension.

  • launch_site (string) – Name of the launch site. For example "LaunchPad" or "Runway".

  • crew (list<string>?) – The Kerbals to place in the craft, by name. Controls how the craft is crewed, as described in the remarks. Optional, defaults to null.

  • recover (bool) – If true and there is a vessel on the launch site, recover it before launching. Optional, defaults to true.

  • flag_url (string) – If not null, the asset URL of the mission flag to use for the launch. Optional, defaults to "".

POST /space-center/launch-vessel-from-vab#

Launch a new vessel from the VAB onto the launchpad.

Note

This is equivalent to calling POST /space-center/launch-vessel with the craft directory set to “VAB” and the launch site set to “LaunchPad”. Throws an exception if any of the games pre-flight checks fail.

Request JSON Object:
  • name (string) – Name of the vessel to launch.

  • recover (bool) – If true and there is a vessel on the launch pad, recover it before launching. Optional, defaults to true.

POST /space-center/launch-vessel-from-sph#

Launch a new vessel from the SPH onto the runway.

Note

This is equivalent to calling POST /space-center/launch-vessel with the craft directory set to “SPH” and the launch site set to “Runway”. Throws an exception if any of the games pre-flight checks fail.

Request JSON Object:
  • name (string) – Name of the vessel to launch.

  • recover (bool) – If true and there is a vessel on the runway, recover it before launching. Optional, defaults to true.

GET /space-center/editor#

The editor, for inspecting the vessel that is being constructed.

Response JSON Object:
  • value (SpaceCenter.Editor)

POST /space-center/save#

Save the game with a given name. This will create a save file called name.sfs in the folder of the current save game.

Request JSON Object:
  • name (string) – Name of the save.

POST /space-center/load#

Load the game with the given name. This will create a load a save file called name.sfs from the folder of the current save game.

Request JSON Object:
  • name (string) – Name of the save.

POST /space-center/quicksave#

Save a quicksave.

Note

This is the same as calling POST /space-center/save with the name “quicksave”.

POST /space-center/quickload#

Load a quicksave.

Note

This is the same as calling POST /space-center/load with the name “quicksave”.

GET /space-center/can-save#

Whether the game can be saved.

Note

The game cannot be saved in some flight states, e.g. while under acceleration or moving over the surface. Setting GET /krpc/game-scene to leave flight saves the game only when this is true.

Response JSON Object:
  • value (bool)

POST /space-center/can-revert-to-launch#

Whether the current flight can be reverted to launch.

Response JSON Object:
  • value (bool)

POST /space-center/revert-to-launch#

Revert the current flight to launch.

POST /space-center/transfer-crew#

Transfers a crew member to a different part.

Request JSON Object:
  • crew_member (SpaceCenter.CrewMember) – The crew member to transfer.

  • target_part (SpaceCenter.Part) – The part to move them to.

GET /space-center/ui-visible#

Whether the UI is visible.

Response JSON Object:
  • value (bool)

PUT /space-center/ui-visible#

Whether the UI is visible.

Request JSON Object:
  • value (bool) – The new value.

GET /space-center/navball#

Whether the navball is visible.

Response JSON Object:
  • value (bool)

PUT /space-center/navball#

Whether the navball is visible.

Request JSON Object:
  • value (bool) – The new value.

GET /space-center/altimeter-mode#

The current mode of the altimeter.

Response JSON Object:
  • value (SpaceCenter.AltimeterMode)

PUT /space-center/altimeter-mode#

The current mode of the altimeter.

Request JSON Object:
  • value (SpaceCenter.AltimeterMode) – The new value.

GET /space-center/ut#

The current universal time in seconds.

Response JSON Object:
  • value (double)

GET /space-center/g#

The value of the gravitational constant G in \(\mathrm{N(m/kg)^{2}}\).

Response JSON Object:
  • value (double)

GET /space-center/buoyancy-scalar#

The multiplier the game applies to every buoyant force.

Note

Stock KSP sets it to 1.2. A buoyant force is a fifth larger than Archimedes’ principle alone gives.

Response JSON Object:
  • value (double)

GET /space-center/warp-rate#

The current warp rate. This is the rate at which time is passing for either on-rails or physical time warp. For example, a value of 10 means time is passing 10x faster than normal. Returns 1 if time warp is not active.

Response JSON Object:
  • value (float)

GET /space-center/warp-factor#

The current warp factor. This is the index of the rate at which time is passing for either regular “on-rails” or physical time warp. Returns 0 if time warp is not active. When in on-rails time warp, this is equal to GET /space-center/rails-warp-factor, and in physics time warp, this is equal to GET /space-center/physics-warp-factor.

Response JSON Object:
  • value (float)

GET /space-center/rails-warp-factor#

The time warp rate, using regular “on-rails” time warp. A value between 0 and 7 inclusive. 0 means no time warp. Returns 0 if physical time warp is active.

If requested time warp factor cannot be set, it will be set to the next lowest possible value. For example, if the vessel is too close to a planet. See the KSP wiki for details.

Note

Outside the flight scene, every factor can be set.

Response JSON Object:
  • value (int32)

PUT /space-center/rails-warp-factor#

The time warp rate, using regular “on-rails” time warp. A value between 0 and 7 inclusive. 0 means no time warp. Returns 0 if physical time warp is active.

If requested time warp factor cannot be set, it will be set to the next lowest possible value. For example, if the vessel is too close to a planet. See the KSP wiki for details.

Note

Outside the flight scene, every factor can be set.

Request JSON Object:
  • value (int32) – The new value.

GET /space-center/physics-warp-factor#

The physical time warp rate. A value between 0 and 3 inclusive. 0 means no time warp. Returns 0 if regular “on-rails” time warp is active.

Response JSON Object:
  • value (int32)

PUT /space-center/physics-warp-factor#

The physical time warp rate. A value between 0 and 3 inclusive. 0 means no time warp. Returns 0 if regular “on-rails” time warp is active.

Request JSON Object:
  • value (int32) – The new value.

POST /space-center/can-rails-warp-at#

Returns true if regular “on-rails” time warp can be used, at the specified warp factor. The maximum time warp rate is limited by various things, including how close the active vessel is to a planet. See the KSP wiki for details.

Note

Outside the flight scene, every valid factor can be used.

Request JSON Object:
  • factor (int32) – The warp factor to check. Optional, defaults to 1.

Response JSON Object:
  • value (bool)

GET /space-center/maximum-rails-warp-factor#

The current maximum regular “on-rails” warp factor that can be set. A value between 0 and 7 inclusive. See the KSP wiki for details.

Note

Outside the flight scene, this is the highest factor.

Response JSON Object:
  • value (int32)

POST /space-center/warp-to#

Uses time acceleration to warp forward to a time in the future, specified by universal time ut. This call blocks until the desired time is reached. Uses regular “on-rails” or physical time warp as appropriate. For example, physical time warp is used when the active vessel is traveling through an atmosphere. When using regular “on-rails” time warp, the warp rate is limited by max_rails_rate, and when using physical time warp, the warp rate is limited by max_physics_rate.

Note

Outside the flight scene, only regular “on-rails” time warp is used. Throws an exception if the game scene changes during the time warp.

Request JSON Object:
  • ut (double) – The universal time to warp to, in seconds.

  • max_rails_rate (float) – The maximum warp rate in regular “on-rails” time warp. Optional, defaults to 1e+05.

  • max_physics_rate (float) – The maximum warp rate in physical time warp. Optional, defaults to 2.0.

POST /space-center/transform-position#

Converts a position from one reference frame to another.

Request JSON Object:
  • position (tuple<double, double, double>) – Position, as a vector, in reference frame from.

  • from (SpaceCenter.ReferenceFrame) – The reference frame that the position is in.

  • to (SpaceCenter.ReferenceFrame) – The reference frame to covert the position to.

Response JSON Object:
  • value (tuple<double, double, double>) – The corresponding position, as a vector, in reference frame to.

POST /space-center/transform-direction#

Converts a direction from one reference frame to another.

Request JSON Object:
  • direction (tuple<double, double, double>) – Direction, as a vector, in reference frame from.

  • from (SpaceCenter.ReferenceFrame) – The reference frame that the direction is in.

  • to (SpaceCenter.ReferenceFrame) – The reference frame to covert the direction to.

Response JSON Object:
  • value (tuple<double, double, double>) – The corresponding direction, as a vector, in reference frame to.

POST /space-center/transform-rotation#

Converts a rotation from one reference frame to another.

Request JSON Object:
  • rotation (tuple<double, double, double, double>) – Rotation, as a quaternion of the form (x, y, z, w), in reference frame from.

  • from (SpaceCenter.ReferenceFrame) – The reference frame that the rotation is in.

  • to (SpaceCenter.ReferenceFrame) – The reference frame to covert the rotation to.

Response JSON Object:
  • value (tuple<double, double, double, double>) – The corresponding rotation, as a quaternion of the form (x, y, z, w), in reference frame to.

POST /space-center/transform-velocity#

Converts a velocity (acting at the specified position) from one reference frame to another. The position is required to take the relative angular velocity of the reference frames into account.

Request JSON Object:
  • position (tuple<double, double, double>) – Position, as a vector, in reference frame from.

  • velocity (tuple<double, double, double>) – Velocity, as a vector that points in the direction of travel and whose magnitude is the speed in \(\mathrm{m/s}\), in reference frame from.

  • from (SpaceCenter.ReferenceFrame) – The reference frame that the position and velocity are in.

  • to (SpaceCenter.ReferenceFrame) – The reference frame to covert the velocity to.

Response JSON Object:
  • value (tuple<double, double, double>) – The corresponding velocity, as a vector, in reference frame to.

POST /space-center/raycast-distance#

Cast a ray from a given position in a given direction, and return the distance to the hit point. If no hit occurs, returns infinity.

Request JSON Object:
  • position (tuple<double, double, double>) – Position, as a vector, of the origin of the ray.

  • direction (tuple<double, double, double>) – Direction of the ray, as a unit vector.

  • reference_frame (SpaceCenter.ReferenceFrame) – The reference frame that the position and direction are in.

Response JSON Object:
  • value (double) – The distance to the hit, in meters, or infinity if there was no hit.

POST /space-center/raycast-part#

Cast a ray from a given position in a given direction, and return the part that it hits. If no hit occurs, returns null.

Request JSON Object:
  • position (tuple<double, double, double>) – Position, as a vector, of the origin of the ray.

  • direction (tuple<double, double, double>) – Direction of the ray, as a unit vector.

  • reference_frame (SpaceCenter.ReferenceFrame) – The reference frame that the position and direction are in.

Response JSON Object:
  • value (SpaceCenter.Part?) – The part that was hit or null if there was no hit.

GET /space-center/far-available#

Whether Ferram Aerospace Research is installed.

Response JSON Object:
  • value (bool)

GET /space-center/ag-ext-available#

Whether Action Groups Extended is installed.

Response JSON Object:
  • value (bool)

GET /space-center/real-fuels-available#

Whether RealFuels is installed.

Response JSON Object:
  • value (bool)

GET /space-center/real-chute-available#

Whether RealChute is installed.

Response JSON Object:
  • value (bool)

GET /space-center/procedural-fairings-available#

Whether Procedural Fairings is installed.

Response JSON Object:
  • value (bool)

GET /space-center/near-future-solar-available#

Whether Near Future Solar is installed.

Response JSON Object:
  • value (bool)

GET /space-center/d-magic-available#

Whether DMagic’s DMModuleScienceAnimateGeneric is installed.

Response JSON Object:
  • value (bool)

GET /space-center/firespitter-available#

Whether Firespitter is installed.

Response JSON Object:
  • value (bool)

GET /space-center/kerbal-actuators-available#

Whether KerbalActuators is installed.

Response JSON Object:
  • value (bool)

GET /space-center/ksp-community-part-modules-available#

Whether KSPCommunityPartModules is installed.

Response JSON Object:
  • value (bool)

GET /space-center/kos-available#

Whether kOS is installed.

Response JSON Object:
  • value (bool)

GET /space-center/b9-part-switch-available#

Whether B9PartSwitch is installed.

Response JSON Object:
  • value (bool)

GET /space-center/tweak-scale-rescaled-available#

Whether TweakScale Rescaled is installed.

Response JSON Object:
  • value (bool)

GET /space-center/real-antennas-available#

Whether RealAntennas is installed.

Response JSON Object:
  • value (bool)

GET /space-center/kerbals#

The Kerbals in the roster.

Response JSON Object:
  • value (list<SpaceCenter.CrewMember>)

POST /space-center/create-kerbal#

Creates a Kerbal.

Request JSON Object:
  • name (string)

  • job (string)

  • male (bool)

POST /space-center/get-kerbal#

Find a Kerbal by name.

Request JSON Object:
  • name (string)

Response JSON Object:
  • value (SpaceCenter.CrewMember?)

GET /space-center/map-filter#

The visible objects in map mode.

Response JSON Object:
  • value (SpaceCenter.MapFilterType)

PUT /space-center/map-filter#

The visible objects in map mode.

Request JSON Object:
  • value (SpaceCenter.MapFilterType) – The new value.

POST /space-center/screenshot#

Saves a screenshot.

Request JSON Object:
  • file_path (string) – The path of the file to save.

  • scale (int32) – Resolution scaling factor Optional, defaults to 1.

GET /space-center/game-mode#

The current mode the game is in.

Response JSON Object:
  • value (SpaceCenter.GameMode)

GET /space-center/warp-mode#

The current time warp mode. Returns "none" if time warp is not active, "rails" if regular “on-rails” time warp is active, or "physics" if physical time warp is active.

Response JSON Object:
  • value (SpaceCenter.WarpMode)

GET /space-center/camera#

An object that can be used to control the camera.

Response JSON Object:
  • value (SpaceCenter.Camera)

GET /space-center/waypoint-manager#

The waypoint manager.

Response JSON Object:
  • value (SpaceCenter.WaypointManager)

GET /space-center/contract-manager#

The contract manager.

Response JSON Object:
  • value (SpaceCenter.ContractManager)

GET /space-center/alarm-manager#

The alarm manager.

Response JSON Object:
  • value (SpaceCenter.AlarmManager)

GameMode

The game mode. Returned by GameMode

Passed and returned as the name of one of its values:

"sandbox"

Sandbox mode.

"career"

Career mode.

"science"

Science career mode.

"science_sandbox"

Science sandbox mode.

"mission"

Mission mode.

"mission_builder"

Mission builder mode.

"scenario"

Scenario mode.

"scenario_non_resumable"

Scenario mode that cannot be resumed.

AltimeterMode

The mode of the altitude reported on the altimeter. See GET /space-center/altimeter-mode.

Passed and returned as the name of one of its values:

"default"

The altimeter is in the default mode.

"asl"

The altimeter is in the “Above Sea Level” mode.

"agl"

The altimeter is in the “Above Ground Level” mode.

WarpMode

The time warp mode. Returned by WarpMode

Passed and returned as the name of one of its values:

"rails"

Time warp is active, and in regular “on-rails” mode.

"physics"

Time warp is active, and in physical time warp mode.

"none"

Time warp is not active.

MapFilterType

The set of things that are visible in map mode.

Note

The values may be combined.

A flags enumeration, passed and returned as a list of the names of its values:

"all"

Everything.

"none"

Nothing.

"debris"

Debris.

"unknown"

Unknown.

"space_objects"

SpaceObjects.

"probes"

Probes.

"rovers"

Rovers.

"landers"

Landers.

"ships"

Ships.

"stations"

Stations.

"bases"

Bases.

"evas"

EVAs.

"flags"

Flags.

"plane"

Planes.

"relay"

Relays.

"site"

Launch Sites.

"deployed_science_controller"

Deployed Science Controllers.

LaunchSite

A place where craft can be launched from. More of these can be added with mods like Kerbal Konstructs.

Passed and returned as an object with these fields:

name (string)

The name of the launch site.

body (SpaceCenter.CelestialBody)

The celestial body the launch site is on.

editor_facility (SpaceCenter.EditorFacility)

Which editor is normally used for this launch site.

latitude (double)

The latitude of the point vessels launch from, in degrees, or NaN if the site has no spawn point.

longitude (double)

The longitude of the point vessels launch from, in degrees, or NaN if the site has no spawn point.

altitude (double)

The altitude above sea level of the point vessels launch from, in meters, or NaN if the site has no spawn point.

EditorFacility

Editor facility. See editor_facility.

Passed and returned as the name of one of its values:

"vab"

Vehicle Assembly Building.

"sph"

Space Plane Hanger.

"none"

None.