Saturday, 11 March 2017

The Game is On - in one line of code

- or how to play around with the Steam Web API and a honorable mentioning of a nice new game on Steam build using Delphi.

The title of this post could indicate that this is about the BBC series "Sherlock" - which I would highly recommend - but this is not what this is about.

Almost 4 years back I did a small client for myself that did consume various APIs to get a unified client and overview of the various games I had acquired over the years on various platforms like -, Desura (now OnePlay it seems), Uplay, GOG, OriginEA, PSN and Steam - combined with data from TheGameDB and others.

But when GOG announced their Galaxy Client, I had hoped that this would at least give some overview of my games libraries - but alas not yet - so I might revive my old code..

Well back to the task - the game is afoot. If you do not know what Steam is, and don't have a Steam account and any games on that platform, then you might find the below irrelevant - but many of the things can be related to other service API out there - do put a bit of abstraction in there :) and there is also the part about a great new game at the very end.

There are two things that needs to be in place before you can play around with the Steam Web API:
  1. Your need your Steam Web API key - which you get by following the instructions here:
  2. You need your SteamID - which can be found most easily if you change the settings in you Steam client under the Interface section to have "Display Steam URL address bar when available" enabled, when you then edit your profile you see the Id (masked below in red) - afterwards you can disable the option again.

With these two numbers at hand, you can have a bit of fun using the API described here:

So if we start up a new blank FMX project in the newest version our favorite IDE - Delphi 10.1.2 Berlin if anyone should wonder what that is - and under the tools menu start the REST Debugger - we can fill in the newly gathered information - as the endpoint:

and the method (resource) and the request parameters:

Now send the request - and as a tip you can actually use the tabular data grid to set the JSON root element, by clicking the titles and applying the change.

I have masked out my key and id - as also mentioned in the API license, you should not share your API key.

Now click the copy components button, and paste them into the form in the IDE - that we add a TRESTClient, TRESTRequest, TRESTResponse, TFDMemTable and a TRESTResponseDataSetAdapter that are all setup.

The debugger is available as a free download from Embarcadero, if you are not a user of one of their IDE offerings, but want a nice REST debugger.

Add a TListView, a TPanel with two TLabels and a TWebBrowser component - and arrange them to your liking. Right-click on the TRestRequest and execute the request - now you have a set of response data while in designing your application - pretty cool.

Enter the visual binding editor, by right-clicking on the form and select "Bind Visually...". Right-click on the TWebBrowser, select "Bindable Members..." and select the "URL" property - that was the reason I went for an FMX-based application, where the TWebBrowser has an URL property.

At this point in time the IDE with LiveBindings Designer should look a bit like this:

Now visually link the properties like below, and enter the CustomFormat property for the second label as shown:

On the URL property of the TWebBrowser control enter the following CustomFormat:


Here we both have and example of a direct reference to a binding source property and the use of the %S placeholder at the same time.

Just for cosmetics we could also set the FDMemTable.IndexFieldNames property to "name", to get the list sorted nicely.

All set? No - we actually need to include that 1 line of code, on the FormShow event - to execute the REST request.

procedure TForm1.FormShow(Sender: TObject);

Now back to the honorable mentioning of the new game "Blast-off" on Steam build in Delphi - the Store page is here:

And even if I normally do not play games that require an reaction time of sub-seconds - I bought this jumper-style game - and it is very impressive was the three guys from Quad Games has done - even if this is also the early-access version.

What is maybe even cooler is that they currently have 27 hours of live coding on, where they build the game using their QuadEngine also build in Delphi - and even if my Russian is non-existing - they are thankfully keep the best practice of coding in English :D

Link to their channel:

You will also find Embarcadero's Jim McKeeth and Craig Chapman doing live coding on

Support all these guys and enjoy.