Monday, March 11, 2013

Python iRacing API client

Some of you will already know that I am a massive fan of the racing simulator iRacing. I signed up to this "game" a couple of years ago and it's lead to the purchase of new computers, steering wheels and even a dedicated "racing seat".

What I've always wanted to do was build a basic motion rig for the game, something that at least would represent lateral acceleration to give me a better idea of my grip limits when driving. The first step towards this is parsing the telemetry from the game.

iRacing has a telemetry API that's solely documented in the manner of a demo client built from a pile of C code. Whilst I am certainly capable of programming in C, my preference is definitely my pet language, Python. Some brave souls have built clients in C#, but that isn't much better *

Aside from my own bias, Python is a really nice language to use as a new programmer, so developing this client should allow for more people to develop iRacing add-ons which can only be a good thing!

Anyway, I decided to build a Python implementation of a client for iRacing. The API uses a memory mapped file, something Python happily supports out of the box, as well as C data structures for all the high-frequency telemetry which I was able to parse using Python's struct module.

As I was secretly hoping, Python's dynamic-programming abilities allowed me to write a client in short order, using very little code.

The code's right here on GitHub. It's, honestly, quite rough-and-ready, but it works. Please do let me know if you have success or problems with it, I'll do my best to help out. I expect it'll be updated regularly, or whenever I find a bug...

You'll have to extend and modify it to work with your application, but that's half the fun - enjoy! :)

* Whilst I'm not a huge fan of C#, the in-line debugging/inspection functionality in Visual Studio was a god-send when applied it to the C# demo client.


  1. Hello, I'm a fairly beginner programmer and I just got a free Raspberry Pi off a friend. I was thinking about using it to make a tachometer with some LEDs for iRacing.

    I've worked out how to make the LEDs turn on and off with Python, I just need to get the data out of iRacing somehow.

    Will your code help me with this? I looked at the but most of it looks too complicated for me. Will it work on a Raspberry Pi over the network?


    1. Hi Pete,

      Sorry for the massive delay, I reckon you could use my code for this. I would suggest creating a XMLRPC client on the Pi to connect to an XMLRPC server on you PC. The server on your pc could wrap my API client ( and return the RPM via a method in XMLRPC.



  2. Does anyone else have freezes when playing in Wine?
    It does not happen to me when running under VMware Workstation.
    The sound, and graphics locks up for 6-10 seconds, and then it continues. Very hard to win races when that happens. For more interesting information click here.
    I happens in 1/3 races.

  3. I can set up my new idea from this post. It gives in depth information. Thanks for this valuable information for all, click this site