Results 1 to 11 of 11

Thread: Github latest release version

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2022
    Posts
    70

    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

  2. #2
    Fanatic Member
    Join Date
    Jun 2019
    Posts
    579

    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

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2022
    Posts
    70

    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.

  4. #4
    Fanatic Member
    Join Date
    Jun 2019
    Posts
    579

    Re: Github latest release version

    If you can't get response using browser then the API usage rate limiter is in the game.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jan 2022
    Posts
    70

    Re: Github latest release version

    I can open the page via the browser but not via my program, because I get the error back.

  6. #6
    Fanatic Member
    Join Date
    Jun 2019
    Posts
    579

    Re: Github latest release version

    VB.NET Code:
    1. ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
    2. Dim http = new WebClient()
    3. http.Headers("Accept") = "application/vnd.github.v3+json"
    4. http.Headers("User-Agent") = "My GitHub API Client"
    5. Dim json = http.DownloadString("https://api.github.com/repos/OxideMod/Oxide.Rust/releases/latest")
    6. ...
    7. ...
    8. ' jsonconvert.deserialize(...)
    9. ...
    10. ...
    Last edited by peterst; Feb 7th, 2022 at 01:03 AM.

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Jan 2022
    Posts
    70

    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")

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Jan 2022
    Posts
    70

    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.

  9. #9

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Jan 2022
    Posts
    70

    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.

  11. #11
    Fanatic Member
    Join Date
    Jun 2019
    Posts
    579

    Re: Github latest release version

    VB.NET Code:
    1. ...
    2. Dim json = http.DownloadString("https://api.github.com/repos/OxideMod/Oxide.Rust/releases/latest")
    3. ...
    4. Console.WriteLine("X-RateLimit-Limit = " & http.ResponseHeaders("X-RateLimit-Limit"))
    5. Console.WriteLine("X-RateLimit-Remaining = " & http.ResponseHeaders("X-RateLimit-Remaining"))
    6. 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
  •  



Click Here to Expand Forum to Full Width