Fetching a list of supported Nextcloud server versions

Is there an official URL, that will remain “static” (or reasonably so) where I can fetch a list of supported Nextcloud versions, their release date, and the current minor version in JSON/XML?

I thought I had seen that somewhere, but can’t recall where and my search engine doesn’t seem to have an answer … :thinking:

I see that there’s a similar question here:

What exactly do you need?

does this meet your requirements?:

curl -s https://nextcloud.com/changelog/ | awk '/Version / {print $2}'

Output:

27.0.0
26.0.3
26.0.2
26.0.1
26.0.0
25.0.8
25.0.7
25.0.6
25.0.5
25.0.4
25.0.3
25.0.2
25.0.1
25.0.0

If you need more fields (date or so) than it is not much effort to make it and create the json array. Just explain what you need.:

curl -s https://nextcloud.com/changelog/ | awk -F'[< ]' '/version_date/ {
  day = $9;
  year = $10;
  month = $8;
  date = sprintf("%s.%02d.%02d", year, (index("JanFebMarAprMayJunJulAugSepOctNovDec", substr(month, 1, 3))+2)/3, day);
  getline; getline; getline; getline;
  sub(/^[ \t]+/, "", $2);
  gsub(/[\x00-\x1F]/, "", $2);
  version = $2;
  printf "{ \"date\": \"%s\", \"version\": \"%s\" }\n", date, version
}' | jq -s .

Output:

[
  {
    "date": "2023.06.13",
    "version": "27.0.0"
  },
  {
    "date": "2023.06.22",
    "version": "26.0.3"
  },
  {
    "date": "2023.05.26",
    "version": "26.0.2"
  },
  {
    "date": "2023.04.20",
    "version": "26.0.1"
  },
  {
    "date": "2023.03.21",
    "version": "26.0.0"
  },
  {
    "date": "2023.06.22",
    "version": "25.0.8"
  },
  {
    "date": "2023.05.26",
    "version": "25.0.7"
  },
  {
    "date": "2023.04.20",
    "version": "25.0.6"
  },
  {
    "date": "2023.03.24",
    "version": "25.0.5"
  },
  {
    "date": "2023.02.23",
    "version": "25.0.4"
  },
  {
    "date": "2023.01.28",
    "version": "25.0.3"
  },
  {
    "date": "2022.12.08",
    "version": "25.0.2"
  },
  {
    "date": "2022.11.03",
    "version": "25.0.1"
  },
  {
    "date": "2022.10.19",
    "version": "25.0.0"
  }
]

Same with beta versions, can be generated without much effort.

1 Like

like this (needs xmlstarlet):

curl -s https://github.com/nextcloud/server/releases.atom | xmlstarlet sel -N atom="http://www.w3.org/2005/Atom" -t -v "//atom:entry/atom:title" | sed 's/^v//1; s/rc/ RC/1' && echo

Output:

27.0.1 RC2
26.0.4 RC2
25.0.9 RC2
27.0.1 RC1
26.0.4 RC1
25.0.9 RC1
26.0.3
25.0.8
26.0.3 RC2
25.0.8 RC2

Or if you need the date as well:

curl -s https://github.com/nextcloud/server/releases.atom | xmlstarlet sel -N atom="http://www.w3.org/2005/Atom" -t -m "//atom:entry" -v "atom:title" -o $'\t- ' -v "atom:updated" -n | sed 's/^v//1; s/rc/ RC/1' | column -t -s $'\t'

does output this:

27.0.1 RC2  - 2023-07-17T18:30:10Z
26.0.4 RC2  - 2023-07-17T18:30:01Z
25.0.9 RC2  - 2023-07-17T18:29:39Z
27.0.1 RC1  - 2023-07-13T14:53:32Z
26.0.4 RC1  - 2023-07-13T14:53:47Z
25.0.9 RC1  - 2023-07-13T14:53:41Z
26.0.3      - 2023-06-22T10:53:44Z
25.0.8      - 2023-06-22T10:53:28Z
26.0.3 RC2  - 2023-06-19T19:47:03Z
25.0.8 RC2  - 2023-06-19T19:46:47Z
1 Like

Thank you. What I’m after is basically an official URL that’ll give me JSON/XML with the officially supported releases, and be able to fetch it with a PHP and/or Python script.

But I guess I could go from your suggestion to that.

