4 ms·
I'm going to take this opportunity to promote my current principal project, Datasette. https://datasette.readthedocs.io/en/stable/ https://datasette.readthedoc
by simonw 7y ago
I'm going to take this opportunity to promote my current principal project, Datasette.
https://datasette.readthedocs.io/en/stable/ https://datasette.readthedocs.io/en/stable/
Datasette aims to reduce the gap between "I have some data" and "I have a useful JSON API for it" as much as possible. I think it does this really well.
A timely example: the first version of this API for interacting with data about the COVID-19 pandemic took me just a few minutes to build AND deploy: https://covid-19.datasettes.com/ https://covid-19.datasettes.com/ - it uses data pulled hourly from https://github.com/CSSEGISandData/COVID-19 https://github.com/CSSEGISandData/COVID-19 and https://github.com/nytimes/covid-19-data https://github.com/nytimes/covid-19-data
Here's JSON for the number of reported cases and deaths in California (served with a CORS header so you can call it from other pages): https://covid-19.datasettes.com/covid/ny_times_us_states.json?state=California&_shape=array https://covid-19.datasettes.com/covid/ny_times_us_states.jso...
And here's data showing the number of NEW cases per day reported in Italy, using a SQL window function. First as a graph visualization: https://covid-19.datasettes.com/covid?sql=with+italy+as+%28%0D%0A++select%0D%0A++++rowid%2C%0D%0A++++day%2C%0D%0A++++country_or_region%2C%0D%0A++++province_or_state%2C%0D%0A++++admin2%2C%0D%0A++++fips%2C%0D%0A++++confirmed%2C%0D%0A++++deaths%2C%0D%0A++++recovered%2C%0D%0A++++active%2C%0D%0A++++latitude%2C%0D%0A++++longitude%2C%0D%0A++++last_update%2C%0D%0A++++combined_key%0D%0A++from%0D%0A++++johns_hopkins_csse_daily_reports%0D%0A++where%0D%0A++++%22country_or_region%22+%3D+%3Ap0%0D%0A++order+by%0D%0A++++confirmed+desc%0D%0A%29%0D%0Aselect%0D%0A++day%2C%0D%0A++confirmed+-+lag%28confirmed%2C+1%29+OVER+%28%0D%0A++++ORDER+BY%0D%0A++++++day%0D%0A++%29+as+new_cases%0D%0Afrom%0D%0A++italy%0D%0Aorder+by+day+desc+limit+50&p0=Italy#g.mark=bar&g.x_column=day&g.x_type=ordinal&g.y_column=new_cases&g.y_type=quantitative https://covid-19.datasettes.com/covid?sql=with+italy+as+%28%...
And here's that raw data as JSON:
https://covid-19.datasettes.com/covid.json?sql=with+italy+as+%28%0D%0A++select%0D%0A++++rowid%2C%0D%0A++++day%2C%0D%0A++++country_or_region%2C%0D%0A++++province_or_state%2C%0D%0A++++admin2%2C%0D%0A++++fips%2C%0D%0A++++confirmed%2C%0D%0A++++deaths%2C%0D%0A++++recovered%2C%0D%0A++++active%2C%0D%0A++++latitude%2C%0D%0A++++longitude%2C%0D%0A++++last_update%2C%0D%0A++++combined_key%0D%0A++from%0D%0A++++johns_hopkins_csse_daily_reports%0D%0A++where%0D%0A++++%22country_or_region%22+%3D+%3Ap0%0D%0A++order+by%0D%0A++++confirmed+desc%0D%0A%29%0D%0Aselect%0D%0A++day%2C%0D%0A++confirmed+-+lag%28confirmed%2C+1%29+OVER+%28%0D%0A++++ORDER+BY%0D%0A++++++day%0D%0A++%29+as+new_cases%0D%0Afrom%0D%0A++italy%0D%0Aorder+by+day+desc+limit+50&p0=Italy&_shape=array https://covid-19.datasettes.com/covid.json?sql=with+italy+as...
And as CSV: https://covid-19.datasettes.com/covid.csv?sql=with+italy+as+(%0D%0A++select%0D%0A++++rowid%2C%0D%0A++++day%2C%0D%0A++++country_or_region%2C%0D%0A++++province_or_state%2C%0D%0A++++admin2%2C%0D%0A++++fips%2C%0D%0A++++confirmed%2C%0D%0A++++deaths%2C%0D%0A++++recovered%2C%0D%0A++++active%2C%0D%0A++++latitude%2C%0D%0A++++longitude%2C%0D%0A++++last_update%2C%0D%0A++++combined_key%0D%0A++from%0D%0A++++johns_hopkins_csse_daily_reports%0D%0A++where%0D%0A++++%22country_or_region%22+%3D+%3Ap0%0D%0A++order+by%0D%0A++++confirmed+desc%0D%0A)%0D%0Aselect%0D%0A++day%2C%0D%0A++confirmed+-+lag(confirmed%2C+1)+OVER+(%0D%0A++++ORDER+BY%0D%0A++++++day%0D%0A++)+as+new_cases%0D%0Afrom%0D%0A++italy%0D%0Aorder+by+day+desc+limit+50&p0=Italy&_shape=array https://covid-19.datasettes.com/covid.csv?sql=with+italy+as+...
- simonw 7y agoIf you want to try it out the fastest way is on Glitch: https://glitch.com/~datasette-csvs https://glitch.com/~datasette-csvs Click "remix" on that page, drag-and-drop in a CSV file and you get an instant API for it. You can try it out without even signing up for a Glitch account!
- jonnydubowsky 7y agoI didn't even see this comment when I wrote my earlier message. Glitch integration makes it even easier for us to work with in a hackathon environment. Awesome that you are thinking about accessibility in your promotion of Datasette. You've definitely got some over-caffeinated hackathon people coming your way in the coming days as we begin the 8 week Covidathon with the Decentralized AI Alliance. I'll let you know what we come up with.
- simonw 7y agoPlease do - I'm https://twitter.com/simonw https://twitter.com/simonw on Twitter or you can reach me using swillison at Google's email service.
- jonnydubowsky 7y agoThat is a powerful and concise outline of Datasette. I am working on an 8 week hackathon to build privacy first data solutions for the pandemic response. I am totally going to bring these examples to my session tonight for inspiration. Very cool stuff! Thanks for sharing. https://covidathon.devpost.com/ https://covidathon.devpost.com/ (Also love the Commodore reference)
- simonw 7y agoAwesome! I'm definitely excited about hackathons as an opportunity to take advantage of Datasette.
- ionwake 7y agoLooks good - is there any way to get world stats?