This alpha release previews the updated design for Datasette's default JSON API. (#782)
The new default JSON representation for both table pages (/dbname/table.json
) and arbitrary SQL queries (/dbname.json?sql=...
) is now shaped like this:
{
"ok": true,
"rows": [
{
"id": 3,
"name": "Detroit"
},
{
"id": 2,
"name": "Los Angeles"
},
{
"id": 4,
"name": "Memnonia"
},
{
"id": 1,
"name": "San Francisco"
}
],
"truncated": false
}
Tables will include an additional "next"
key for pagination, which can be passed to ?_next=
to fetch the next page of results.
The various ?_shape=
options continue to work as before - see Different shapes for details.
A new ?_extra=
mechanism is available for tables, but has not yet been stabilized or documented. Details on that are available in #262.
Smaller changes
- Datasette documentation now shows YAML examples for Metadata by default, with a tab interface for switching to JSON. (#1153)
- register_output_renderer(datasette) plugins now have access to
error
andtruncated
arguments, allowing them to display error messages and take into account truncated results. (#2130) render_cell()
plugin hook now also supports an optionalrequest
argument. (#2007)- New
Justfile
to support development workflows for Datasette using Just. datasette.render_template()
can now accepts adatasette.views.Context
subclass as an alternative to a dictionary. (#2127)datasette install -e path
option for editable installations, useful while developing plugins. (#2106)- When started with the
--cors
option Datasette now serves anAccess-Control-Max-Age: 3600
header, ensuring CORS OPTIONS requests are repeated no more than once an hour. (#2079) - Fixed a bug where the
_internal
database could displayNone
instead ofnull
for in-memory databases. (#1970)