Yes, you can find out if the user has received the association bonus using the API. It's a bit clunky though.
However, as we discovered, "association bonus rights" are rather meaningless at the moment. Otherwise, you'd be able to edit wikis, upvote, comment, and flag on Information Security Stack Exchange right now, despite currently only having 1 rep there.
If the association "rights" persisted, then you could use the API's /users/{id}/privileges
route to see if you had, say, the Edit Community Wiki privilege despite not having 100 rep.
However, they currently do not stick, and I've created a bug report on Meta SE which you might want to review (and upvote).
Using the /users/{ids}/reputation-history
route to see if the association bonus was given:
The /users/{ids}/reputation-history
route will show if the user has received the association_bonus
. Example:
/reputation-history#ids=169072&site=security
Unfortunately, a user may have thousands of reputation events, and there is no way to filter, nor change the sorting of, that route's output.
Fortunately:
- Although the order can't be changed, the results do appear to be sorted by
creation_date
.
- In most cases, the user will get the bonus within the first 200, or so, events.
So, a recipe for seeing if the user has the bonus might go like this:
Get the user's total number of events like:
/2.2/users/331508/reputation-history?site=stackoverflow&filter=!--pn9sU*3FRx
Result: ... "total": 7192
Divide the total by 100 and add 1 to get the number of pages. In this case, 72.
Fetch the last page like:
/2.2/users/331508/reputation-history?page=72&pagesize=100&site=stackoverflow&filter=!9Z(-x-d4A
Result: entry not yet present.
If the results do not contain the association_bonus
entry fetch the penultimate page:
/2.2/users/331508/reputation-history?page=71&pagesize=100&site=stackoverflow&filter=!9Z(-x-d4A
Result: association_bonus
entry found.
The association_bonus
entry will almost always be there. If not, continue fetching pages off the end until you are satisfied.
Notes:
- The
/users/{ids}/reputation
route won't work because it only reports (some) rep changes associated with posts.
- There is no easy way to detect the bonus in SEDE.