Skip to main content

Terrex

Programmable automation client for Terraria servers.

PyPI version

Terrex logo


What is Terrex?

Terrex is a Python framework for building programmable Terraria agents (bots).

It provides a clean event-driven API for connecting to servers, reacting to world state, parsing packets and executing scripted behaviors.

Originally inspired by an archived TerraBot project by Alexander Freeman (MIT licensed) (inactive for ~10 years),
Terrex is a modernized, extended and actively developed fork focused on:

  • automation
  • simulation
  • protocol control
  • scalable multi-agent systems

Think of it as a runtime for Terraria agents — not just a bot.


Installation

pip3 install terrex

Core Features

  • Connect to Terraria servers as a client
  • Full chat interaction
  • Event-driven packet handling
  • Live world & player state parsing
  • Item & tile updates tracking
  • Programmatic movement (teleport + control layer)
  • Extensible event system for custom logic

Minimal Example

A basic bot that connects to a server and reacts to chat messages:

import asyncio

from terrex import Terrex
from terrex.event.filter import NewMessage
from terrex.event.types import ChatEvent

async def main() -> None:
    async with Terrex("127.0.0.1", 7777) as client:
        @client.on(NewMessage())
        async def on_chat(event: ChatEvent) -> None:
            print(event.text)

            if "stop" in event.text.lower():
                await client.stop()

        await client.run_until_disconnected()

if __name__ == "__main__":
    asyncio.run(main())

More examples are available in the examples/ directory.


Project Philosophy

Terrex is built as an automation engine — not a cheat client.

Primary use cases include:

  • programmable agents
  • server testing & simulation
  • AI experiments
  • scripted behaviors
  • world interaction automation

Anything else is simply an emergent property.


Contributing

Terrex is under active development and contributions are welcome.

Current high-priority areas:

  • NPC packet parsing
  • Item interactions & drops
  • Player synchronization packets
  • Tile placement & world modification
  • Movement & physics layer

Packet documentation reference: https://github.com/MakStashkevich/terrex/blob/master/docs/packets.md


Origins

Terrex is based on a fork of the original TerraBot project by Alexander Freeman (MIT licensed) (now archived and unmaintained). The codebase has been refactored, extended and re-architected for modern Python workflows.


Roadmap (high level)

  • stable protocol layer
  • multi-agent orchestration
  • scripting behaviors (FSM / behavior trees)
  • performance scaling
  • cleaner API surface

Metadata

Release files for terrex 2.0.1

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

Source distribution (sdist)

Source distribution for terrex 2.0.1
File Size Uploaded Provenance
terrex-2.0.1.tar.gz 230.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for terrex 2.0.1
File Interpreter ABI Platform
terrex-2.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 550.6 kB

Release files / terrex-2.0.1.tar.gz

Download URL terrex-2.0.1.tar.gz
Size 230.8 kB
Tags Source
SHA-256 checksum
How to use checksums
9684a1020c0c9f79f07c212f3e5ade495fc9ba8b4f773709709e663c4dea87fd
BLAKE2b-256 checksum
How to use checksums
827cab747a9dadd889f0860ffbea587310a2ec2017beb5a6bf627ffa67e6678a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Release files / terrex-2.0.1-py3-none-any.whl

Download URL terrex-2.0.1-py3-none-any.whl
Size 319.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7f3c334d290ccfaf759361ab31a312b114dce150eed2660749d4c82ce86c2b47
BLAKE2b-256 checksum
How to use checksums
c2a0118fb3be843955130e71bf36faf7a7ece9302194ce3e74e095d42e93fcdf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Security for terrex 2.0.1

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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