Posts Tagged ‘API’

Tagalus Widget

Tuesday, March 10th, 2009

Tagalus widget exampleRight on the heels of the announcement of our API, we’re announcing one of the first applications of it: the Tagalus Widget.

The Tagalus Widget provides a way for other web-apps to leverage the power of Tagalus by letting users view and set tag definitions without leaving the page.  In the pictured example (from Combotweet), a user has clicked on the Tagalus icon next to the tag .  When they click, a box pops up displaying the definition of the tag.  Also, if the user has entered an API key (or the site has set one for the user), they are allowed to create their own definition and submit it to Tagalus.

Because of cookie restrictions, the user has to set their API key for each site, but if they check “Remember your API key,” the key will be stored so that they don’t have to enter it each time that come back to the site.

Adding the widget to your site

Adding the widget to your site is relatively easy.  There are three required files:

- jQuery (http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js)

- Tagalus Widget CSS (http://tagal.us/stylesheets/tagalus_widget.css)

- Tagalus API Interface script (http://tagal.us/javascripts/tagalus_api_interface.js)

To add the functionality to this blog (running a modified version of the default theme), here’s the code that I put in the <head> section of the document:


<script src="http://tagal.us/javascripts/tagalus_api_interface.js" type="text/javascript"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
<link href="http://tagal.us/stylesheets/tagalus_widget.css" media="screen, projection" rel="stylesheet" type="text/css"/>

<script type="text/javascript">
jQuery(document).ready(function() {
TagalusAPI.load_widget();
TagalusAPI.add_buttons_to_elements("a[rel='tag']")
});
</script>

The code is fairly self-explanitory, with the exception of the last bit.  First, it imports the three required files (<script> and <link> elements).  Then, it uses jQuery’s docment.ready to determine when the page is ready, and proceeds to load the widget.  The next call is where the magic is: TagalusAPI.add_buttons_to_elements.  This is the function that puts the clickable Tagalus icons next to tags in your page (note that the link still clicks through to its original destination) – if you would like to just have the link open up the widget and forgoe the icon, use TagalusAPI.bind_to_links(selector).  The argument that you feed it is a jQuery selector.  So, if you wanted it on every link of the page, you would call TagalusAPI.add_buttons_to_elements(“a”).  For every link of class ‘tagalus_link’, you would call TagalusAPI.add_buttons_to_elements(“a.tagalus_tag”).  In this case, we’re looking for all of the links that have “tag” in their ‘rel’ element – something that all pages that use the Tag microformat would use.  Read more about jQuery selectors here.

We hope to have a WordPress plugin automating this functionality soon for your blogs.  But, keep in mind this is not limited to blogs – it is already in use on Combotweet, which is a Twitter client, for example.  It could also be used on photo viewers, video pages, or whatever you want.

Tagalus API Announced

Tuesday, March 10th, 2009

Until now, Tagalus has allowed two methods to interact with the service – via the website, and via Twitter.  This gave users a fair amount of flexibility in how they interact with the service, depending on their needs.

Today, we’re announcing a new way to interact with Tagalus: an API.

As of now (version 0001), the API allows for most of the functionality that the website offers, including creating tags, definitions, and comments, and of course fetching them as well.  What isn’t available is anything related to creating or editing users, for obvious security reasons.

In regards to authentication and security, all methods relating to fetching data are available without authentication.  Methods that create data require that the client app provide an API key.  API keys are provided to each user – you can find your key by going to the User Details page on Tagalus (you have to be logged in, obviously).  API keys should be kept secret, but in the event that one becomes insecure, a new key can be generated on that same key.  Be forewarned that this will make the old API key invalid.  This will be the authentication method of choice for the time being – it is possible that it will be deprecated in favor of OAuth in the future, but it seems unnecessary at this point.

API limits will not be throttled for the time being, but we reserve the right to adjust that in the future.

Also, the API will be published and modified in versions.  As to not break applications when changes are made to the protocols, client apps will be able to specify which API version they would like to use.  At a certain age, old versions of the API may be deprecated, but the goal is to have at least the current version, plus the revision or two before it available all the time.

To read more about the API and learn how to use it, visit the Tagalus API Documentation