spacetraders.io client
Apr 21, 2025
4 minute read

A custom client for spacetraders.io using ebitengine.

spacetraders.io has been an on-and-off obsession of mine for years. Every time I return, it pulls me into a months-long spiral of automation and systems tinkering. It’s one of the most satisfying playgrounds for exploration, creativity, and code-driven strategy I’ve found. Through this game I’ve gotten to play with

  • good coding design
  • API rate limiting mitigation
  • object oriented-like modeling
  • behavior trees/GOAP for coding ship behavior and mission execution
  • 2d game programming with ebitengine
  • djikstra’s algorithm for efficient waypoint navigation

Unlike most games, there’s no flashy client, no install button, no graphical interface at all. SpaceTraders is pure API. You sign up, pick a callsign (I’m BWIGGS), and get handed a JSON/REST token. That’s it. Your mission control is whatever code you write to interact with the universe.

You start with a single COMMAND ship. BWIGGS-1. Now what?

Missions

Contract Fulfillment

Factions offer money to you for delivering goods to a specific location. you can request a contract with a ship at a specific waypoint. Then you need to go source the required goods for the contract and deliver it to the specified location. You get paid on acceptance and again on delivery.

Trade Arbitrage

Within your system,there are several planets, asteroid bases, and other waypoint that offer a market to buy sell goods and services. Markets fluctuate,so the price of a good now could change later.

The market prices are only available when you have a ship at that waypoint. One strategy is to flood the system with SATELLITE ships, that are coded to check the price of goods every so often. You also might want to think about have your ships record the price of goods as they hop through the system.

Revenue

How profitable are your trades? Are you tracking the fuel cost and time of delivery with each trade you execute? Are you making or losing money on each trade? There’s a lot to explorer here. I’ve noticed that a contract might come in that is no very lucrative or potentially even a net loss, but the next contract is a windfall. So it makes sense at times to take a loser contract.

Mining

Mining is a fun one,and required coordination of multiple ships.

While you can use a single ship to mine an asteroid and deliver those materials to a destination. the mining ships typically have smaller cargo holds than say your command ship. So there’s a strategy of having multiple mining craft unload into a massive delivery ship.

How do you automate that?

Market Tracking

The prices of goods/fuel/ship changes over time as the game progresses. What was once a cheap commodity now becomes a very expensive part of your supply chain. Some players track this over time into Grafana/InfluxDB.

I currently have market data stored in a local sqlite database, no historical at the moment, just more recent prices for goods. Works for now, I may need to change it later.

To do either of these you need to navigate between waypoints (planets, asteroids, …).

How do you get your ship from one planet to the next? Issue a navigate api request, but wait, you don’t have eneough fuel capacity to get from one the code of your system to the outer rim, so you need to hop. How do you do that? Well now you’re in computer science world! Traveling Salesman? Shortest Path? WEighted paths? Knuth’s algorithm? SpaceTraders brings the opportunity for you to play with these concepts.

Fuel costs

Fuel costs money, do you fill up along the way? Do you fill up once along the way and again at the end? Will you have enough fuel toget back or will you be marooned on some distant asteroid?

Game Client

The playground is a bit limited in what you can do but it is a great starting point. Once you outgrow that, then what? How do you want to visualize the game? Do you want a simple web UI to click buttons and manually issue commands?

Most recently I wanted to try out ebitengine: A dead simple 2D game engine for Go. So I created a client to chart out my system, the overall galaxy and my ships. What a fun challenge!

Click the following image to watch a video capture of the UI.

Click to play