4

I have a question after reading this: Is there any web API for Software Center available?

I am trying to understand the Ubuntu Software Center's JSON endpoints.

This JSON lists all the apps available from the Software Center: http://software-center.ubuntu.com/api/2.0/applications/any/ubuntu/any/any/

Cool... Now I need to get all review for one app!

So I choose an app and get its packages_name from the JSON file:

{
        "status": "Published", 
        "package_name": "splashtop-streamer", 
        "video_embedded_html_urls": [
            "http://myapps.developer.ubuntu.com/dev/apps/1804/video/264a5fb11b60410a3a7d03bebdd1fcccd0cf5a72/"
        ],....

Here the package_name is splashtop-streamer.

To gets all reviews for the vlc app I just do this: https://reviews.ubuntu.com/reviews/api/1.0/reviews/filter/any/ubuntu/any/any/vlc

But for splashtop-streamer app I can't: https://reviews.ubuntu.com/reviews/api/1.0/reviews/filter/any/ubuntu/any/any/splashtop-streamer

It only returns this:

[]

If you look at splashtop-streamer Install splashtop-streamer online, you'll see that it does indeed have reviews. So why is the API returning an empty list?

Voidcode
  • 793

1 Answers1

2

It's not obvious, but the API filter there is using origin to specify whether the app is from the ubuntu archives or a PPA. So for a commercial app, filtering by 'ubuntu' gives zero results. What you want is:

http://reviews.ubuntu.com/reviews/api/1.0/reviews/filter/any/any/any/any/splashtop-streamer/
http://reviews.ubuntu.com/reviews/api/1.0/reviews/filter/any/any/any/any/splashtop-streamer/page/2/

etc.

Note, there's also a tiny wrapper that can keep your code cleaner if you want it:

$ bzr branch lp:~rnr-developers/rnr-server/rnrclient
$ cd rnrclient && virtualenv venv && venv/bin/python setup.py install && venv/bin/python
>>> from rnrclient import RatingsAndReviewsAPI
>>> api = RatingsAndReviewsAPI("http://reviews.ubuntu.com/reviews/api/1.0")
>>> api.server_status()
u'ok'
>>> streamer_reviews = api.get_reviews(packagename='splashtop-streamer')
>>> len(streamer_reviews)
10
>>> streamer_reviews = api.get_reviews(packagename='splashtop-streamer', page=2)
...