JSON Profile Data

JSON is a nice, lightweight format which is relatively terse and provides for a simple way to encode complex information. There are libraries (or native support) for it in most programming languages now, including Javascript, which makes it a perfect cross-language encoding format. Requesting profile data in JSON is a simple process and gives you immediate access to all open profile information.

Base Request

Making a JSON request is likely to follow these steps (assuming you have an email address already):

Append .json to that URL to indicate that you want the results in JSON format

Once you have done the above, you should end up with a URL that looks something like this:

https://www.gravatar.com/205e460b479e2e5b48aec07710c08d50.json

When you request that URL (you can do it in your browser) you should get a JSON document containing all open profile data. We use Portable Contacts to format our profile data whereever possible, so see the PoCo spec for more details on the structure of the response.

Request Options

Gravatar also supports JSONP requests to make working with the data via Javascript a little easier. If you append a query string parameter callback to the URL, then that will be wrapped around the resulting JSON object and thus executed when the data is fully loaded.

A request with a callback (to execute an 'alert') would look something like this:

Tips

The "About Me" or "Description" section of a profile may contain line breaks, so be careful how you use it in Javascript.

Many fields may contain apostrophes or other characters which affect Javascript output, so be careful to escape those characters if they are a concern.

Links (a href) within the "Description" field are automatically modified to include rel="nofollow" on profile pages, but the raw profile data does not have this change applied.

As with all profile data formats, profile requests will only resolve for the hash of the primary address on an account. Users may have multiple addresses on a single account, so while a Gravatar image request may return a result, a profile request for the same hash may not.