<p>I pulled this from the <a href="https://github.com/chef-cookbooks/firefox" rel="nofollow noreferrer">Firefox Chef cookbook</a> (in particular <a href="https://github.com/chef-cookbooks/firefox/blob/master/libraries/default.rb" rel="nofollow noreferrer">this</a> .rb file). This an example of the request they use to get the latest version based on OS and language. </p>

<pre><code>https://download.mozilla.org/?product=firefox-latest#&amp;os=win#&amp;lang=#en-US
</code></pre>

<p>It adheres to the following format:</p>

<pre><code>https://download.mozilla.org/?product=firefox-{VERSION_NUMBER}#&amp;os={OS_ABBREVIATION}#&amp;lang=#{LANGUAGE_ABBREVIATION}
</code></pre>

<p>I searched around for official api documentation, but couldn't find anything. If I do, I will post a link to it in this answer. </p>

CC BY-SA 3.0
2018-02-20T23:16:39.747Z
2018-02-21T00:44:54.367Z
2018-02-21T00:44:54.367Z
Preston Martin
<p>You do not want to be parsing HTML in a programmatic way. Avoid it at all costs, if you can. It would be a nightmare to support on-going. There's actually a JSON output that Mozilla provides of all the versions:</p>

<p><a href="https://product-details.mozilla.org/1.0/firefox_versions.json" rel="nofollow noreferrer">https://product-details.mozilla.org/1.0/firefox_versions.json</a></p>

<p><strong>Edit:</strong> Here is a simple bash script example that will always return the latest Firefox version. Make sure you have <code>jq</code> &amp; <code>curl</code> installed on your system:</p>

<pre><code>curl -s https://product-details.mozilla.org/1.0/firefox_versions.json | jq -r .LATEST_FIREFOX_VERSION
</code></pre>

<p>This returns:</p>

<p><code>58.0.2</code></p>

CC BY-SA 3.0
2018-02-21T16:16:18.600Z
Huh? I don't understand what you are saying. That is a JSON file that you can programmatically parse `LATEST_FIREFOX_VERSION` to get the latest version. That file is used to _find_ the latest version. You don't need to know the version before you read that file. Just pull out the value for `LATEST_FIREFOX_VERSION` in your script that you write. I've updated my answer to show a code example of this.
BoomShadow
CC BY-SA 3.0
2018-02-21T17:03:08.750Z
Ah, you're right. Brain fart. Sorry.
Dan Cornilescu
CC BY-SA 3.0
2018-02-25T10:03:19.073Z
@BoomShadow I totally agree. Perhaps you could answer [this question](https://devops.stackexchange.com/q/3262/210) as well?
030
CC BY-SA 3.0
2018-02-25T17:32:15.620Z
@BoomShadow and perhaps you could answer [this question](https://devops.stackexchange.com/q/3443/210) too.
030
CC BY-SA 3.0
2018-02-20T16:40:48.497Z
2018-02-21T16:20:25.157Z
2018-02-21T16:20:25.157Z
BoomShadow
<p>How to get the latest version of firefox? <a href="https://www.mozilla.org/en-US/firefox/releases/" rel="nofollow noreferrer">This URL</a> was found, but is there no API? I would like to get the latest version, e.g. <code>58.0.2</code> so this could be used for other purposes. Just <code>latest</code> is insufficient as I require the version in one of my ansible roles to lookup the checksum.</p>

<hr>

<p>At the moment I am considering to parse <a href="https://www.mozilla.org/en-US/firefox/releases/" rel="nofollow noreferrer">https://www.mozilla.org/en-US/firefox/releases/</a></p>

<automation><api>
How to get the latest stable version of Firefox?
030
# How to get the latest stable version of Firefox?

(Asked by: username_0 on 2018-02-20)

How to get the latest version of firefox? [This URL](https://www.mozilla.org/en-US/firefox/releases/) was found, but is there no API? I would like to get the latest version, e.g. `58.0.2` so this could be used for other purposes. Just `latest` is insufficient as I require the version in one of my ansible roles to lookup the checksum.

---

At the moment I am considering to parse <https://www.mozilla.org/en-US/firefox/releases/>

**Tags:** automation, api


---

## 2 answers

### Answer by username_2 on 2018-02-20. Score: 3 | Accepted answer

You do not want to be parsing HTML in a programmatic way. Avoid it at all costs, if you can. It would be a nightmare to support on-going. There's actually a JSON output that Mozilla provides of all the versions:
https://product-details.mozilla.org/1.0/firefox_versions.json
Edit: Here is a simple bash script example that will always return the latest Firefox version. Make sure you have jq & curl installed on your system:
curl -s https://product-details.mozilla.org/1.0/firefox_versions.json | jq -r .LATEST_FIREFOX_VERSION

This returns:
58.0.2

> **Comments:**
> **username_2**: Huh? I don't understand what you are saying. That is a JSON file that you can programmatically parse `LATEST_FIREFOX_VERSION` to get the latest version. That file is used to _find_ the latest version. You don't need to know the version before you read that file. Just pull out the value for `LATEST_FIREFOX_VERSION` in your script that you write. I've updated my answer to show a code example of this.  
> **username_3**: Ah, you're right. Brain fart. Sorry.  
> **username_0**: @username_2 I totally agree. Perhaps you could answer [this question](https://devops.stackexchange.com/q/3262/210) as well?  
> **username_0**: @username_2 and perhaps you could answer [this question](https://devops.stackexchange.com/q/3443/210) too.  

---

### Answer by username_1 on 2018-02-20. Score: 3

I pulled this from the Firefox Chef cookbook (in particular this .rb file). This an example of the request they use to get the latest version based on OS and language. 
https://download.mozilla.org/?product=firefox-latest#&os=win#⟨=#en-US

It adheres to the following format:
https://download.mozilla.org/?product=firefox-{VERSION_NUMBER}#&os={OS_ABBREVIATION}#⟨=#{LANGUAGE_ABBREVIATION}

I searched around for official api documentation, but couldn't find anything. If I do, I will post a link to it in this answer.


---

