The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Hot answers tagged

6

This is what custom filters are for. For example, if you append &filter=!BGRhem4Z)WIti9lP55R*tgr(Jq_fHC to your query, above, you will get results without upvote_count, downvote_count, or owner information. (The first two aren't included by default anyway.) An easy way to create a filter is to use the filter-edit tool, on the appropriate doc page for ...


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: When you click the [edit] link the filter dialog opens: Where you can expand any the [types] provided by this ...


4

The most straightforward way to get the body is to use the named withbody filter, which you pass in as the value of the filter parameter (example). This will give you all of the default fields, along with the post body. You can also create a custom filter that passes back question.body and answer.body where appropriate along with your select choice of other ...


4

Filters are created by sending include, exclude, and base to /filters/create. You can use GET for rapid prototyping, or POST when the amount of data you're sending grows too large for a GET. base specifies a filter to use as a template. It is the "default" filter, by default. A blank slate can be achieved by using "none". include and exclude contain ...


3

"A number of" might be a bit of a misnomer, as there are a whopping four standard ones: From the filters documentation: default, each type documents which fields are returned under the default filter (for example, answers). withbody, which is default plus the *.body fields none, which is empty total, which includes just .total The page also ...


3

This appears to be closely related to the bug: Why is comment_count=1 (incorrectly) when this particular filter is used?. The workaround from there -- altering the filter by: selecting comment.comment_id and selecting question.comments appears to work in this case too. (Although, in at least one instance, it seemed to need question_id as well. But this ...


3

The key mistake here is neglecting the Wrapper Object, and this is a big flaw with the filter documentation. The wrapper is the box that everything you get from the API comes in. You always get the wrapper object except in the grossest of server/API errors. (In your case you were getting a wrapper of {}.) The stuff you care about, the payload, is the ...


2

Yes. You can pass a filter, and you should (for all the standard reasons). First: On the doc page, changing the filter or preview, etc. will not change the URL for write methods. Write methods must POST to the API, which means that parameters are supposed to be sent form encoded, not in the URL. (This API bakes some things, like post ID, into the route. ...


2

Well, this was a fun one. Basically, a number of methods were figuring out that you weren't asking for any fields on an object type (like, say, users) and short-circuiting around database queries. Unfortunately, there are also some methods that relying on the database queries to populate total. This generally happened in the "query by id" methods. So, I ...


2

No, we won't be implementing this. Not that I don't see a use case for it, but we'd never be able to accept and execute arbitrary regular expressions against the database. It'd just be far too easy cripple performance wise (we've done this accidentally plenty of times, and we don't have to worry about malicious actors on the dev team). While we could ...


2

The API console in the documentation should attach it's key to all requests now. For the filter creation error, what's happening there is actually a size check against the incoming parameters .NET enforces. A better error is returned now, but the proper course of action for a consumer remains the same; use POST when creating filters with a large # of ...


2

No, you cannot pass multiple filters. But the good news is you don't need to. Just create a custom filter. In your case, you might first set the edit tool to use withbody, and then further edit the filter to check the box next to .wrapper -> total, in the edit tool. When you do that, you get a custom filter like !BHTP)ZqRO*RussQSam5gFh2.5-X*0T -- which ...


1

I have struggled with Stack Exchange API filters too, when I tried to incorporate up_vote_count, down_vote_count and view_count attributes in my user response object. I visited this page of the Stack Exchange API to create my filter (same as you). I just wanted to include my three attributes and thus set the following parameters: include: user....


1

I was able to deduce an answer by 'reverse-engineering' (sort of) the default filter: /2.2/filters/default this gives { "items": [ { "included_fields": [ ".backoff", ".error_id", ".error_message", ".error_name", ".has_more", ".items", ".quota_max", ".quota_remaining", "...


1

Confirmed. The path seems to use a default sort key on last_activity_date and that corrupts the filter somehow. (I checked for caching by waiting more than 1 minute and by varying the question ids.) If I create a new filter and explicitly specify a sort key on votes, it worked for a time or two (no last_activity_date returned). But somehow it still inserts ...


1

You're not returning .items, which contains the objects that have the fields you want back. When you include it you get !*QjqSxwBvapC)EVC)JW_Vhi*w4jvF.WzEYmxBpMaH, which does return values for /sites, /questions, and /users.


1

Perhaps a good approach would be to cache the entire list of tags on a site (there are only 770, or 25 pages worth on Travel.SE). You can then run them through a RegEx locally. Tags don't change very much so you could just refresh your list every week or so to keep it up to date. You didn't specify a particular language / framework, but if you were using ...


1

I can't reproduce this bug, both queries return what I'd expect (and variations work as well).


Only top voted, non community-wiki answers of a minimum length are eligible