7

Can we have the people reached statistic added to the /users/{ids} method?

The response could simply be:

"people_reached": 1000

I'm asking because it would be cool to get a network-wide number.

2

1 Answer 1

2

Until the feature request is approved (unlikely, and a similar request has no developer love either), you can get this number in one of 3 ways:

  • You can get slightly stale data with this SEDE query (Not mine, and may not reflect SE's algorithm as of 2018).
    Note that it uses your Stack Exchange account number (4337810 for the OP) -- which you can get by clicking on the "Accounts" listing of any profile page.

  • Or, You can make a boatload of API calls to get the current information. See the pseudocode, below.

  • Or, You can just scrape all of the user's account profile pages, extracting and summing the people reached stat.


Recipe for calculating network people reached using the API:

  1. Refer to the formula listed in this Meta SE question.

  2. Set variable helpfulViews to zero.

  3. With the user's SE id, call /users/{ids}/associated. For example:
    /2.2/users/4337810/associated?pagesize=100&filter=!Snjr*CId4V6czluxxf

  4. Discard any returned sites that have question_count == 0 AND answer_count == 0.

  5. For each of the remaining site accounts:

    1. Extract the domain name from the site_url. This will be passed as the site parameter.
    2. Using the user's user_id for that site, call /users/{ids}/questions. For example:
      users/74948/questions?pagesize=100&site=webapps.stackexchange.com&filter=!C%28o2zYW*Tj-xzlEqb
    3. Loop through the returned questions, adding the view_counts to helpfulViews. But discard any question that has closed_date set.

    4. Now, call /users/{ids}/answers. For example:
      /users/74948/answers?pagesize=100&site=webapps.stackexchange.com&filter=!.UE8F0rlDSTV0*VE

    5. Set variable ansMetrics to an empty array of objects.
    6. For each answer:

      1. If the score is <= 0, discard it.
      2. Otherwise, make an object containing: the answer_id, the question_id, the score, and the is_accepted value. Add that object to the to ansMetrics array.
    7. Now, collect the question_ids, from ansMetrics into batches of 100.

    8. For each batch, call /questions/{ids}. For example:
      /2.2/questions/65674;67758?pagesize=100&site=webapps.stackexchange.com&filter=!l83g-Uitq5r7FkUIAdfApf

    9. For each question returned:

      1. Retrieve the associated answer_id from the ansMetrics object.
      2. If: That answer has is_accepted == true, then add the question's view_count to helpfulViews.
      3. Else If: That answer has score > 5, then add the question's view_count to helpfulViews.
      4. Else If: That answer is in the top 3 answers, then add the question's view_count to helpfulViews.
      5. Else If: That answer has at least 20% of the total score of all answers, then add the question's view_count to helpfulViews.


  6. When all the looping is done, helpfulViews will be the people reached score.
5
  • That SEDE query is waaaaay off, like inflated by 1800% for my SO "people reached". Thus, I'm hesitant to put any time into trying your API method. I realize this is an old question; maybe something's changed?
    – ashleedawg
    Jun 14, 2018 at 17:01
  • @ashleedawg: (1) That's about 2 logical fallacies, (2) That is not my SEDE query, as clearly shown on the SEDE page, (3) The 2 methodologies are not interlinked, (4) Yes, it is very possible that SE's method has changed. Search the meta sites. Jun 14, 2018 at 19:22
  • @BrockAdams: Why api.stackexchange.com/2.2/users/74948/…*VE return no value in items ? I have replaced site as stackoverflow.com Nov 4, 2020 at 5:43
  • @ᔕᖺᘎᕊ : i tried to use siteName as stackoverflow.com in the above queries and it does not return any item Nov 4, 2020 at 5:45
  • @ShashankVivek your query has an invalid filter: Invalid filter specified. You could try generating the filter string again and retrying Nov 4, 2020 at 9:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .