Digital Web Magazine

The web professional's online magazine of choice.

Your Social Graph: Exploring the Google API

Got something to say?

Share your comments on this topic with other web professionals

In: Articles

By Brian Suda

Published on February 26, 2008

“You are known by the company you keep”, as the old saying goes; and, at least as far as the internet is concerned, Google’s recently released Social Graph API makes it easy to identify the individuals whose company you are keeping. It not only acts as a tool to make your data portable, but it can also be used to audit your own activities online.

The Social Graph API accesses the parts of the internet which specifically deal with declared relationships. A Social Graph shows connections based on who your friends are, and the web sites you have in common. Each person is represented by a dot with lines representing the web sites linking them to and from each other—the more dots (or people) you add, the bigger the interconnected graph becomes.

The Google Social Graph API comes with three example applications to demonstrate common uses for the tool:

Identity Consolidation

Gathering information about yourself is pretty easy—enter your name into Google and you might be surprised how much Google already knows! This type of search only reveals how often your name is mentioned—it doesn’t include any relationships or other structured data.

The site connectivity example does something similar. It allows you to enter a list of URLs, much like entering your name in the search box, and see sites that are interlinked with the ones you entered.

For instance, when I enter my claimID page the list contains sites that Google knows share a reciprocal link, and that represent me. On claimID, I link to my personal site, suda.co.uk, and I also link to several other sites, such as Flickr. On Flickr, my profile page links back to my personal site. The Social Graph API can easily find and display all these links about me—the Googlebot has been scouring the net collecting these pages and links for years.

Adding the XFN value rel="me" to links about yourself is the first step towards claiming a pageas your own, and is the key to merging all of your online identities. Most sites assume that if you can edit the page then you control it. If you create a page on a social networking site that links to your personal site, and your personal site has a reciprocal link to the social networking site, and both links have rel="me" then there is an agreement that you must control both of those pages and that they both represent you. In my case, my claimID page links to suda.co.uk and to Flickr. Flickr links to suda.co.uk, so we have a closed loop and that identity can be consolidated.

There are several benefits to consolidating your online identity. You prove one site is equivalent to another through a transitive process of ownership. If I can prove that I own suda.co.uk and I can prove that my Flickr profile page is also connected to suda.co.uk, then it is possible to show that my Flickr profile page is also me. If you consolidate all of your sites, then any of them can represent you, and each site can be used to represent a body of work spread across the internet.

For more information about XFN and rel="me" you can read more and see some examples at The Global Multimedia Protocols Group.

Relationship Management

Typed relationships are the next interesting aspect of the Social Graph API. As I join social networking sites and attend conferences, I continue to meet new people and strengthen old friendships. After these events, people head off to their virtual worlds and make new connections or change others.

<a href="http://johndoewebsite.com/" rel="met colleague">John</a>
<a href="http://janesweb.com" rel="friend">Jane</a>

The “My Connections” API example acts as a relationship detection tool so you can better manage your connections. When I type my claimID link into the search box, it will search all my other social networking sites and find the people who I link to and how I link to them. Do I consider that person a ‘friend’? Have I ‘met’ them? And are they a ‘co-worker’ or merely a ‘colleague’? I can also see people who are linking to me and in what fashion; do they claim to have ‘met’ me? Knowing who links to who, and how, allows you to see your connections in one simple place and makes them easy to manage. And who knows? Noticing old friends link to you may prompt you to link back to them and strike-up a conversation.

Custom Searching

The last example API that Google provides is there to let you play with all the different parameters to see what everything does. The API returns the data as JSON and allows you to send it to a callback function of your choice. At the moment, there are only 7 possible parameters that can be used in any combination—the example application displays all seven.

The first parameter is q, and is the list of URLs you want to search on: http://socialgraph.apis.google.com/lookup?q=suda.co.uk.

{
 "canonical_mapping": {
  "suda.co.uk": "http://suda.co.uk/" 
 },
 "nodes": {
  "http://suda.co.uk/": {
   "attributes": {
   }
  }
 }
}

The information returned from this is not that interesting, so we need a few additional parameters. The next parameter is fme which means “follow me”. This returns additional links that are also the same identity as the q value. The parameter is optional, so you do not need to add this if you do not need this data. http://socialgraph.apis.google.com/lookup?q=suda.co.uk&fme=1

{
 "canonical_mapping": {
  "suda.co.uk": "http://suda.co.uk/" 
 },
 "nodes": {
  "http://openid.claimid.com/briansuda": {
   "attributes": {
   },
   "claimed_nodes": [
   ]
  },
  "http://suda.co.uk/": {
   "attributes": {
   },
   "claimed_nodes": [
    "http://openid.claimid.com/briansuda" 
   ]
  }
 }
}

The next two optional boolean parameters are edi and edo. The edi parameter is inbound edges, which is a fancy term for people who link to me, whereas edo is outbound edges, which means people that I link to: http://socialgraph.apis.google.com/lookup?q=suda.co.uk&fme=1&edi=1&edo=1

