I would like to programmatically - or with the API determine what a user's reputation is on a particular day. As such, I have found this link: Determine a user's reputation on a given day
However, it does not outline a programmatic method to do so.
I would like to programmatically - or with the API determine what a user's reputation is on a particular day. As such, I have found this link: Determine a user's reputation on a given day
However, it does not outline a programmatic method to do so.
In addition to writing a program that polls and compiles API data as mentioned by Awesome Poodles' Answer, you can also do this via the Stack Exchange Data Explorer.
There are some limitations due to some events not being visible in the data dump (like private reputation events):
Even with these limitations, you can get a pretty representative number for most people. I went ahead and wrote a query doing this here:
https://data.stackexchange.com/stackoverflow/query/882556/reputation-gained-until-a-certain-date
SELECT
-- Total Reputation
(
SUM(CASE WHEN r2d.ReputationFromVotes + r2d.ReputationFromSuggestedEdits > 200 THEN 200 ELSE r2d.ReputationFromVotes + r2d.ReputationFromSuggestedEdits END)
+ SUM(r2d.ReputationFromBounties)
+ COALESCE((SELECT SUM(v4.BountyAmount * -1) FROM Votes AS v4 WHERE v4.VoteTypeId = 8 AND v4.UserId = ##UserId## AND v4.CreationDate < ##UntilDate:string## ),0)
+ COALESCE((SELECT COUNT(*) * 2 FROM Posts AS p3 WHERE p3.OwnerUserId = ##UserId## AND p3.AcceptedAnswerId IS NOT NULL),0)
+ SUM(r2d.ReputationFromAccepts)
) AS TotalReputation,
-- Rep Capped Activities with the Cap Factored in
SUM(
CASE
WHEN r2d.ReputationFromVotes + r2d.ReputationFromSuggestedEdits > 200 THEN 200
ELSE r2d.ReputationFromVotes + r2d.ReputationFromSuggestedEdits
END) AS ReputationFromRepCap,
-- Total Bounties recieved
SUM(r2d.ReputationFromBounties) AS ReputationFromBounties,
-- Total Bounties given
COALESCE((SELECT SUM(v4.BountyAmount * -1) FROM Votes AS v4 WHERE v4.VoteTypeId = 8 AND v4.UserId = ##UserId## AND v4.CreationDate < ##UntilDate:string## ),0) AS ReputationGivenAsBounties,
-- Total Reputation from Accepting Answers
COALESCE((SELECT COUNT(*) * 2 FROM Posts AS p3 WHERE p3.OwnerUserId = ##UserId## AND p3.AcceptedAnswerId IS NOT NULL),0) AS ReputationFromAcceptingAnswers,
-- Total Reputation from Accepted Answers
SUM(r2d.ReputationFromAccepts) AS ReputationFromAcceptedAnswers
FROM
(
SELECT
v.CreationDate AS VoteDate,
-- Total Reputation from Post Upvotes
-- PostTypeId 1 = Question, 2 = Answer
-- VoteTypeId 2 = Upvote, 3 = Downvote
-- CommunityOwnedDate is when a post was made CW.
-- Votes before that count, after not.
-- Vote Date is truncated to full days only so grouping works
SUM((CASE
WHEN (p.PostTypeId = 1 AND v.VoteTypeId = 2 AND (p.CommunityOwnedDate > v.CreationDate OR p.CommunityOwnedDate IS NULL)) THEN 5
WHEN (p.PostTypeId = 2 AND v.VoteTypeId = 2 AND (p.CommunityOwnedDate > v.CreationDate OR p.CommunityOwnedDate IS NULL)) THEN 10
WHEN (v.VoteTypeId = 3 AND (p.CommunityOwnedDate > v.CreationDate OR p.CommunityOwnedDate IS NULL)) THEN -2
ELSE 0
END)) AS ReputationFromVotes,
-- Total Reputation from Answer Bounties
-- VoteTypeId 9 = Bounty Close (Bounty Awarded)
-- BountyAmount = Amount of Reputation awarded
SUM(CASE
WHEN v.VoteTypeId = 9 THEN v.BountyAmount
ELSE 0
END) AS ReputationFromBounties,
-- Total Reputation from Answer Accepts
-- VoteTypeId 1 = AcceptedByOriginator (Answer Accepted)
SUM(CASE
WHEN (v.VoteTypeId = 1 AND (p.CommunityOwnedDate > v.CreationDate OR p.CommunityOwnedDate IS NULL)) THEN 15
ELSE 0
END) AS ReputationFromAccepts,
-- Total Reputation from Suggested Edits
-- if ApprovalDate isn't NULL and RejectionDate is NULL it's been approved and not overriden
-- Group by the same Date as Votes for Rep-Cap evaluation (They count towards it)
COALESCE((SELECT
SUM(CASE WHEN (se.ApprovalDate IS NOT NULL AND se.RejectionDate IS NULL) THEN 2 ELSE 0 END)
FROM SuggestedEdits AS se
WHERE se.OwnerUserId = ##UserId##
AND YEAR(v.CreationDate) = YEAR(se.ApprovalDate)
AND MONTH(v.CreationDate) = MONTH(se.ApprovalDate)
AND DAY(v.CreationDate) = DAY(se.ApprovalDate) ),0) AS ReputationFromSuggestedEdits
FROM Posts AS p
INNER JOIN Votes AS v ON v.PostId = p.Id
WHERE p.OwnerUserId = ##UserId:int##
AND v.CreationDate <= ##UntilDate:string##
GROUP BY v.CreationDate
) as r2d
For your convenience the UserId
And UntilDate
can be entered as variables.
COALESCE((SELECT SUM(v4.BountyAmount * -1) FROM Votes AS v4 WHERE v4.VoteTypeId = 8 AND v4.UserId = ##UserId## AND v4.CreationDate < ##UntilDate:string## ),0) AS ReputationGivenAsBounties,
The API provides /users/{id}/reputation-history
methods for this. There are 2 flavors:
/users/{ids}/reputation-history
Doc -- gets the user's Public reputation events./users/{id}/reputation-history/full
Doc -- gets a logged in user's full reputation events.The first method does not return private reputation events such as the -1
rep for downvoting someone's answer or the super-secret bonus when you {redacted}.
Note: private reputation event data is not available anywhere to anyone but the logged in user viewing her own rep.
Disadvantages: If a user has more than 1 million reputation events, you won't be able to get all his data within your 10K API quota.
calling /users/398595/reputation-history?site=meta
yields results like:
"items": [ {
"reputation_history_type": "post_downvoted",
"reputation_change": -2,
"post_id": 313519,
"creation_date": 1533279795,
"user_id": 398595
}, {
"reputation_history_type": "post_downvoted",
"reputation_change": -2,
"post_id": 313562,
"creation_date": 1533279038,
"user_id": 398595
}, {
"reputation_history_type": "post_upvoted",
"reputation_change": 5,
"post_id": 313561,
"creation_date": 1533278694,
"user_id": 398595
}, {
"reputation_history_type": "post_upvoted",
"reputation_change": 5,
"post_id": 313561,
"creation_date": 1533277282,
"user_id": 398595
}, {
// etc...
-- which you can compile to reconstruct the user's rep on a given date.
site=math
,UserId=460999
,UntilDate=2021-01-15
returns-586
, whereas the activity tab graph shows31
on that date. What might be the reasons for that? The user might've earned reputation from deleted posts. Are there any other possibilities? Refunded downvotes for deleted posts wouldn't enter the equation in the first place.