Stack Apps is a question and answer site for apps, scripts, and development with the Stack Exchange API. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can someone explain how Filters are created in the Stackexchange v2 API?

The documentation mentions the following for /filters/create:

It is not expected that many applications will call this method at runtime, filters should be pre-calculated and "baked in" in the common cases.

Not sure what this means.. Would be really helpful if someone constructed an example URL to make this call.

Thanks!

share|improve this question

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 semi-colon delimited lists of fields to add or remove from the base filter. For example, include=.total;question.body says to return the total field on the common wrapper object and question bodies (provided you call a method that returns questions, naturally).

We provide a utility in the console on every method page (see /questions for example) to make building filters easier.

enter image description here
When you save, the created filter will be placed where the "editing..." box is.

...filters should be pre-calculated and "baked in" in the common cases

Simply means that the vast majority of applications shouldn't call /filters/create as part of their normal operation. An apps developer should have pre-calculated the filters the app needs, and hard-coded them in basically. Note, filters are immutably and non-expiring so this "bake in" is perfectly safe.

share|improve this answer
1  
Is it possible to Name these saved filters instead of resorting to the pre-configured name? – KronoS Oct 12 '12 at 6:41
    
@kevin-montrose I think it would be helpful if the docs on this page mentioned the part about using a semicolon as a delimiter in the create call – chb Jun 18 '13 at 3:38

You must log in to answer this question.

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