Using this, it is possible to take the badges from a specific user of Stack Overflow:
library(stackr)
badges <- stack_users(9371451, "badges", num_pages=100000, pagesize=100)
How can I add a parameter to take also the timestamp that the badge was awarded to the user? And if possible, for which answer?
It is possible-ish with the Stack Exchange API, but not with the stackr library you are using.
The
/users/{ids}/badges
route returns a list of badge objects, which only has these possible properties:So you can't get the timestamp or triggering post there.
However, you can get this information (mostly) from the
/notifications
route, which can return results like:But, important:
/notifications
requires authentication and only works for a logged-in (via the API) user.rank
, so you will still need to call/users/{ids}/badges
and marry the results.you can use
users/{ids}/timeline
. See description page:The
:::
is necessary because the functionstack_GET
is an internal command