-
Notifications
You must be signed in to change notification settings - Fork 9
Home
Welcome to the fluidinfo.js wiki!
Fluidinfo has been variously described as "a Wikipedia for data", "a platform for open data", "a social network for your data" and "stonkingly cool". It's basically a hosted storage solution that allows companies and individuals to create, search, organise and share data.
Fluidinfo also provides instant online APIs for those who use it for storage.
Finally, Fluidinfo provides simple yet powerful mechanisms for users to control their data. Nevertheless, it is organised in such a way that it remains openly writeable (so anyone can contribute).
Why not read our introduction to Fluidinfo..?
In case you hadn't guessed fluidinfo.js
is a small library for using Fluidinfo's REST API with Javascript. It is currently aimed at client side development although plans are afoot to make it work server-side (with frameworks such as node.js). Fluidinfo supports CORS (Cross Origin Resource Sharing) so fluidinfo.js
opens up the potential of sharing, using and annotating open, linked data with Fluidinfo within your own websites and projects.
var fi = fluidinfo({username: "username, password: "password");
var onSuccess = function(result) {
// A callback to do something with the result
};
var onError = function(result) {
// A callback to handle when things go wrong
};
fi.query({select: ["fluiddb/about", "ntoll/rating", "terrycojones/comment",
where: 'oreilly.com/title matches "Javascript"', onSuccess: onSuccess, onError: onError});
To get started you should instantiate a fluidinfo object and optionally pass in three arguments contained in an options object:
var options = {
username: "fred", // your fluidinfo username
password: "secret", // your fluidinfo password
instance: "main" // either "main", "sandbox" or "http://somthing.else/"
};
var fi = fluidinfo(options);
Note: Passing no options assumes you're connecting as the anonymous user to the main instance. If you don't include an instance
argument the library will default to the main instance. (The sandbox is used for testing and is regularly cleaned/restarted. Passing in a URL is a convenience for Fluidinfo developers running a development instance locally.)
The library is organised into two levels:
- Utility functions for common tasks.
- API functions for accessing Fluidinfo's REST API.
These functions make it easy to perform the most common types of interactions with Fluidinfo. They follow a common pattern:
- Pass in arguments via an
options
object. - Handle two types of callback:
onSuccess
andonError
. - Both callbacks are passed a
result
object that contains the following attributes:- status the HTTP status code for the result from Fluidinfo (e.g. 200, 404)
- statusText a description of the status of the result from Fluidinfo (e.g. "OK", "Not found")
-
headers an object representing the headers and associated values returned from Fluidinfo (e.g.
{ "Content-Type": "application/json"}
) -
rawData if appropriate, a
string
representation of the raw data payload returned from Fluidinfo (e.g. the following JSON string:'{ "id": "9c8e4b12-4b7d-40d2-865b-d5b1945350b1", "URL": "http://fluiddb.fluidinfo.com/objects/9c8e4b12-4b7d-40d2-865b-d5b1945350b1"}'
-
data if appropriate, a processed and de-serialized representation of the data payload returned from Fluidinfo (e.g. the following Javascript object related to the JSON string above:
{ id: "9c8e4b12-4b7d-40d2-865b-d5b1945350b1", URL: "http://fluiddb.fluidinfo.com/objects/9c8e4b12-4b7d-40d2-865b-d5b1945350b1"}
- The content of
result.data
will often be post-processed and/or cleaned up in some useful way.
Allows a logged-in user to easily create/re-use an object in Fluidinfo.
var options = {
about: "my new object",
onSuccess: function(result) { // do something useful },
onError: function(result) { // handle any problems }
};
fi.createObject(options);
The about
value is used to indicate what the new object represents. If an object "about" this value already exists then details of the existing object will be returned. It's possible to create so-called anonymous object that don't have an associated "about" value by leaving the about
attribute out of the options.
Removes a collection of tags (and associated values) from objects that match the query in the where
argument.
var options = {
values: ["ntoll/rating", "ntoll/description"],
where: 'fluiddb/about="my object"',
onSuccess: function(result) { // do something useful },
onError: function(result) { // handle any problems }
};
fi.delete(options);