Tuesday, August 19, 2008

How to use tinydb.org

how to use

write a DB entry

Make a POST or GET request to http://tinydb.org/_write.

write GET example:
http://tinydb.org/_write?this=is so simple&i=will use this a lot

You can make as many variables as you in your POST or GET request.

the only special field that is always created is \"url\"
the _url parameter is so when people click your link on a web page, they can go to an actual site rather than seeing your data.

the _url paramater must be in the format http://www.url.com or http://url.com after submitting your request, we will return a unique short url you can use to access your data ( tinydb.org/c )
If your _url parameter contains the string __tinydb_id__ , this string will be replaced with your new tinydb id. Eg, setting the _url param to http://kortina.net?tinydb_id=__tinydb_id__ will create a tinydb record that redirects to http://kortina.net?tinydb_id=19f (or whatever the tinydb id you create is)
read a DB entry

Call a url. If you want the data returned in a certain format add ?_f=json to your request. The current formats are:

* _f = json - returns a json object containing your data
* _f = jsonp - returns a json object but in javascript, that is fed directly into a callback function, tinydbCallback, to be called once the script is loaded. use your own callback with ( &_c=callback )
* _f = js - returns a json object but in javascript, with an optional callback function ( &_c=callback ) to be called once the script is loaded
* _f = xml - returns your data in XML

- these also work on the _write call, allowing your app to get the id back in a friendly format.
- the default format for read is HTML, so if you provide no _f parameter, you will recieve html
- the default format for write is plaintext, so if you provide no _f parameter, you will recieve a plaintext url for your tinydb data
read examples:

*** Note: It should be assumed that any data stored in tinydb is not secure and can be accessed by anyone.
read and write multiple rows

To create an entry with multiple rows add the _i parameter to your first write call (i.e. http://tinydb.org/_write?_i&name=jane&comment=first row). This will basically your first entry be your parent_id. So additional writes to this should contain the id as the _i variable returned on the first write. (i.e. http://tinydb.org/_write?_i=Qw&name=joe&comment=another row).

To return a list of the rows just call the original id with the _i=true as a parameter (i.e. http://tinydb.org/Qw?_f=xml&_i=true )

Remember you can create rows, but not edit them - you can see a sample of this here.

FLASH DEVELOPERS: There is a bug with google app crossdomain.xml file -- so to get the proper unrestricted crossdomain.xml you must use the appspot.com domain which in our case is tinydborg2.appspot.com (i.e. http://tinydborg2.appspot.com/Qw?_i=true&_f=xml).

No comments: