|
-
Feb 6th, 2022, 03:56 PM
#1
Thread Starter
Lively Member
Github latest release version
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
-
Feb 6th, 2022, 04:16 PM
#2
Re: Github latest release version
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
-
Feb 6th, 2022, 04:44 PM
#3
Thread Starter
Lively Member
Re: Github latest release version
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")
i get back an error :/
Code:
Additional Information: The remote server returned an error: (403) Forbidden.
-
Feb 6th, 2022, 04:53 PM
#4
Re: Github latest release version
If you can't get response using browser then the API usage rate limiter is in the game.
-
Feb 6th, 2022, 05:14 PM
#5
Thread Starter
Lively Member
Re: Github latest release version
I can open the page via the browser but not via my program, because I get the error back.
-
Feb 7th, 2022, 12:59 AM
#6
Re: Github latest release version
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(...)
...
...
Last edited by peterst; Feb 7th, 2022 at 01:03 AM.
-
Feb 7th, 2022, 08:34 AM
#7
Thread Starter
Lively Member
Re: Github latest release version
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")
-
Feb 10th, 2022, 05:08 PM
#8
Thread Starter
Lively Member
Re: Github latest release version
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.
-
Feb 10th, 2022, 05:38 PM
#9
Re: Github latest release version
-
Mar 9th, 2022, 12:40 PM
#10
Thread Starter
Lively Member
Re: Github latest release version
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.
-
Mar 9th, 2022, 01:40 PM
#11
Re: Github latest release version
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|