Skip to main content

lfs_insim

A Python library for the Live for Speed InSim protocol: InSim (TCP), OutSim and OutGauge (UDP). Plain import, no framework, no dependencies.

Status: alpha. The library is checked against a real LFS (0.8C), but its API may still change before 1.0.

  • Python 3.11 or newer, no dependencies, fully typed.
  • Every packet class is generated from the official specification published at lfs.net, so the fields are named exactly as in InSim.txt.
  • Handlers with decorators, await insim.request.IS_STA(), chat commands, a roster of connections and players, and automatic reconnection if LFS restarts.

Install

pip install lfs-insim

A first program

In LFS, type /insim=29999 to let it listen for InSim. Then run this and type !hello in the game:

from lfs_insim import Command, Commands, InSim, received


def hello(insim: InSim) -> None:
    """A plugin: `insim.use(hello)` adds it to any InSim, alone or with other plugins."""
    commands = insim.use(Commands)

    @insim.on.IS_VER
    def connected(packet: received.IS_VER) -> None:
        print(f"Connected to LFS {packet.Version}, InSim {packet.InSimVer}")

    @commands.on_command("hello")
    def answer(command: Command) -> None:
        command.reply("Hello from Python")


if __name__ == "__main__":
    insim = InSim(name="hello", prefix="!")  # admin_password="..." if LFS has one
    insim.use(hello)
    insim.run()  # blocks until Ctrl+C; reconnects on its own if LFS restarts

What is in the box

You want to… Use
Receive a packet @insim.on.IS_XXX
Answer a chat command commands = insim.use(Commands), @commands.on_command("name")
Send a packet, chat or /commands insim.send.IS_XXX(...), insim.say(...), insim.command(...)
Ask LFS and wait for the answer await insim.request.IS_STA(), request_all.IS_NPL(), instruct.IS_RIP(...)
Run something on a rhythm @insim.every(seconds)
Know who is connected and who is driving roster = insim.use(Roster) (lfs_insim.state)
Write a plugin, alone or with others a function that takes the InSim: insim.use(plugin)
Test without the game lfs_insim.testing.FakeLFS
Read car physics or the dashboard OutSim and OutGauge
Show LFS text without colour codes lfs_insim.text.plain(...)

The guide is in docs/. Short, runnable programs are in examples/: hello.py, who.py, buttons.py, gauge.py, and together.py, which runs the first three in one program.

Development

This repository is worked on with the notes in docs/dev (in Spanish). To check everything: python scripts/verify.py.

License

MIT — see LICENSE.

Metadata

Release files for lfs-insim 0.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lfs-insim 0.7.0
File Size Uploaded Provenance Actions
lfs_insim-0.7.0.tar.gz 171.5 kB With provenance Details for lfs_insim-0.7.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lfs-insim 0.7.0
File Interpreter ABI Platform Actions
lfs_insim-0.7.0-py3-none-any.whl Python 3 none any Details for lfs_insim-0.7.0-py3-none-any.whl

Total release size: 254.0 kB

Release files / lfs_insim-0.7.0.tar.gz

Download URL lfs_insim-0.7.0.tar.gz
Size 171.5 kB
Tags Source
SHA-256 checksum
How to use checksums
a1a4304dcf01dd2d27eef70f2ef3b8e309712a43edb508fffa48d02b0a224d8c
BLAKE2b-256 checksum
How to use checksums
1236d0f0bab1ab210690cab84a37e5c7b8cc01a6e0c935b013c9e7ee038efd7c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 14, 2026.

Transparency log

Release files / lfs_insim-0.7.0-py3-none-any.whl

Download URL lfs_insim-0.7.0-py3-none-any.whl
Size 82.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d7426eed45d033e4d3807e2a1ec64a57d8946022bd154e0609f59e86bcd3ee38
BLAKE2b-256 checksum
How to use checksums
8955c55f65c3daa9b8d237b5ed7a29b65cc1be768a16f5068855c9e345bd8ddf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 14, 2026.

Transparency log

Security for lfs-insim 0.7.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for lfs_insim-0.7.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 14, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page