soda-ruby icon indicating copy to clipboard operation
soda-ruby copied to clipboard

Mechanism to create datasets over the API

Open warmfusion opened this issue 11 years ago • 13 comments

I've found it difficult to create new datasets with the column and datatypes I need - Whilst its possible through the user interface, I'd prefer an API interaction so that new datasets can be quickly made when new data sources are found to load into the system.

Would it be possible to create a dataset using something like

d = client.dataset.new({ name=>'warmfusions-data', columns = [ 'id' => 'numeric', 'name' => 'text' ], 'key'=> 'id' } )
client.dataset.delete(d.key)

Perhaps even a little #9 trick:

client.dataset.metadata.put( { update => Date.now, summary => 'Some little text'  } )

warmfusion avatar Aug 26 '14 21:08 warmfusion

Monitoring the network traffic through the web interface, I found https://opendata.socrata.com/api/imports2.json to be the correct url to create a new dataset. This, of course, requires authentication. I can't seem to find this info on the dev site, but a quick search of its github repo reveals that this is, in fact, documented.

xmunoz avatar Feb 09 '15 01:02 xmunoz

My my @xmunoz, you sure are crafty. :)

More correctly, they were documented in old content on our old dev site. That's a deprecated SODA 1.0 API that we'll be removing over the coming months. I can't stop you from using them, but when 2.0 replacements are rolled out in the coming months they'll eventually be be removed. :+1:

chrismetcalf avatar Feb 09 '15 23:02 chrismetcalf

@chrismetcalf - So will this 2.0 replacement include this feature?

warmfusion avatar Feb 10 '15 11:02 warmfusion

Yep. I wish I had design docs and a timeline to share with you but we're not quite to that point yet. If you'd like, I'll keep this bug open and we can share details as we get to that point. :sunglasses:

chrismetcalf avatar Feb 10 '15 19:02 chrismetcalf

Is 2.0 out yet? Or is there a way to programmatically create datasets? We're importing a bunch of datasets (~400) from an existing data catalog and would love to automate it with python. Thanks!

mappingvermont avatar Oct 26 '15 19:10 mappingvermont

I'm assuming this is possible because you can create datasets via Safe FME. I also would like to programmatically create them via an API

timwis avatar Nov 08 '15 16:11 timwis

@mappingvermont @timwis New dataset creation APIs aren't available yet, and Safe FME uses the very old import API instead of an explicit creation API.

There are internal APIs that allow new datasets to be created - otherwise we wouldn't be able to create them from Socrata's tools either. But they're very old and not something I'd be proud to release to the world. If you poke around in my personal Github long enough, you may or may not find some example code that uses them.

@nitsjuly and I are working on plans for replacements for them, and we'd love feedback and ideas.

chrismetcalf avatar Nov 09 '15 23:11 chrismetcalf

Any hints @chrismetcalf? That's a lot of repos :P I'll share if you share

timwis avatar Nov 10 '15 21:11 timwis

@timwis Only because you're such a nice guy ;)

https://github.com/chrismetcalf/zillow-data/blob/master/bin/uploader

Standard warnings about private/deprecatable APIs apply. :neckbeard:

chrismetcalf avatar Nov 17 '15 23:11 chrismetcalf

Thanks @chrismetcalf, but I think I got it working with the new API this morning: https://github.com/timwis/socrata-creator

timwis avatar Nov 18 '15 12:11 timwis

Working on incorporating it into sodapy rather than a separate library: https://github.com/xmunoz/sodapy/pull/8/files

timwis avatar Nov 19 '15 12:11 timwis

...so that pull request has been merged but I just came across socrata-python-deprecated which uses the same API calls. Did I use an even older API @chrismetcalf? It certainly feels newer...

timwis avatar Nov 27 '15 15:11 timwis

@timwis Actually they're the same API, its a very old private API. :smile:

chrismetcalf avatar Dec 01 '15 18:12 chrismetcalf