Take the 2-minute tour ×
Stack Apps is a question and answer site for apps, scripts, and development with the Stack Exchange API. It's 100% free, no registration required.

I am using the 2.2 API to display user stats by quarter, but I also want to display reputation changes between any 2 dates.

I use the /users/{ids} API to get the summaries. For example, user 2403309 on Stack Overflow shows a +72 reputation change in the current (April 1 onwards) quarter (which matches his profile), but /users/2403309/reputation shows entries that add up to 68 and it seems to be missing a couple of +2 accept bonuses.

Any idea as to why this is?

Here's the screenshot of the profile, from April 28 (the last change before that was August last year):

This adds up to 72 points

This is the JSON I get by querying /users/{ids}/reputation from April 1 to May 4 (which is two days in the future, because otherwise some changes weren't included, but that is a separate question):

{
  "items": [
    {
      "on_date": 1399076511,
      "reputation_change": 10,
      "vote_type": "up_votes",
      "post_type": "answer",
      "post_id": 23416402,
      "user_id": 2403309
    },
    {
      "on_date": 1399076478,
      "reputation_change": 10,
      "vote_type": "up_votes",
      "post_type": "answer",
      "post_id": 23416787,
      "user_id": 2403309
    },
    {
      "on_date": 1398979754,
      "reputation_change": 15,
      "vote_type": "accepts",
      "post_type": "answer",
      "post_id": 23416787,
      "user_id": 2403309
    },
    {
      "on_date": 1398977734,
      "reputation_change": 15,
      "vote_type": "accepts",
      "post_type": "answer",
      "post_id": 23416402,
      "user_id": 2403309
    },
    {
      "on_date": 1398718062,
      "reputation_change": -2,
      "vote_type": "down_votes",
      "post_type": "question",
      "post_id": 23348663,
      "user_id": 2403309
    },
    {
      "on_date": 1398712175,
      "reputation_change": 5,
      "vote_type": "up_votes",
      "post_type": "question",
      "post_id": 23348663,
      "user_id": 2403309
    },
    {
      "on_date": 1398711479,
      "reputation_change": 5,
      "vote_type": "up_votes",
      "post_type": "question",
      "post_id": 23348269,
      "user_id": 2403309
    },
    {
      "on_date": 1398711171,
      "reputation_change": 5,
      "vote_type": "up_votes",
      "post_type": "question",
      "post_id": 17688439,
      "user_id": 2403309
    },
    {
      "on_date": 1398711150,
      "reputation_change": 5,
      "vote_type": "up_votes",
      "post_type": "question",
      "post_id": 17394188,
      "user_id": 2403309
    }
  ],
  "has_more": false,
  "quota_max": 10000,
  "quota_remaining": 9940
}
share|improve this question
    
This is a duplicate and is related to: stackapps.com/questions/4555/… and stackapps.com/questions/1431/… and stackapps.com/questions/4584/… . –  Brock Adams May 6 at 1:05
    
@BrockAdams Second one looks mostly unrelated, but definitely looks like a dupe of first, and third calls out first specifically. However, the proposed dupe target is an unresolved bug report, whereas this is a resolved support request... (Maybe it's [status-bydesign]...) –  michaelb958 May 6 at 22:19
    
@michaelb958, This question is also probably a bug report (and is still tagged that way at the moment). I think this is probably faulty/poor behavior (thus a valid bug), but I haven't taken the time to analyze it properly. –  Brock Adams May 6 at 22:24
    
@BrockAdams It's still tagged that way because suggested edits. *sigh* –  michaelb958 May 6 at 23:01
    
@michaelb958, I know and I approved your edit despite thinking that removing the bug tag might not be best. Most of your edits improve posts, but we might need to chat (later) about the edit remarks. I think there's now only 2 of us who review general edits, and since I'm not a mod, I can't approve them all by myself unless I improve them. Nor can I review tag-wiki edits. –  Brock Adams May 6 at 23:09

1 Answer 1

up vote 3 down vote accepted

From the docs for /users/{ids}/reputation (emphasis mine):

Gets a subset of the reputation changes for users in {ids}.

I think you'll find that the API method you're using is working exactly as designed - it's just not designed to do what you were expecting.

Fortunately, /users/{ids}/reputation-history will yield precisely what you're after.

Returns users' public reputation history.

This is what http://api.stackexchange.com/users/2403309/reputation-history?site=stackoverflow&fromdate=1396310400&todate=1399420800 yields:

{
  "items": [
    {
      "reputation_history_type": "post_upvoted",
      "reputation_change": 10,
      "post_id": 23416402,
      "creation_date": 1399198727,
      "user_id": 2403309
    },
    {
      "reputation_history_type": "post_upvoted",
      "reputation_change": 10,
      "post_id": 23416402,
      "creation_date": 1399076511,
      "user_id": 2403309
    },
    {
      "reputation_history_type": "post_upvoted",
      "reputation_change": 10,
      "post_id": 23416787,
      "creation_date": 1399076478,
      "user_id": 2403309
    },
    {
      "reputation_history_type": "answer_accepted",
      "reputation_change": 15,
      "post_id": 23416787,
      "creation_date": 1398979754,
      "user_id": 2403309
    },
    {
      "reputation_history_type": "answer_accepted",
      "reputation_change": 15,
      "post_id": 23416402,
      "creation_date": 1398977734,
      "user_id": 2403309
    },
    {
      "reputation_history_type": "asker_accepts_answer",
      "reputation_change": 2,
      "post_id": 23415248,
      "creation_date": 1398973813,
      "user_id": 2403309
    },
    {
      "reputation_history_type": "post_downvoted",
      "reputation_change": -2,
      "post_id": 23348663,
      "creation_date": 1398718062,
      "user_id": 2403309
    },
    {
      "reputation_history_type": "post_upvoted",
      "reputation_change": 5,
      "post_id": 23348663,
      "creation_date": 1398712175,
      "user_id": 2403309
    },
    {
      "reputation_history_type": "asker_accepts_answer",
      "reputation_change": 2,
      "post_id": 23349002,
      "creation_date": 1398711485,
      "user_id": 2403309
    },
    {
      "reputation_history_type": "post_upvoted",
      "reputation_change": 5,
      "post_id": 23348269,
      "creation_date": 1398711479,
      "user_id": 2403309
    },
    {
      "reputation_history_type": "post_upvoted",
      "reputation_change": 5,
      "post_id": 17688439,
      "creation_date": 1398711171,
      "user_id": 2403309
    },
    {
      "reputation_history_type": "post_upvoted",
      "reputation_change": 5,
      "post_id": 17394188,
      "creation_date": 1398711150,
      "user_id": 2403309
    }
  ],
  "has_more": false,
  "quota_max": 300,
  "quota_remaining": 292
}

Which, accounting for that upvote from today (after you took your test data), is exactly what you're after.

share|improve this answer

You must log in to answer this question.

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