OpenData Project

Written by Kevin on November 04, 2010

This was an interesting idea, but no longer had any purpose and had many security flaws. Therefor, I shut it down

I have started a project I call the OpenData Project. To sum it up it is a free, open API that serves as a simple Key/Value server. The API is easy to understand, and can be accessed from anything that can make http calls. There is no signup, no registration, no fees, nothing. Just use it. I have provided a simple implementation of the API in php, but it is easily portable to any other language.

How it works

As a user, you start by creating a new table. To do this you must pass the new query and a tablename. This can be done via GET or POST, but for simplicity sake I will only show you GET examples here. To start a new table, you would do this:

http://kevingravier.com/opendata/api.php?q=new&name=test

Create new table

This will return a plaintext answer. If there were no problems it will be 3 lines. The first line is the result code. A 0 inplies there was an error, a 1 implies there was no problems. If you get a 1, as you should, the next line will be your secret key. You must save this because it is required to use your table. The third line should be the name of the table you sent to OpenData. Below is an example of a new query’s result.

1
618f1323ad3e7c7b376e1e79e13e0ee6
test

Add a new key

From here you can add data to your table. This can be achieved by sending the add query along with the table name, the secret key for that table, the key name, and the value you want to save.

http://kevingravier.com/opendata/api.php?q=add&name=test&secret=618f1323ad3e7c7b376e1e79e13e0ee6&key=test&value=bla
The result again will have a 1 or 0 on the first line, 1 for success and 0 for failure. Here is the result from the previous query.

1
test
bla

Edit an existing key

As you can see the request was successful and it returned the key and value. Once keys are added, you obviously can edit them. the query is almost the same as the add but just change the word add to edit.

http://kevingravier.com/opendata/api.php?q=edit&name=test&secret=618f1323ad3e7c7b376e1e79e13e0ee6&key=test&value=blabla
Now the Key test has the value blabla. Here is the result from that.

1
test
blabla

List all existing keys

You can see the result is the same format every time. Now lets say we want to see all the keys that are on the table test, I have added a few extras already, they were test2, and hello. You can just run the list query. Remember you still have to give the table name and secret key.

http://kevingravier.com/opendata/api.php?q=list&name=test&secret=618f1323ad3e7c7b376e1e79e13e0ee6
The result follows the same pattern. The first line will be a 1 or 0. If it is a 1 each following line will contain one key.

1
test2
test
hello

View the value for a key

To view the value of any key, just use the view query.

http://kevingravier.com/opendata/api.php?q=view&name=test&secret=618f1323ad3e7c7b376e1e79e13e0ee6&key=test
With the result:

1
blabla

Delete a key

To delete a key, and its corresponding value, you can use the delete query. Lets delete the key test2.

http://kevingravier.com/opendata/api.php?q=delete&name=test&secret=618f1323ad3e7c7b376e1e79e13e0ee6&key=test2
With a simple result:

1
test2

Remove a table

And finally to remove the entire table, including the secret key associated with it, use the remove query.

http://kevingravier.com/opendata/api.php?q=remove&name=test&secret=618f1323ad3e7c7b376e1e79e13e0ee6
And the result of the remove is:

1
test
618f1323ad3e7c7b376e1e79e13e0ee6

Handle errors

It gives you the table name and the secret key that was linked to it. Every error is returned as follows:

0
error_number
description of error
I will post a list of what each error number means at a later time. I have also written a sample OpenData class you can use to access the OpenData server easily. I wrote this is php and also plan of porting it to perl and python. Here is that code:http://kevingravier.com/opendata/sample.txt. Any question, comments, or concerns can be sent to me via email: kevin at mrkmg dot com or posted as a comment here. Thanks, Kevin Gravier (MrKMG).