2

I used the following request link to extract data from the Stack Exchange API. But I have no idea how to create "filter" as used in the request line.

Please help me understand the creation of such filter in order to get the desired fields in response the response.

https://api.stackexchange.com/2.1/users/2/answers?key=xTr7YgsHdmfcevW6Vo1*BQ((&page=1&pagesize=100&site=stackoverflow&filter=!3u0zcO%28lpHVEGuskA

6

You can create and edit filters from the documentation page of the API endpoint.

So you start at the Index of all endpoints. There you'll find /users/{id}/answers.

On the right at the top of the parameter block you'll find the filter dialog:

enter image description here

When you click the [edit] link the filter dialog opens:

enter image description here

Where you can expand any the [types] provided by this endpoint.

enter image description here

If you click [Save] you'l get a magic number representing your selection.

You can also provide an that magic when you start editing. You take the filter value from the url, in your case:

!3u0zcO%28lpHVEGuskA

but notice it has %28 in it which indicate it is url encoded. So we first reverse that by running this in the Developer Console

decodeURI('!3u0zcO%28lpHVEGuskA');

which returns

!3u0zcO(lpHVEGuskA

You can copy-paste that value in the textbox at the top of the filter dialog, to get the types and fields that were selected for that magic number:

enter image description here

Another option is to use the read-filter endpoint which returns an object showing the selected fields for a particular filter.

You must log in to answer this question.

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