Stack Apps is a question and answer site for apps, scripts, and development with the Stack Exchange API. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to get the amount of reputation that a user has. I have established that I need to use this url:, but where do I go from there?

I have a knowledge of PHP, HTML, JavaScript and a bit of jQuery.

I have looked around extensively and cannot find out how to handle the response (or get one) from a script.

Thanks in advance :)

share|improve this question
up vote 3 down vote accepted

"I have established that I need to use this url: ..."

That is the correct path to use, but the order and sort query string parameters are unnecessary since you will always be receiving only one item in the response.

"I have a knowledge of PHP, HTML, JavaScript and a bit of jQuery."

The Stack Exchange API can be accessed using both PHP and JavaScript. You will need to decide whether API requests should be made by the client or the server.

"... how to handle the response (or get one) from a script."

As mentioned in my previous sentence, it really depends on which language you will be using - the approach used in each case will differ greatly. In PHP, requests against the API will likely be synchronous and use PHP's cURL functions. In JavaScript, however, your requests will most likely be asynchronous and must be made with XMLHttpRequest (or JSONP if your browser does not support CORS).

In both cases, the actual response will be in JSON format.

Instead of interacting directly with the API, I would highly recommend using one of the existing libraries / wrappers. I have written a library for PHP that is compatible with version 2.0 of the API: Stack.PHP. I wrote a brief tutorial describing the usage of the library.

Things aren't so easy in JavaScript - the only library that I'm aware of supporting v2.0 of the API is Stack.JS, which I also wrote. However, it is far from complete and not very well tested. Your best bet is probably to use the jQuery.ajax() method of the jQuery library.

Edit: as requested, here is an example demonstrating how to fetch a user's reputation withs Stack.PHP:


require_once 'stackphp/api.php';

$stackoverflow = API::Site('stackoverflow');
$user = $stackoverflow->Users(1272330)->Exec()->Fetch();

echo $response['reputation'];


The example above will output the reputation of user #1272330 on Stack Overflow.

share|improve this answer
That looks absolutely great. Well done for developing it. Could you tell me how I could get the reputation of a user (with said link )? Thanks so much in advance. – Mattios550 Apr 15 '13 at 17:14
@Mattios550: With Stack.PHP? – Nathan Osman Apr 15 '13 at 18:18
Yes please? I'd really appreciate it. – Mattios550 Apr 15 '13 at 18:35
@Mattios550: I've added an example to my answer. – Nathan Osman Apr 15 '13 at 19:22
Thanks alot; this has really helped me. – Mattios550 Apr 17 '13 at 15:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .