2 Quick Start

Let’s say you simply want to use one of the Google web services.

1. If you don’t already have one, get an API key from Google’s API Console.

2. Put your Google API key in a .google-api-key file in your home directory (On Unix and OSX: ~/.google-api-key.)

3. Find the name of the discovery document corresponding to the service you want to use; see Available service documents. For example, you want to use the goo.gl URL shortener service, and find that its name is urlshortener.v1.js.

4. Use require-gapi-doc to define Racket functions. For instance:

(require gapi/macro)
(require-gapi-doc "urlshortener.v1.js")

5. Use the resulting functions to make requests to the service.

For example:

;; Use goo.gl to make a short URI
(define js (urlshortener-url-insert #:longUrl "http://www.racket-lang.org/"))
(dict-ref js-insert 'id)

In this example, the urlshortener-url-insert procedure was defined when you did (require-gapi-doc "urlshortener.v1.js") in step 4.

Documentation of the functions defined for each service can be found using the links in Available service documents.

In general the web services will return JSON which is parsed and returned to you as a jsexpr? via the Racket json collection.