Hello, can someone help me and tell me how I can read the latest release version number from GitHub?
https://github.com/OxideMod/Oxide.Rust
Many Thanks
Printable View
Hello, can someone help me and tell me how I can read the latest release version number from GitHub?
https://github.com/OxideMod/Oxide.Rust
Many Thanks
You can use GitHub API to get latest release for repository: https://docs.github.com/en/rest/refe...latest-release
For the project you provided, the URL is something like:
https://api.github.com/repos/OxideMo...eleases/latest
Note that there is rate limiter for free API calls and you have to use some of the authentication methods provided, probably easiest is to register your app and get access token.
Also you have to deserialize the JSON response for easier access to properties but it is mostly "Paste as JSON classes" or using JsonUtils web site.
Another approach is to use .NET library like Octokit:
https://github.com/octokit/octokit.net
i get back an error :/Code:ServicePointManager.Expect100Continue = True
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
Dim request As HttpWebRequest
Dim reader As StreamReader
request = DirectCast(WebRequest.Create("https://api.github.com/repos/OxideMod/Oxide.Rust/releases/latest"), HttpWebRequest)
Dim response As HttpWebResponse = DirectCast(request.GetResponse(), HttpWebResponse)
reader = New StreamReader(response.GetResponseStream())
Dim rawresp As String
rawresp = reader.ReadToEnd()
Label1.Text = JObject.Parse(rawresp)("tag_name")
Code:Additional Information: The remote server returned an error: (403) Forbidden.
If you can't get response using browser then the API usage rate limiter is in the game.
I can open the page via the browser but not via my program, because I get the error back.
VB.NET Code:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 Dim http = new WebClient() http.Headers("Accept") = "application/vnd.github.v3+json" http.Headers("User-Agent") = "My GitHub API Client" Dim json = http.DownloadString("https://api.github.com/repos/OxideMod/Oxide.Rust/releases/latest") ... ... ' jsonconvert.deserialize(...) ... ...
thanks man :)
Code:ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
Dim http = New WebClient()
http.Headers("Accept") = "application/vnd.github.v3+json"
http.Headers("User-Agent") = "My GitHub API Client"
Dim json = http.DownloadString("https://api.github.com/repos/OxideMod/Oxide.Rust/releases/latest")
oxide.Text = JObject.Parse(json)("tag_name")
Ok, now I get it (API rate limit exceeded)
Can someone please explain this to me with the rate limit?
I have already registered the app on Github (OAuth) I just don't quite understand how to use this with the Client ID and Client Secret.
Thanks for all help.
I don't understand the docs :/
How do I get X-RateLimit-Reset and the X-RateLimit-Remaining values from the header.
I only want a maximum of 60 queries to be made per hour. If one is above, the last value should be returned.
VB.NET Code:
... Dim json = http.DownloadString("https://api.github.com/repos/OxideMod/Oxide.Rust/releases/latest") ... Console.WriteLine("X-RateLimit-Limit = " & http.ResponseHeaders("X-RateLimit-Limit")) Console.WriteLine("X-RateLimit-Remaining = " & http.ResponseHeaders("X-RateLimit-Remaining")) Console.WriteLine("X-RateLimit-Used = " & http.ResponseHeaders("X-RateLimit-Used"))
Made 3 tries (without using API key), got 53 used :D