Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pagination #53

Closed
dsoprea opened this issue Jul 30, 2015 · 3 comments
Closed

Pagination #53

dsoprea opened this issue Jul 30, 2015 · 3 comments

Comments

@dsoprea
Copy link

dsoprea commented Jul 30, 2015

I'm trying to figure out how to page through results.

Create the object:

dg = ckanapi.RemoteCKAN('http://catalog.data.gov', apikey=_API_KEY)

Execute query:

r = dg.action.package_search(q='fish')

This gives me the first ten results. However, there doesn't appear to be a way to get the next ten results. I get the exact same results whether I call the last command, or:

dg.action.package_search(q='fish', offset=20)

or

dg.action.package_search(q='fish', XYZ=20)

They all return successful.

@deniszgonjanin
Copy link

Hum. I think you're found a bug in data.gov. The following is the code the will do what you want it to do in any other CKAN catalogue I've tested (so like, 2 other CKAN catalogues...):

myckan.action.package_search(q='fish', rows='20', start=120)

But on data.gov it always returns just the first 10 rows. Consider reporting to https://github.com/GSA/data.gov/

@dsoprea
Copy link
Author

dsoprea commented Jul 31, 2015

It's weird that the cURL requests work perfectly, though the parameter looks like it's "start" rather than "offset":

Start at offset 1:

$ curl -s "http://catalog.data.gov/api/3/action/package_search?q=fish&rows=1&start=1" -L | python -m json.tool 
                        "state": "active",
                        "vocabulary_id": null
                    }
                ],
                "title": "Statistics of U.S. Businesses (SUSB)",
                "tracking_summary": {
                    "recent": 177,
                    "total": 918
                },
                "type": "dataset",
                "url": null,
                "version": null
            }
        ],
        "search_facets": {}
    },
    "success": true
}

Start at offset (10):

$ curl -s "http://catalog.data.gov/api/3/action/package_search?q=fish&rows=1&start=10" -L | python -m json.tool 
                        "state": "active",
                        "vocabulary_id": null
                    }
                ],
                "title": "Annual Survey of State and Local Government Finances",
                "tracking_summary": {
                    "recent": 29,
                    "total": 158
                },
                "type": "dataset",
                "url": null,
                "version": null
            }
        ],
        "search_facets": {}
    },
    "success": true
}

@wardi
Copy link
Contributor

wardi commented Aug 31, 2015

start=X should work exactly the same with ckanapi. closing as it looks like you were just using the wrong parameter. There is no code in ckanapi related to the parameters pased to specific actions.

@wardi wardi closed this as completed Aug 31, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants