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.

7
  • 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. Commented Feb 16, 2018 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. Commented Feb 16, 2018 at 20:47
  • @BrockAdams thank you I tried it but it gives only some of bronze badges Commented Feb 17, 2018 at 7:28
  • You probably aren't paging through the results. Consult the docs for that library. Commented Feb 17, 2018 at 8:07
  • 1
    @BrockAdams many thanks I made it. I agree totally. Commented Feb 17, 2018 at 20:40

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.