What’s the current stable version of Google Chrome, Firefox, and Safari? Your browser automatically checks for and keeps itself up to date. However, sometimes you need to find the latest version numbers for other uses. How do you get the latest version numbers of the most popular web browsers?
You could theoretically parse your server logs and get an approximate idea by observing the greatest of the most common version numbers. However, why bother to analyze and guesstimate data from logs when Wikidata (a sister project to Wikipedia) has the answer?
A quick plea before I proceed: Please don’t discriminate against people’s browser of choice. Don’t restrict access to your site or services based on the visitor’s User-Agent.
Mozilla is the only browser vendor that has an authoritative answer to the headliner question. You can query the current stable and extended support release of Firefox for desktop plus mobile releases through the Product-Details JSON API. Neither Apple nor Google offer a similar public API.
Fortunately, you can get the latest version information for all three from Wikidata. Wikidata is a linked data project from the Wikimedia Foundation (Wikipedia’s parent organization). The data is entered into the project by volunteers. These particular data entries don’t appear to use any automated sources or bots.
I analyzed Firefox’s release history and compared it to the Wikidata change history. I found that the wiki is usually never more than a few hours behind on releases. Past performance is not an indication of future performance (nor data reliance or stability). As the data source is a collaborative wiki, you can update it yourself if you spot a mistake or omission.
You can download data from Wikidata in any common linked metadata formats such as the Resource Description Framework (RDF). However, you don’t need to parse and extract the useful bits of data from the individual Firefox, Google Chrome, and Safari data entries on Wikidata.
Instead, you can use this SPARQL query to round up the desired data in one API call. The link opens in the interactive Wikidata Query Service editor. Press the Run button to test the query and see its current output. Press the Link button to get a link to the SPARQL API endpoint for use in your application. You can hover predicates in the editor to look up their meaning.
The SPARQL Protocol and RDF Query Language (SPARQL, a recursive acronym) may be unfamiliar to you, but the response is a structured Extensible Markup Language (XML) document. It should be much easier to parse than the SPARQL query called to generate it!
You should absolutely log errors and trigger alerts if the API output changes (e.g. any missing/renamed fields). You probably shouldn’t rely on this API for anything business-critical (at least not without configuring logging and alerts).
Instead, you might want to consider using the Browser Versions API from Long Way Research. (At least, you’ll have someone to yell at if it stops working or the data is outdated!)
Data from Wikidata is available under a permissive Creative Commons Zero license (a Public Domain deed). You don’t need to (but should) attribute the source. The API is free to use for any purpose, but make sure to cache responses and don’t be a hog. You should donate monthly to the Wikimedia Foundation if the service creates value for your product or service.