• ⚠️ Mod Release Rules now apply to this board.

    All mods must include a license, source code (for executable mods), and proper attribution.

    Read the full rules here before posting.

Tools kRPC v0.3.0 - Control KSA with scripts in Python, C#, C++, C, Java, Lua, JavaScript, HTTP requests and more

djungelorm

New Member
Messages
6
Reaction score
11
banner-ksa.png

kRPC allows you to control the game from scripts written in Python, C#, C++, C, Java, Lua, JavaScript and more. It also includes an HTTP API.

This a continuation of the mod of the same name for KSP, and shares the same client libraries with it. It provides a server that runs in KSA, and works with all the same client libraries that the original kRPC mod uses.

This python script launches a rocket from Cape Canaveral, flies it straight up, and cuts the engines at 10 km:
Python
import krpc
conn = krpc.connect(name="Launch")
ksa = conn.ksa
vehicle = ksa.launch_vehicle("Rocket", "CCSFS LC-39A")
flight = vehicle.flight

vehicle.auto_pilot.target_pitch_and_heading(90, 90)
vehicle.auto_pilot.engage()
vehicle.control.throttle = 1
vehicle.control.activate_next_sequence()
vehicle.control.engine_on = True

event = conn.add_event(lambda: flight.mean_altitude > 10000)
with event.condition:
    event.wait()

vehicle.control.engine_on = False
print(f"{vehicle.name} reached 10 km")
Features
  • Telemetry: altitudes, speeds, attitude, pressure, g-force, thrust and specific impulse, and the delta-v of each sequence.
  • Orbits, including the orbits of bodies, the orbit after a planned burn, and the predicted trajectory through sphere of influence changes.
  • Parts, resources and part modules: engines, RCS, decouplers, parachutes and docking ports.
  • Landing: terrain height anywhere on a body, altitude above the terrain, and the time to impact.
  • Reference frames, with positions, velocities and rotations in body, vehicle, surface and orbital frames.
  • Control: throttle, engines, staging, and the flight computer as an auto-pilot, including executing planned burns.
  • Launching vehicles onto a launch pad, and time warp.
  • Server side functions: events, streams and functions that run inside the game, once per frame.
  • kFS support: build, load, start and stop programs remotely on kFS, the in-game flight software. kRPC scripts can also communicate with kFS programs via the program's variables and logs.
  • Native client libraries for many languages
  • gRPC server: the mod includes a server that can talk to gRPC clients. Allows any language that gRPC supports to communicate.
  • HTTP API if you don't want to use a client library
Documentation
krpc.github.io/krpc/experimental/ksa, with a getting started guide, tutorials, and the API reference for each client language.

Find us on Discord: https://discord.gg/c8c36UM

Requirements
  • Kitten Space Agency v2026.11.16.5901
  • StarMap 0.5.4 by KlaasWhite (MIT)
  • A kRPC 0.8.0 client library, for example the Python client: pip install krpc==0.8.0 See the documentation website (link above) for more details.
  • Tested on Windows and Linux.
Installation
kRPC is available via Borea and SpaceDock

Or to install manually:
  1. Install StarMap
  2. Copy the kRPC folder from the archive into <Documents>/My Games/Kitten Space Agency/mods.
  3. Enable the mod in <Documents>/My Games/Kitten Space Agency/manifest.toml:
    Code
    [[mods]]
    id = "kRPC"
    enabled = true
  4. Launch the game through StarMap.
  5. The server starts once the game has loaded its mods.
The archive also holds the client stubs for C#, C++, C and Java, and example scripts. Note: pre-generated stubs are *not* required for the Pytho, Lua and JavaScript clients, or the HTTP API.

Source and Bug Reports
Source: github.com/krpc/krpc
Bug reports and feature requests: GitHub issues

License
kRPC is licensed under the LGPL v3. It bundles Google.Protobuf (BSD 3-Clause), System.IO.Ports (MIT), ASP.NET Core (MIT) and gRPC for .NET (Apache 2.0), whose licenses are in the archive.
 
Last edited:
Yes this would be a great addition to the Borea index!
 
I'll get it added to Borea in the next release. The way I packaged it for 0.1.0 would need a hacky workaround just for that release, as the version string is baked into the root folder in the archive. Oops. Shouldn't be too long ;)

I also updated the OP with planned features. I'm quite excited to be able to add gRPC - will allow many many many more client languages!
 
I just released v0.2.0, and it's now listed on Borea too!

Features added:
  • gRPC server: control the game from any language gRPC supports (there are many!)
  • In-game UI to configure the server
  • More API coverage: engines, fuel, power, lights, kittens and EVA, camera, screenshots, saving and loading
  • Drawing and UI: draw lines, shapes and text in the scene, and build your own windows
  • Supports KSA v2026.10.25.5707, and has best-effort handling of other game versions. A pop-up lists any RPCs that use game code missing from that version, and the rest keep working.
Note: upgrading from v0.1.0, the mod folder is now named kRPC, so delete the old mods/kRPC.KSA folder first.
 
I'm the creator of this:
68747470733a2f2f692e706f7374696d672e63632f744a5862714b70432f75677071786d796369623963312e6a7067


I will be using this mod as a backend for a new Streamdeck Plugin to control the vessels and get readouts.
I have already started!

Anxiously awaiting you adding more API coverage!
 
Last edited:
I'm the creator of this:
68747470733a2f2f692e706f7374696d672e63632f744a5862714b70432f75677071786d796369623963312e6a7067


I will be using this mod as a backend for a new Streamdeck Plugin to control the vessels and get readouts.
I have already started!

Anxiously awaiting you adding more API coverage!
Cool! I see your project is written in JavaScript - I'm currently working on adding a proper JavaScript client library, but for now you could use the gRPC server type from JavaScript.
 
Cool! I see your project is written in JavaScript - I'm currently working on adding a proper JavaScript client library, but for now you could use the gRPC server type from JavaScript.
here is the new Repo for KSA version:
1794363014307.png
1794363032365.png
 
Last edited:
kRPC v0.3.0 for KSA has been released :) Here are the highlights:

- kFS support: build, load, start and stop programs remotely on kFS, the in-game flight software. kRPC scripts can also communicate with kFS programs via the program's variables and logs.
- JavaScript client, for the browser and Node.js.
- HTTP API: call the server with JSON over HTTP, without the need for a client library.
- More KSA API coverage: life support and crew, engines, power, aerodynamics, orbits, radiation and space weather.
- **Compatibility note:** this release needs kRPC 0.8 clients, and the mod's settings have moved to `kRPC/settings.toml`
 
Back
Top