05 Jun 2011

By - 823 Comments

Pile of +1 Buttons Now that the Google +1 button is out the Social SEO battle will inevitably be stepped up a gear. We know the search engines are using social shares and likes to impact the rankings, and Google’s +1 button is their way of ensuring at least some of this data is directly in their hands.

So obviously, tracking this data is very important for SEOs, and both Facebook and Twitter have APIs for pulling in Likes and Tweets, but currently we are left without a public API for doing this with Google’s +1 button. With a little digging behind the scenes I managed to find the API they use for the button. So now us SEOs can use it to pull out the Google +1 counts for lists of URLs (if you are interested in the technical details then see the optional section below).

I’ve put together a public Google Spreadsheet which can do all of this automatically for you – you just need to enter a list of URLs and the spreadsheet will pull in the counts for you. To get started, open the spreadsheet (download it right here) and select “Make a copy” from the File menu (you’ll need to be logged into a Google account to do this). Enter the URLs in the the A column (ensuring you pay attention to trailing slashed and they include http:// at the start), and the counts will appear in column B. You should see something like this:

Google Spreadsheet showing Google +1 Counts

Technical Bits

If you want to write your own solution, you can rip the code from the spreadsheet. The URL for the service is:


It is a JSON-RPC setup, meaning you send a JSON formatted request and get a JSON formatted response. The request should be via POST in the following format:

  1. [{"method":"pos.plusones.get","id":"p","params":{"nolog":true,"id":"http://www.test.com","source":"widget","userId":"@viewer","groupId":"@self"},"jsonrpc":"2.0","key":"p","apiVersion":"v1"}]

The request will be returned like so:

  1. [{"result": { "kind": "pos#plusones", "id": "http://www.google.com/", "isSetByViewer": false, "metadata": {"type": "URL", "globalCounts": {"count": 3097.0} } } "id": "p"}]

Example PHP Code

If you want to implement this server side, here is some example PHP code to get you going:

  2. <?php
  4.  $url = "http://www.tomanthony.co.uk/";
  6.  $ch = curl_init();  
  7.  curl_setopt($ch, CURLOPT_URL, "https://clients6.google.com/rpc?key=AIzaSyCKSbrvQasunBoV16zDH9R33D88CeLr9gQ");
  8.  curl_setopt($ch, CURLOPT_POST, 1);
  9.  curl_setopt($ch, CURLOPT_POSTFIELDS, '[{"method":"pos.plusones.get","id":"p","params":{"nolog":true,"id":"' . $url . '","source":"widget","userId":"@viewer","groupId":"@self"},"jsonrpc":"2.0","key":"p","apiVersion":"v1"}]');
  10.  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  11.  curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
  14.  $curl_results = curl_exec ($ch);
  15.  curl_close ($ch);
  17.  $parsed_results = json_decode($curl_results, true);
  19.  echo $parsed_results[0]['result']['metadata']['globalCounts']['count'];
  21. ?>

There is an interactive demo here: Google +1 Button API demo.

Wrap Up

If you want to track social shares and likes and aren’t already setup with a Google Doc for the Twitter/Facebook parts you can head over to this post on Distilled which will help you get going. Combined with the above and you can build a complete system for tracking social search signals. Have fun!

823 comments on “Google +1 Button SEO – Getting Bulk Counts with the hidden API
  1. Bradley Fehler

    Great post! Thanks.

    It’s certainly a start :)

  2. John Dyer

    Thanks! This is just what I was looking for. I wish Google would make it as easy as Facebook and Twitter to get the count.

  3. Tom

    I agree! I’m sure they will in time, but not sure why they haven’t from the get go. This private API isn’t quite as straightforward as the Twitter and FB ones, but works perfectly for the moment. Fingers crossed they release a public API with proper support.

    Would love to hear what you use it for. :)

  4. Cctv installers

    Hi Tom, I was wondering if you have any suggestions as to how I can integrate the google plus 1 button into my wordpress site ?

  5. Jake

    When I copy your exact code(except change the API key to mine), I get a error returned from Google. Any idea what the problem could be? It’s returning a 400 error.

    [ { “error”: { “code”: 400, “message”: “Bad Request”, “data”: [ { “domain”: “global”, “reason”: “badRequest”, “message”: “Bad Request” } ] }, “id”: “p” } ]

  6. Tom

    Hi Jake,

    You’ve answered your own question! Don’t change the key – it is a developerKey that is the same for everyone. Changing it will give you a 400 error. Let me know how you get on (and what you are using it for – I love to know about applications!). :)


  7. Tom

    Cctv installers – I recommend this plugin: Google +1 WP Plugin from Pleer. It works great. :)

  8. Jake

    Thanks for the help, seems I was getting ahead of myself changing the API key without being told to ;P.

    On another note, you wouldn’t happen to know how to get the amount of stumbles for a URL would you? They provide no public API and I’m struggling to find any code pasted online.

  9. Vladimir

    Ruby one-liner 😀

    require ‘curb’
    require ‘json’

    JSON.parse((Curl::Easy.http_post(‘https://clients6.google.com/rpc?key=AIzaSyCKSbrvQasunBoV16zDH9R33D88CeLr9gQ’,[{‘method’=>’pos.plusones.get’,’id’=>’p’,’params’=>{‘nolog’=>true,’id’=>’!->URL’widget’,’userId’=>[email protected],’groupId’=>[email protected]},’jsonrpc’=>’2.0′,’key’=>’p’,’apiVersion’=>’v1′}]){|curl|curl.headers[‘Accept’]=’application/json’;curl.headers[‘Content-Type’]=’application/json’;curl.headers[‘Api-Version’]=’2.2′}).body_str)[‘result’][‘metadata’][‘globalCounts’][‘count’]

  10. Vladimir

    Sorry, parser killed my code

    require ‘curb’
    require ‘json’

    JSON.parse((Curl::Easy.http_post(‘https://clients6.google.com/rpc?key=AIzaSyCKSbrvQasunBoV16zDH9R33D88CeLr9gQ’,[{‘method’=>’pos.plusones.get’,’id’=>’p’,’params’=>{‘nolog’=>true,’id’=>’!!!URL!!!’,’source’=>’widget’,’userId’=>[email protected],’groupId’=>[email protected]},’jsonrpc’=>’2.0′,’key’=>’p’,’apiVersion’=>’v1′}]){|curl|curl.headers[‘Accept’]=’application/json’;curl.headers[‘Content-Type’]=’application/json’;curl.headers[‘Api-Version’]=’2.2′}).body_str)[‘result’][‘metadata’][‘globalCounts’][‘count’]

  11. Jake

    On another note, I just found this class on CodeCanyon. Looks useful for those of us that need to count multiple statistics. SocialCounter Class

  12. Tumadjian

    Thanks to share it dude, nice!

  13. PHP Agentur

    PHP: I would add CURLOPT_SSL_VERIFYPEER = false, use curl_setopt_array for performance reasons and put the whole thing in a function like this: /php-google-plus-one-count-api
    But the best version is async processing of multiple urls at once.

  14. Aurimas

    Thanks a lot for the code – I’ve been monitorig the web for such a solution for a couple of weeks already, but found this post only today. And I was wondering – how do you find out what kind of request is made in such cases? I’ve seen people similarly ripping apart Twitter private API for tweet count, but I never got to know how it is done. Could you share the approach?

  15. Justin Vanderheide

    Thanks, this is working wonderfully.

  16. Is there a way to count how many "Likes", "Tweets", "+1's", etc., a given URL has? - Quora

    […] and PeopleAddFind Questions, Topics or PeopleCancelFlag Answer1 Comment • 3:08pm on Thursdayhttp://www.tomanthony.co.uk/blog… for Google+Jonathan Ong • 4:34pmView 1 Comment Edit Link Text Show answer summary preview […]

  17. shri

    I am passing following JSON to URL you mentioned. I am getting error below json string. Same code was working five days back. What can be the reason behind the error

    JSON String I am passing to googleplusone
    [{“method”:”pos.plusones.get”,”id”:”p”,”params”:{“nolog”:true,”id”:”http://yahoo.com”,”source”:”widget”,”userId”:[email protected],”groupId”:[email protected]},”jsonrpc”:”2.0″,”key”:”p”,”apiVersion”:”v1″}]

    Error I am getting :
    {“error”:{“code”:-32700,”message”:”A JSONObject text must begin with ‘{‘ at character 0 of “,”data”:[{“domain”:”global”,”reason”:”parseError”,”message”:”A JSONObject text must begin with ‘{‘ at character 0 of “}]}}

  18. seo reseller

    The big difference of Google +1 to other social media is it will have influence on the search results people see at Google.

  19. fernando

    I think it doesn’t work … Maybe … Google has change anything ?

  20. fernando

    My curl_getinfo:
    Array ( [url] => https://clients6.google.com/rpc [content_type] => [http_code] => 0 [header_size] => 0 [request_size] => 0 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0 [namelookup_time] => 0 [connect_time] => 0.112 [pretransfer_time] => 0 [size_upload] => 0 [size_download] => 0 [speed_download] => 0 [speed_upload] => 0 [download_content_length] => 0 [upload_content_length] => 0 [starttransfer_time] => 0 [redirect_time] => 0 )

    May be the problem is the ssl certificate ?

  21. Dan Jones

    Great tutorial. I had a little trouble at first, and kept getting the “Bad Request” error.
    I discovered the reason I was getting it is because I was leaving off a trailing slash on a domain, i.e., I had put “http://example.com”, instead of “http://example.com/”. If anyone else is having similar problems, you might want to check that.

  22. Holly Jahangiri

    Works great, but I did notice a quirk in the spreadsheet – it won’t update automatically on refresh. I have to copy/paste the urls into new cells – then the count updates.

  23. Andreas

    The spreadsheet works great, thanks for that. I do have a problem with the PHP code though. It does not return the same values as the spreadsheet but lower +1 counts. Anybody that has noticed this, or even better, found a workaround?


  24. Monitoring Socials


    this was useful information. I have small problem. When I put $url = ($_GET[‘url’]); and wish to check +1 counts this don’t work. Anybody know how to fix that?

    Thank you.

  • Guest

    I’ve no idea why Google doesn’t yet have an API like Facebook or Twitter to make this easy but thanks to you we can still get the count easily. Works perfectly and does exactly what I wanted.


  • webdevelopergeeks

    Hi, I have one question. I want followers of my brand page. Means who has added me to their circles. It seems g+ is showing pluses and followers total at top. I am not sure how can i get that. You examples fetches pluses count for a website. I want such as Facebook or Twitter like fans or followers count. Is it possible?

  • Scott

    OK, I’m not sure if I am the only one attempting this via javascript or not, but I seem to be the only commenter with this problem:

    XMLHttpRequest cannot load https://clients6.google.com/rpc?key=AIzaSyCKSbrvQasunBoV16zDH9R33D88CeLr9gQ. Origin http://mydomain.com is not allowed by Access-Control-Allow-Origin.

    Any chance this is something stupid I am missing, or do I need to be doing this server-side? I cannot imagine their server would be interpreting the requesting domain any differently from the server versus the client. Any ideas?

  • curious

    Hi, I’m not familiar with php. Is there a way directly retrieval the count using an url? Could we put the parameters in the url? I tried several times but couldn’t get it right. If you can show me how to do it, it will be great!


    • curious

      Or how to do that using curl?
      I tried
      curl -v -k -H “Content-Type: application/json” -X POST -d ‘{“method”:”pos.plusones.get”,”id”:”p”,”params”:{“nolog”:true,”id”:”http://www.test.com”,”source”:”widget”,”userId”:[email protected],”groupId”:[email protected]},”jsonrpc”:”2.0″,”key”:”p”,”apiVersion”:”v1″}’ https://clients6.google.com/rpc?key=AIzaSyCKSbrvQasunBoV16zDH9R33D88CeLr9gQ
      but it didn’t work. I got an “error code 400…”
      Could you please help me?

  • Plusone Expert

    Very helpful article indeed. I have to admit that I always follow all blog posts about plus one, so it was quite interesting to read this. Thank you

  • Todd Marcum

    Hi All…

    I’ve tried several times an keep getting a 400 error. I haven’t changed the API code either

    [0] => Array
    [error] => Array
    [code] => 400
    [message] => Invalid Value
    [data] => Array
    [0] => Array
    [domain] => global
    [reason] => invalid
    [message] => Invalid Value



    [id] => p


    Any ideas? Has Google gone live with this and or killed this key?


  • Dev

    I am also getting same error

  • analyzer

    I’m getting same error too

  • Dev

    It will give above error if url does not have the Google+ button.

  • Nicolas

    I’m getting same error too

  • wes

    this doesn’t work no more!

    it is absurd that we can’t get the count

    how will we write this tag (defined by google’s schema.org)

    <meta name="interactionCount" content="UserPlusOnes:NUMBER_THAT_I_CANT_GET" >

    if we can’t get the count? it is non-sense!

  • Paweł Rabinek

    The main disadvantage of this is that you can check G+ count for only one specified page/URL, not for entire website. Thats sad, but actually there’s no way to count +1 for entire website :( If you want to quick check of +1 and Like count of page, try http://www.seoptimer.com for this.

  • Kalpa Welivitigoda

    Wow This post and comments are really helpful. Thanks a lot.

  • David Do

    Yeah, this is great to read the article. Many thanks, Tom Anthony

  • Andor Nagy

    Hey, When I try to use this method, on a wordpress website I got this error :

    ‘ Fatal error: Call to undefined function curl_init() in C:\xampp\htdocs\wordpress\framework\wp-content\themes\framework\lib\functions-extanded.php on line 435 ‘

    Any idea? Or how to make so it is defined?

  • Joan Izquierdo

    Hi, great post! thanks. I have a question about this. Is it possible get the globalCounts for a Google+ Page? for example: https://plus.google.com/+FCBarcelona/ .. a lot of thanks.

    • Joan Izquierdo

      ufff.. I found the solution. you must make the request with the identifier. For exemple:

      $url = “https://plus.google.com/116151548242653888082”;

      Yea! it works.

  • Sreejesh

    Spreadsheet gives me error: Unknown function name GETPLUSONES

    • Łukasz Kęska

      Hey, I have the same problem, unknow function getplusones… Did U manage to find a solution?


  • Ankur

    How did u get the google plus counts? I dint get ….could you please share the code for getPlusones() ?

  • Mete

    What about share button count? (not +1’s). can we count them?

  • Social SEO Share Counts Private & Public APIs

    […] from Google’s hidden API in their Google Plus widget, find the details at Tom’s blog: www.tomanthony.co.uk/blog/google_plus_one_button_seo_count_api/ […]

  • [PHP]or[java script]google+1のカウント数だけを取得して表示する | CreativeLife

    […] Google +1 Button SEO – Getting Bulk Counts with the hidden API – Tom Anthony […]

  • edy

    an example with javascript please I can not even get it ..

  • Accessing Google +1 stats via Google Analytics API? | StackAnswer.com

    […] found this blog post about accessing Google +1 stats. However, we are rolling out a fairly large project that needs to […]

  • Krzysiek Deszcz

    Hi Tom! I really enjoy your post. This small webservice is very useful for me to quickly find G+ count for single page or small bunch of URLs. It would be (drastically) more useful to know if I could use it (or maybe there is another way) to grab g+ count for a bigger number… let’s say for 50K URLs daily basis.
    I can also divide it to the smaller number but I can’t find if there is any query limit.

  • antie

    is can’t work,all is error message : Access Not Configured. Please use Google Developers Console to activate the API for your project. but i was active g+ services.
    and i can’t find about this api about “pos.plusones.get” explanation

  • dan

    how to get my own API key?

  • Leave A Comment

    Your email address will not be published. Required fields are marked *