4

I would like to get the total number of answers provided by userid 1068142 between 01/07/2015-31/07/2015 with tag = paypal.

I have looked into this question but it does not help!

I have been trying this for quite sometime with no correct output.

PS: I am building a web application and can use only API calls. (So no SEDE (yet).)

4

Your stated problem is considerably easier than the question you linked.
You can use the /users/{ids}/answers route to get what you want -- with a little work.
The trick is to use a filter that returns the answers.tags property.

In your case, if you really just want totals, and for one user at a time, you can use the filter: !GeF-5u(cSumXA .

The general procedure is:

  1. Call /users/{ids}/answers with the desired user ID's, the desired date ranges, and an appropriate filter.
    For example:
    /users/1068142/answers?fromdate=1435708800&todate=1438387200&order=desc&sort=creation&site=stackoverflow&filter=!GeF-5u(cSumXA

  2. This returns results like:

    {
      "items": [ {
          "tags": [
            "paypal"
          ]
        },
        ... ...
        {
          "tags": [
            "paypal-adaptive-payments"
          ]
        }
      ],
      "has_more": false,
      "quota_max": 10000,
      "quota_remaining": 9984
    }
    
  3. Use paging, if necessary, to fetch all of the results.

  4. Now loop through the items array and count how many times the tags array contains "paypal". (In this case 7)

  5. That's your answer.


IMPORTANT:

  1. When searching for date ranges, you almost always want to increment the todate by one full day (see the link for details).
    For example, if you want items from 12-12-2012 to 12-13-2012, you would use todate=1355443200 (The equivalent of 12 AM on 12-14-2012).

  2. If you want more information per answer, or you search for more than 1 user ID at a time, then you will have to edit your own custom filter. It is best if you use a filter that only returns the items you need (plus all of the .wrapper handshaking).

  • thanks for that, I have already followed the similar steps and was successful :) got to know other useful information too ! perfect – Vimalnath Sep 3 '15 at 19:14
  • You're welcome; glad it helped! – Brock Adams Sep 3 '15 at 19:15

You must log in to answer this question.

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