Welcome to the Inedo Forums! Check out the Forums Guide for help getting started.

If you are experiencing any issues with the forum software, please visit the Contact Form on our website and let us know!

Understanding the API for NuGet Packages



  • We are attempting to use the ProGet API for a NuGet feed, but we are not having much luck with understanding what parameters to use. Our goal is to be able to query into ProGet and get the latest pre-release package and then create an Octopus deploy with the versions found.

    We thought we could just use the endpoint:

    https://<server>/api/json/NuGetPackages_GetPackages?API_Key=<key>&Feed_Id=1&PackageIds_Psv ="Scripts"
    

    where Scripts is the name of the package. However, this returns:

    []
    

    So we tried NuGetPackages_GetPackageCount but always get a count of 0. So we tried:

    https://<server>/api/json/NuGetPackages_GetPackage?API_Key=<key>&Feed_Id=1&Package_Id=Scripts&Version_Text=2.60.0.1492-green
    

    And got:

    {
        "NuGetPackages_Extended": [],
        "NuGetPackageSymbols": []
    }
    

    If we use the OData API:

    https://<server>/nuget/halo/Packages()?$format=json&$filter=Id eq 'Scripts'&$top=1
    

    We can find the package, but this query take 11s+ to return, and we would need to do 70+ queries, so we are trying the JSON API.

    At this point we have no idea what to pass to the server for Package_Id, Version_Text or PackageIds_Psv.

    Is there any help for what to use for the fields in the API?


    ProGet Version : Version 5.2.23 (Build 7)


  • inedo-engineer

    The /api/json/NuGetPackages_GetPackages endpoint is a Native API endpoint; it wraps a stored procedure, and the easiest way to see exactly what data to pass into it (and how it behaves) is to check the database, and see what the stored proc is doing, look at the underlying views, and try calling it.

    For what you're looking to do, the NuGet API (/nuget/halo/Packages()) is probably what you want, and it uses connectors and the other configuration you've setup.

    Why is it taking 11s? Maybe there's a bad connector you've configured. Those timeout after 10seconds by default.



  • For the Database stored procedure, is there a code repo we can look at - or just do an inspection on a running instance?

    For the NuGet API, we don't have any connectors configured on ProGet. By connector, I am assuming that when I go from the Feeds screen to the Connectors tab it displays:
    There are no connectors that match the specified criteria.

    Our instance is running 733 packages with 34000 versions. Does this play a part as well?



  • So having done some digging around database procs it appears all our packages are part of the NuGetPackageVersionsV2_Extended view not NuGetPackageVersions_Extended.

    We had assumed that the NuGetPackageVersions_Extended was the default "v3" protocol and the "V2" api was legacy.

    As far as we can tell, and assume, ProGet doesn't yet support the v3 NuGet protocol. Can you confirm?


  • inedo-engineer

    Hi Richard,

    ProGet does not currently implement v3. The V2 designation for the tables was simply the 2nd implementation of NuGet feeds that replaced the quirks feeds.

    If you want to get the latest version using the NuGet v2 API, use this URL format:

    https://<proget-server>/nuget/<feed-name>/FindPackagesById()?id=<package-name>&$filter=IsAbsoluteLatestVersion&$format=json
    

    The $format=json is specific to ProGet and may be omitted if you prefer NuGet v2's traditional XML response.

    Hope this helps,
    -John


  • inedo-engineer

    For completeness, I will also add that (without any connectors), the package returned by this Native API call will be the same:

    https://<proget-server>/api/json/NuGetPackagesV2_GetLatest?key=<api-key>&Feed_Id=<feed-id>&PackageIds_Psv=<packages>
    

    Psv stands for "pipe-separated values", and if that argument is omitted, the absolute latest versions of all packages are returned. An example value for <packages> would be Inedo.BuildMaster.SDK or Inedo.BuildMaster.SDK|Inedo.ProGet.SDK

    That being said, the NuGet API endpoint is still the recommended one to use if possible :)



  • Thanks John.

    We have tried the FindPackagesById endpoint and this is completing in 75ms which is much more expected. We are going to continue with this API to see if we can get what we need from it.


Log in to reply
 

Inedo Website HomeSupport HomeCode of ConductForums GuideDocumentation