February 23, 2023
Banner by soda
Written by supra
We are happy to announce that the ETF2L API v2 is now publicly available for everyone! But…what does this mean for you?
Our previous API had been written by dave who was a Site Coder a long time ago (its active development ended in 2015) in an old language called Perl.
Whilst this does work, maintaining it in its current state is a chore. People don’t code in Perl nowadays and most people don’t have time to spend learning it specifically for updating the API, so this update functions as a way for us to work with the latest versions of the libraries available, as well as extending the APIs capabilities.
API v2 should be great news for developers of websites and their applications utilizing ETF2L data. For those who don’t know – API stands for Application Programming Interface and it’s essentially an application that lets other applications/websites like tf2pickup.org based websites such as hl.tf2pickup.eu or tf2center.com to download data about players, teams, competitions, matches and so on. If you have ever played on pug.champ.gg, you will have noticed that the divisions of players waiting in a queue will show. The way that this works is that their website fetches that player’s match history and processes it in order to find out what’s the player experience is. In order to fetch this kind of data, the ETF2L API is being used.
API v2 has been rewritten from scratch by adje in a modern PHP framework called Laravel. It is fully compatible with API v1 query for JSON-formatted queries. Having it done lets us extend it’s features in order to provide better access to ETF2Ls public data. It has some differences compared to API v1:
- API v1 serves data in JSON, XML, YAML, VDF, Perl (data structure) and PHP (serialized array) while API v2 serves data in JSON only,
- API v1 will never recieve an update whilst we do have updates upcoming for API v2,
- API v2 has more endpoints than API v1 (endpoints let an application make different types of queries).
Migrating from v1 to v2
In order to make migrating to the new API as painless as possible, most of the popular endpoints are functionally the same with some slight differences. In order to migrate to the new API, first your endpoint will need to change to the new URL. Second, the paginator used in the new API works differently from the paginator in v1. In order to change pages in v1, you provide the page as the URL parameter for a request. Example: /competition/list/:page However, in v2 the paginator takes a page as a query parameter. So in order to request page 2 you would do the following in v2: Example: /competition/list?page=2 The paginator also takes an argument for amount of records it can return at once. Please keep this within limits. By default, every page returns 20 records. If you want to override this, you can provide the limit query parameter. Example: /competition/list?page=1&limit=50 would give you 50 records instead of 20.