(I do think there should be something like https://nextcloud.com/releases.json or versions.json … but that’s just my two cents :blush:)

1 Like

OK.

  • php code to generate the date/version json:
<?php
$url = 'https://nextcloud.com/changelog/';
$html = file_get_contents($url);

$dom = new DOMDocument();
@$dom->loadHTML($html);

$xpath = new DOMXPath($dom);
$entries = $xpath->query('//p[@class="version_date"]');
$data = [];

foreach ($entries as $entry) {
    $version_date = $entry->nodeValue;
    preg_match('/(\w+ \d+, \d+)/', $version_date, $matches);
    $date = date('Y.m.d', strtotime($matches[1]));

    $version_element = $entry->nextSibling;
    while ($version_element->nodeName !== 'h3') {
        $version_element = $version_element->nextSibling;
    }

    if (preg_match('/Version (\d+\.\d+\.\d+)/', $version_element->nodeValue, $matches)) {
        $version = $matches[1];
    } else {
        $version = '';
    }

    $data[] = ['date' => $date, 'version' => $version];
}

$json = json_encode($data, JSON_PRETTY_PRINT);
echo $json;
?>
  • Python3 code:
import requests
from bs4 import BeautifulSoup
import json

url = 'https://nextcloud.com/changelog/'
response = requests.get(url)
html = response.text

soup = BeautifulSoup(html, 'html.parser')
entries = soup.find_all('p', class_='version_date')
data = []

for entry in entries:
    version_date = entry.get_text()
    date = version_date.split()[2] + '.' + str("%02d" % (['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'].index(version_date.split()[0]) + 1)) + '.' + version_date.split()[1].rstrip(',')

    version_element = entry.find_next('h3', class_='version_name')
    version = version_element.get_text().strip().split()[-1]

    data.append({'date': date, 'version': version})

json_data = json.dumps(data, indent=2)
print(json_data)

Make sure to have the requests and beautifulsoup4 packages installed in your Python environment before running this code.

Thank you :blush:

The code wasn’t the real issue though. I believe in purposeful resources, so that’s why I was asking for a plain vanilla json/xml-feed that is official and constant.

I’ll consider this question solved, since there is no such official json/xml-feed with version data :slightly_smiling_face:

1 Like

Looking at Nextcloud’s internal updater code and version checking, there seems to be an alternative interface. It doesn’t list all available versions, but it does perform an update check. That URL, in my opinion, should also be documented publicly.

It’d also be nice if the functionality of this URL could be expanded to return a list of supported versions.

The URL looks like this:

“https://updates.nextcloud.com/updater_server/?version=26x0x5x1x1524153426.6118x1692278880xstablexx2023-08-10T06:28:27+00:00 96eca4513f999053d3500bb6468d64d550ffdb05x8x1x22x0x0”

(that’s all part of the URL, sans quotes; there’s a space in there, I’m guessing this is why the forum displays it like it does)

1 Like

Thank you! Interesting!

I broke that down to this:

https://updates.nextcloud.com/updater_server/?version=${major}x${minor}x${patch}x${build}x${oc_appconfig core installedat}x${oc_appconfig core lastupdatedat}x${updatechannel}x${edition(empty)}x${$OC_Build from version.php}x${php_major}x${php_minor}x${php_release}x${category}x${isSubscriber}

It can be minimized until this, and it returns the next available version to update to:

curl https://updates.nextcloud.com/updater_server/?version=27x0x2x0xxxstablexxx8x2x0xx
<?xml version="1.0" encoding="UTF-8"?>
<nextcloud>
 <version>27.0.2.1</version>
 <versionstring>Nextcloud 27.0.2</versionstring>
 <url>https://download.nextcloud.com/server/releases/nextcloud-27.0.2.zip</url>
 <web>https://docs.nextcloud.com/server/27/admin_manual/maintenance/upgrade.html</web>
 <changes>https://updates.nextcloud.com/changelog_server/?version=27.0.2</changes>
 <autoupdater>1</autoupdater>
 <eol>0</eol>
 <signature>pd8gQOxzJqcjCR10kWmt+vKhOXWJimF8FhdGcuzkZc/7Ujg8zY+xL3UQ9BG0x9nN
YXC7CtgMDeVr55/UoB2qHpWijze7HD7qsBD9tx4MDTvcTyH4lF5LGsFWydCUrEvH
TAF3mBAqRasfq7Exz7QbMtiqsw3U4+sku2QEQyYZOH6dupbT/k3i5I+syRQiTK9O
1mhmO0WnSMSlW+uMPUsABipYyfiY4bxRJja/kv4GVA66DLSdxrq7WUvvxK2HNKOf
V22tSiRwjvYLZDM6drqpW6DY6hKMoeKFGc14KrFgwN1WFJShmdFCG+Tld3iEcVwE
wf5nncfHuTeT/AapME4dLQ==</signature>
</nextcloud>

ernolf

The full request URL is created in VersionCheck.php, located in <root>/lib/private/Updater.

The function check() does the heavy lifting, and also includes a caching mechanism.

1 Like

Tank you!

I’ve updated my response above accordingly.

Conclusion:

You effectively only need an “actual” version, the channel (stable or beta) and the actual php version for there to be a response.
For example, if php is set to 7.4.0, you will not be offered an update that requires at least 8.0

All other fields can remain empty.

ernolf

Well, I think we’ve just about covered getting update information from all angles now.

Job well done :blush: :+1:

1 Like