jolpica2ergast F1 Database Updater

In addition to this blog and my personal blog I also maintain a Williams Racing fan site at https://williamsdb.com. In fact, this is my longest running site having first gone live on 6th May 1996. As you can imagine this has gone through a number of itterations over the years and the latest makes extensive use of a results database called Ergast.

And then it was gone

About a year ago the maintainer of Ergast announced that he was going to discontinue updating it at the end of 2024. To be honest, I don’t blame him as it seems like a lot of work to keep up-to-date. Of course, you could make an argument that F1 should be providing this directly but they don’t.

This left me searching for an alternative and at one point I thought I was going to have to manually add the data I was interested in by hand after each race. Fortunately, I was saved from that by Jolpica which is an almost direct replacement for Ergast except that it no longer supplies database dumps.

Jolpica2Ergast

This left me with a route forward. I could get the data I needed from Jolpica and insert any updates back into my Ergast database and jolpica2Ergast was born. This queries the Jolpica API and writes the results back to an Ergast database format handling things such as rate limiting.

In Use

It can be run either from the command line or as a web page (although I wouldn’t recommend this) and takes a two parameters as follows:

  • ‘cmd’ which can be set to ‘STATIC’, ‘RACE’ or ‘ALL’. If no parameter is passed, it defaults to ‘ALL’.
  • ‘year’ the four digit year you want to run for. If not passed the script defaults to the current year.

For example:

php index.php race 2024

or

php index.php all

Commands

CommandAction
STATICUpdate any static data such as the circuits, teams and drivers. You should only need to use this once or twice a year.
RACEThis updates the race data such as results, lap data and pit stops
ALLWill run both STATIC and RACE.

Rate limiting

Calls to the Jolpica API are rate limited as follows:

LimitRequests
Burst4 requests per second
Sustained500 requests per hour

The code is written to make as few calls to the API as possible and also manage the rate limiting but the more you request the more likely it is that you will hit the limit. Try and avoid using ALL and spread your calls over a couple of hours. You could do this via cron.

12 Apps in 12 Months

I have been enjoying being a developer once again after years working in ‘management’. I like the creativity and being able to use the fruits of my labour. Therefore, I have decided to stretch myself this year and complete 12 apps in 12 months. These will all inevitably be small affairs that I can write, test, and deploy quickly, such as my Now Playing app from late last year but I do hope to spread out from PHP and, maybe, even write my first mobile app.

So, I present to you January’s app: jolpica2Ergast.

Leave a Reply

Your email address will not be published. Required fields are marked *