How can I get all the unaccepted answers within a date range at user level?

前端 未结 1 1343
北荒
北荒 2021-01-26 05:50

I am able to retrieve a list of all my answers, within a given date range, by using this below curl command:

curl "https://api.stackexchange.com/2.2/users/10         


        
相关标签:
1条回答
  • 2021-01-26 06:48

    is_accepted is one of the fields. And, in the current stage, it seems that this cannot be used for filtering the result values as the query parameter.

    From this situation, how about the following workaround? I would like to propose to use jq for filtering the retrieved values. In this workaround, the values with is_accepted: false are retrieved from the all retrieved values using jq.

    Sample command:

    curl "https://api.stackexchange.com/2.2/users/10348758/answers?page=1&pagesize=100&fromdate=1588291200&todate=1592179200&order=desc&sort=activity&site=stackoverflow&access_token=my-access-token&key=my-key" | gunzip | jq '[.items[] | select(.is_accepted == false)]'
    
    • In this case, jq '[.items[] | select(.is_accepted == false)]' is used for the retrieved values.
    • By this modification, the values with "is_accepted": false are retrieved.

    Note:

    • In this modification, it supposes that your access token and key can be used for requesting to https://api.stackexchange.com/2.2/users/10348758/answers.

    References:

    • Usage of /answers/{ids}
    • jq
    0 讨论(0)
提交回复
热议问题