JSBot API

If you want to use the knowledge held in JSBot for any purpose, there's an API available at this site.

Search

You can search the knowledgebase using the 'search' parameter with the search term as the argument:

http://fn-js.info/jsbot.xhr?search=term

This will return a JSON string that represents as array of objects such as:

[ { term: "foo", value: "meaning of foo", score: 2 },
{ term: "bar", value: "meaning of bar", score: 2 } ]

The results are sorted by the score attribute. This attribute is calculated according to where in the result the search term exists. If the term is exact, the score will be 8. If the result term starts with the search term the score will be 4. If the result term includes the search term, the score will be 2 and if the value contains the search term, the score will be 1.

Show

You can retrieve a single item from the knowledgebase using the 'show' parameter and the term as the argument:

http://fn-js.info/jsbot.xhr?show=term

This will return a JSON string that represents a single object such as:

{ term: "foobar", value: "meaning of foobar" }

Notes

Precedence

It should be noted that the 'search' parameter has precedence over the 'show' parameter. And so a call to http://fn-js.info/jsbot.xhr?search=term&show=term will ignore the 'show' parameter (no matter which order they appear in the query string) and return a list of matching search results.

No results

When there are no results, the search query will return a string representing an empty array and the show query will return a string representing an empty object.

Errors

If an error occurs, the resulting string will represent an object with only an 'error' attribute

Licence

Please note that the terms of the API require that any use other than in the ##javascript IRC channel, or on this site requires a link back to this site or a reference to ##javascript on Freenode.