Google AJAX APIs outside the browser

Google just announced their new Language API this morning. Unfortunately their API is another one of their AJAX APIs – that are designed to be used from JavaScript in web pages. These APIs are pretty cool for building client-side web applications – I used their AJAX Feeds API in my home page – but I had some ideas for server software that could use a translation API.

I remembered John Resig’s hack from a few months back, getting enough of the DOM in Rhino to run some of the jQuery unit tests. I pulled that down, wrote the bits of DOM that were missing and now I’ve got a Java and JavaScript environment for accessing Google’s AJAX APIs. Apart creating stubs for some methods that are called the main functionality I had to implement was turning Google’s APIs’ asynchronous script loading into the Rhino shell’s load(url) calls. They use <script src="... and document.createElement("script"), but both are pretty easy to catch. The upshot of this is that everything is synchronous. This subtly changes a lot of the interface. For example, my Language API example looks like this:

google.load('language', '1');
google.language.translate("Hello world", "en", "es", 
  function(result) { 

it of course prints: Hola mundo.

I’ve put the source up on github. Have a play, tell me what you think.

5 replies on “Google AJAX APIs outside the browser”

  1. We’ve implemented this in a live web to jabber chat client called (which works within livejournal). Feel free to check it out at our blog Basically you can chat with users to your website in any language, seamlessly, and for free.

  2. I have a question. Perhaps you can help me?

    We would like to build a free windows-based application (for the PC) which would work as text translator (English to Spanish only)

    I have read somewhere that the maximum number of requests per day is 1000.

    My question is : Would each one of the Users who installs our Fee application (using Google’s API) be limited to 1000, or is it the TOTAL number of Users multiplied by the total number of translations of each one that should not exceed 1000?

    We want to give this hypothetical application free to our list of clients (about 2000) . So… there is a limitation problem

    Please advise

    Thanks in Advance

    Ricardo Arguello
    Word Magic Software

Comments are closed.