Eve Online API and Discord
What Is Eve Online?
If you haven’t heard of Eve Online, it is a Massively Multiplayer Online space sandbox game. Sand box games are games where you can generally do about whatever you want which makes eve a very unique game. There are various YouTube channels and Twitch streams showing gameplay, and if you want to check the game out, go visit it’s website where you can download and play for free. With a bit of googling, you can even get Eve running in Linux via WINE.
Anyway without getting too far into everything you can do in Eve, I want to give a brief explanation about how some pieces of the game work.
Eve allows for a variety of gameplay. Players can battle other ships, they could be other players ships, and they could be their own ships. They often fly in big groups called fleets, but some players prefer to play alone. At the core, Eve is based on getting ships to battle other ships.
But the content in Eve is not soley on fighting. No, where do all the ships come from? Eve, in my opinion, can bost of having the most complex and best in game economy. To build a ship alone, a player needs to find a blueprint for that ship, mine minerals and refine them based on the ships requirements, and then build the ship. The same is true for any equipment mounted on the ship. ALMOST everything in Eve is built by players and, just like our friend Adam Smith showed us, specialization is more efficient. This opens up Eve to more options. Players will mine in large fleets, other players will by all the minerals and refine them, then sell them to other players who will make ships and equipment. Everything has a price based on time, availability and risk.
Eve also has an extremley large universe players can fly in. There are over one thousand different mapped star systems, and hundreds more which are unmapped and can be found from Wormholes. Transporting goods becomes valuable. Not all systems are the same though. Some systems have in game non player police (Concord) which will come defend ships if they are attacked. Other systems have nothing. And this difference in freedom is what brings risk. With more risk comes more reward.
The API
As you can tell from the section above, Eve is a complex game. There is tons of information that has yet to really be dug into, and some players (and non-players) will joke that Eve is a spread sheet simulator. The market especially has tons of room for automation and analyzation.
CCP Games knows this as well, and, while a player can copy past some information directly out of the game and into a spreadshseet, if they want to compare data across systems that quickly becomes a hassle. So we get an API which provides almost any information a player might want to know right to their greasy fingers.
Check out the Eve Swagger Interface, an API that contains a ton of useful information. I quickly found I also needed a bit of extra static data, the Static Data Export provided by eve has all the item and system names matched to their ID, which is used in the api.
I’m not going to talk too much about the actual routes of the API. They are documented well enough on their website that they are not too hard to figure out. I will call out a few of the high level routes which I think are pretty useful. They also outline some pojects I’d like to work on in the future.
Fleets: It would be cool to write a bot that automatically organizes fleets for a player. This would be especially useful in large corperations, or streamers who want to invite viewers to their fleet.
Market: This one might seem obvious but the options here are much larger than I have seen used. Not only can all the data be down to find out how much your stuff is worth before you transport it there to sell it, or to find the cheapest place to buy your next lazer gun. I think the best use will be pulling in resourse information and calculating the items with the best turnover given the current market. Everything from cost of materials, to manufacturing costs, and price to sell could be calculated to optimize the players time.
Discord Travel Bot
When I was actually playing eve activly, I played with players who lived in wormholes. These are unmapped systems, and the only way to get in, or out is to find the wormhole, and then jump through it. Some general information about where you will come out is provided but nothing too specific. Especially if you want to get somewhere specific; like the closest trade hub to sell off all that rare loot you found before someone comes by and tries to kill you for it.
There are tools which help for mapping wormhole systems and networks, and an ingame route calculator that tells you the distance from your current system to a gien system, but no way to know how far one random system is to another. This was the question we were always asking, and when good exit’s were found everyone would report the results on our Discord. Why not automate this process?
On the whole it was a rather simple project, but I was unfamiliar with the API routing and the data. I decided it was a good starting point.
The first thing I needed to do was grab the static data from the SDE. After all, the routes were all based on ID’s not names. The SDE universe data is organized in a series of directories with yaml files. You have to work down from region, to constellation, to solar system. In each directory there is a file with the information. I wrote some code to yank out the data I wanted and stored it all in a mongo database so I could look it up later. There are over a thousand files to read, and on my laptop with an NVME it still took about 10 minutes to open and close them all and drop the data into mongo. Good thing it only had to happen one!
Once the data all existed the project was easy to complete. The process was pretty streight forward:
- Pass in the source and destination names to the bot.
- Look up the id’s for the two systems from the mongo database.
- Make an Eve API request for the route from one to the other.
- Look up the system names (and security status) for each system returned by the API.
- Print the results back to the user.
I also added an option to see the distance from a system to the four major trade hubs. Not only did I want to know how far I would have to travel to sell my loot, I wanted to know which system was the closest before I left.
Discord
Discord is a chat room program that with built in voice. It’s quickly becoming the most popular way for gamers communicate and organize. They provide their own API for connecting but I used the Python Discord API to connect the travel code I had written to Discord. Both the Discord API and the python wrapper are documented pretty well, so I’m not going to get too into creating the code.
The long and the short of it is, you create a client, add your authorization token (you can get it when you register the bot) and tell it to run. Then you can pull the client id and URL for connecting and add the bot to servers you have permissions on.
There is a lot of a lot of existing bots; most people seem interested in playing music in their channel. It’s effective but it seems like they could do so much more. One of my friends has written a bot which connects to the Player Unknown’s Battle Grounds (PUBG) API and queries the match results after each game. He’s integrated it with a number of API’s to pull out cool information, it’s over here I’d like to see more bots utilizing these API’s to create useful tools instead of just playing music.
My time spent playing eve has decreased to almost zero, but the bot is still in use, and gets about ten requests a day, nothing special. But it also only sits on a It’s currenly running on a raspberry pi sitting in my living room. If you want to see the code, check it out. It’s in desperate need of a restructure.