3

I would like to use the Stack Exchange API with a specific user id to get the text of a user's badges.

I found the stackr library for the Stack Exchange API, and tried this:

# install.packages("devtools")
library(devtools)
devtools::install_github("dgrtwo/stackr")
library(stackr)
stack_users(712603)

But that only gives the total number of every kind of badge. How can I take the text from each one? Example:

gold silver bronze
r     r      ggplot2

I don't only want the total number of badges but also what the badges are.

Brock Adams
  • 90,639
  • 22
  • 233
  • 295
Pozmanski
  • 181
  • 11
  • Can you clarify what you are asking? And please fix your spelling throughout. I can't tell if you want to get a single user and see what badges they have, or find all users with a specific badge. – Max von Hippel Feb 16 '18 at 20:43
  • @MaxvonHippel thank you. As I mention at the start I want for a single user. For example user has 6 gold badges which could be r, python etc. – Pozmanski Feb 16 '18 at 20:47
  • @BrockAdams thank you I tried it but it gives only some of bronze badges – Pozmanski Feb 17 '18 at 07:28
  • You probably aren't paging through the results. Consult the docs for that library. – Brock Adams Feb 17 '18 at 08:07
  • @BrockAdams thank you. Unfortunately I can't find an official document and using in r console `?stack_users` I can't see any paging through the results. – Pozmanski Feb 17 '18 at 10:29
  • @BrockAdams thank you it was very helpful for me. Please could you help with one more thing. I would like to take all questions of a user with their body. I tried this `textques <- stack_users(712603, "questions", body = "true", num_pages=10, pagesize=100)` but it hasn't the body. Any idea if it is possible to take also the body? – Pozmanski Feb 17 '18 at 12:42
  • 1
    @BrockAdams many thanks I made it. I agree totally. – Pozmanski Feb 17 '18 at 20:40

1 Answers1

2

With that library, use:

stack_users(712603, "badges")

to get badges with descriptions and use something like:

stack_users(712603, "badges", num_pages=10, pagesize=100)

to get the user's first 1000 badges.



The default ordering is by rank, not date, so you would get bronze badges first, then silver, then gold, with that library.

Brock Adams
  • 90,639
  • 22
  • 233
  • 295