Navigation Menu

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

How to limit fields returned from the JSON API? #1326

Closed
bram2000 opened this issue May 14, 2021 · 1 comment
Closed

How to limit fields returned from the JSON API? #1326

bram2000 opened this issue May 14, 2021 · 1 comment
Labels

Comments

@bram2000
Copy link

Hi,

I have quite wide tables, and in many cases only want a subset of the data (to save on network bandwidth). I need to use the JSON API as handling pagination is so much easier, but I can't see a way to select specific columns.

Is there a way to do this, or is it a feature request?

Thanks!

@simonw
Copy link
Owner

simonw commented May 23, 2021

Currently you can do this with a custom SQL query, but as you've noticed this means you don't get automatic pagination: https://latest.datasette.io/fixtures.json?sql=select+pk%2C+created%2C+state+from+facetable+order+by+pk+limit+10&_shape=array

I have an open issue to allow selecting specific columns on the table page: #615

A workaround you can use today is to define a SQL view that selects just the tables you want. View pages behave exactly like tables in that they provide pagination by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants