Cloud API List Libraries Questions

I’m trying to use the Cloud API to stay on top of new community libraries as they become available and have found some confusing behavior. For example, I’d like to run a query that returns the 5 most recently created libraries so I run the following:

curl https://api.particle.io/v1/libraries?scope=all&sort=-created&limit=5&access_token=[MY TOKEN]

That returns libraries like HttpClient which obviously isn’t a newly created library. But the other interesting part is that that command returns exactly the same result set as the following 3 commands:

sort=created
curl https://api.particle.io/v1/libraries?scope=all&sort=created&limit=5&access_token=[MY TOKEN]

sort=-published
curl https://api.particle.io/v1/libraries?scope=all&sort=-published&limit=5&access_token=[MY TOKEN]

sort=published
curl https://api.particle.io/v1/libraries?scope=all&sort=published&limit=5&access_token=[MY TOKEN]

My best guess is that the limit argument is limiting the set prior to sorting but that doesn’t explain why changing the sort parameter from ascending to descending doesn’t result in a change of the output. After playing with it for about an hour I came up with a list of questions that I didn’t find answers to in the documentation and was hoping somebody from the team could answer.

  1. Is there a query that would return the most recently created public libraries?
  2. What is the order of operations of the query string params. Does limit happen before sort or sort before limit or does it depend on their order in the query string?
  3. There is a page param but how does one know how many possible pages there are if the limit param defaults to 10 and has a max value of 100?
  4. Why doesn’t changing the sort param between ascending/descending seem to effect the output?
  5. Does the sort param for published mean when it was most recently published or originally published? I assume most recently published as originally published should just be the created option.
  6. Continuing from question 5, what is the difference between sorting by published and updated?
  7. Is the ascending/descending sort functionality working and, if so, what am I doing wrong in the queries above?

I appreciate any further clarification you can provide on this. I’ve included the output I get for all of the above curl commands in case it provides any clues. All of the curl commands return this exact same output.

{
  "data":[
    {
      "type":"libraries",
      "id":"coap",
      "links":{
        "download":"https://library-archives.particle.io/libraries/coap/coap-0.2.2.tar.gz"
      },
      "attributes":{
        "name":"coap",
        "version":"0.2.2",
        "installs":20,
        "license":"MIT",
        "author":"hirotakaster",
        "url":"https://github.com/hirotakaster/coap",
        "repository":"https://github.com/hirotakaster/coap.git",
        "architectures":[

        ],
        "visibility":"public",
        "mine":false
      }
    },
    {
      "type":"libraries",
      "id":"Adafruit_AM2315",
      "links":{
        "download":"https://library-archives.particle.io/libraries/Adafruit_AM2315/Adafruit_AM2315-1.0.1.tar.gz"
      },
      "attributes":{
        "name":"Adafruit_AM2315",
        "version":"1.0.1",
        "installs":17,
        "license":"BSD",
        "author":"Limor Fried/Ladyada",
        "sentence":"This is a library for the AM2315 Humidity + Temp sensor",
        "url":"https://github.com/tripzero/adafruit_am2315",
        "repository":"https://github.com/tripzero/adafruit_am2315.git",
        "architectures":[

        ],
        "visibility":"public",
        "mine":false
      }
    },
    {
      "type":"libraries",
      "id":"FirebaseArduino",
      "links":{
        "download":"https://library-archives.particle.io/libraries/FirebaseArduino/FirebaseArduino-0.0.1.tar.gz"
      },
      "attributes":{
        "name":"FirebaseArduino",
        "version":"0.0.1",
        "author":"Firebase",
        "maintainer":"Firebase",
        "sentence":"Library for communicating with Firebase.",
        "paragraph":"This library simplifies the process of communicating with Firebase. It hides the complexity of authentication and json parsing.",
        "category":"Communication",
        "url":"https://github.com/googlesamples/firebase-arduino",
        "architectures":[
          "esp8266"
        ],
        "visibility":"public",
        "mine":false
      }
    },
    {
      "type":"libraries",
      "id":"FRAM",
      "links":{
        "download":"https://library-archives.particle.io/libraries/FRAM/FRAM-1.0.1.tar.gz"
      },
      "attributes":{
        "name":"FRAM",
        "version":"1.0.1",
        "installs":13,
        "license":"GPLv3",
        "author":"Paul Kourany, Kenneth Lim",
        "sentence":"FRAM library for Particle.",
        "url":"https://github.com/enablersg/fram-lib",
        "repository":"https://github.com/enablersg/fram-lib.git",
        "architectures":[

        ],
        "visibility":"public",
        "mine":false
      }
    },
    {
      "type":"libraries",
      "id":"HttpClient",
      "links":{
        "download":"https://library-archives.particle.io/libraries/HttpClient/HttpClient-0.0.5.tar.gz"
      },
      "attributes":{
        "name":"HttpClient",
        "version":"0.0.5",
        "installs":5280,
        "license":"MIT",
        "author":"Nils Mattisson <nils.mattisson@gmail.com>",
        "sentence":"A work in progress Http Client Library for the Spark Core and Arduino.",
        "url":"https://github.com/nmattisson/httpclient",
        "repository":"https://github.com/nmattisson/httpclient.git",
        "architectures":[

        ],
        "visibility":"public",
        "mine":false
      }
    }
  ]
}
1 Like

@jvanier Who would be a good person to reach out to on this topic? Is there some place to file a bug instead of just putting it in the forum here? Thanks for any help you can provide.

You can create issues in the cloud repository for API issues:

The “cloud” repository is appropriate for all things that don’t have a public github repository, including the API, webhooks, Particle Build (Web IDE) and other things.

1 Like

Thanks @rickkas7. I’ve submitted an issue on the repo to track this. https://github.com/spark/cloud/issues/25

1 Like