{
 "canonical_mapping": {
  "suda.co.uk": "http://suda.co.uk/" 
 },
 "nodes": {
  "http://suda.co.uk/": {
   "attributes": {
   },
   "claimed_nodes": [
   ],
   "unverified_claiming_nodes": [
   ],
   "nodes_referenced": {
   },
   "nodes_referenced_by": {
    "http://adactio.com/articles/": {
     "types": [
      "friend" 
     ]
    },
    "http://adactio.com/journal/": {
     "types": [
      "colleague",
      "friend" 
     ]
    },
    "http://dev.w3.org/cvsweb/?rev\u003d1.10": {
     "types": [
      "colleague",
      "contact" 
     ]
    },
    "http://dmitry.baranovskiy.com/": {
     "types": [
      "colleague",
      "friend" 
     ]
    },
    "http://factoryjoe.com/blog/": {
     "types": [
      "contact",
      "friend" 
     ]
    },
    "http://microformateurs.org/": {
     "types": [
      "colleague",
      "friend" 
     ]
    },
    "http://microformatique.com/": {
     "types": [
      "colleague",
      "contact" 
     ]
    },
    "http://thedredge.org/": {
     "types": [
      "colleague",
      "contact" 
     ]
    },
    "http://wordpress.com/": {
     "types": [
      "acquaintance" 
     ]
    }
   }
  }
 }
}

The next parameter is another optional boolean parameter called pretty. This just outputs the JSON in a more readable format, indented and plenty of returns. (The default is to remove all unnecessary white-space.)

http://socialgraph.apis.google.com/lookup?q=suda.co.uk&fme=1&edi=1&edo=1&pretty=1

The 6th parameter is boolean and optional as well—it is sgn which controls Social Graph Normalized URLs. You don’t need to worry too much about this parameter—it converts the URLs to the special protocol sgn:// for special applications: http://socialgraph.apis.google.com/lookup?q=suda.co.uk&fme=1&edi=1&edo=1&pretty=1&sgn=1

The final parameter is callback; it is an optional string containing the name of the function you want to use to process the data: http://socialgraph.apis.google.com/lookup?q=suda.co.uk&fme=1&edi=1&edo=1&pretty=1&sgn=1&callback=foobar

It simply wraps the function name around the output:

foobar({
 "canonical_mapping": {
  "suda.co.uk": "http://suda.co.uk/" 
 },
 "nodes": {
  "http://openid.claimid.com/briansuda": {
   "attributes": {
   },
   "claimed_nodes": [
   ]
  },
  "http://suda.co.uk/": {
   "attributes": {
   },
   "claimed_nodes": [
    "http://openid.claimid.com/briansuda" 
   ]
  }
 }
}
);

With these parameters you can easily extract the data from Google and migrate it into your own system. What you do with this data next is up to you!

Possible Applications

The Social Graph API tool can allow you to easily jump-start the next site you visit. When I sign up for next week’s hot website, I don’t want to spend hours re-inviting all my friends and re-adding all those connections—and now, with this API, I won’t have to. The new social networking site can simply ask for your URL (not your username and password) and pull in all the people who you have previously declared a ‘contact’ on other websites. Your buddy list is effectively distributed across the internet, and can be queried from a single point. The social networking site can use that list of people to see if any of them are already members, and allow you to connect with them instantly. No more searching for all your friends and adding them one-by-one!

The nice thing about the new Social Graph API is that any site could benefit from it, even the ones you have been a member of for a long time. I use Dopplr, and if it were to query the API once a week, it would learn that on Tuesday I added a new friend to my Flickr contact list. Next time I log in, it could prompt me: “Hello Brian, one of your friends from Flickr is also a Dopplr member, click here to add them as a Dopplr traveller as well.” Now I no longer have to manage lists in multiple places, I can simply add friends in any of my favorite services and rely on the API to pull in that data from around the web.

Auditing your internet fingerprint

The API is an excellent tool to uncover what Google—and subsequently others—know about you. It allows you to make corrections to your online identity by finding and closing old profiles you never use, as well as correcting any information that is wrong or out-of-date. You can also see if Google has made the connection between you and your profiles elsewhere. If you sign-up at a new social networking site, you can use this API to see if Google has merged that with your overall online identity.

Summary

It is too early to tell whether the benefits of the Social Graph API outweigh the possible negative possibilities. As with any new technology, we need time to understand the implications. Google now makes it very easy to see who is connected to whom, which can be a scary idea; it could wrongly implicate someone, suppress others, associate you with groups that you might not want public, expose you to social engineering attacks, and more.

Further reading

Got something to say?

Share your comments  with other professionals (0 comments)

Related Topics: Technology, Scripting, Prototyping, Programming, Content, Browsers, API

 

Since discovering the Internet in the mid-90s, Brian Suda has spent a good portion of each day connected to it. His own little patch of Internet is http://suda.co.uk, where many of his past projects and crazy ideas can be found.

Media Temple

via Ad Packs