# [Proposal: posts and pages API filtering](https://github.com/kadamwhite/wordpress-rest-api/issues/121)

> state: **open** opened by: **leobalter** on: **12/30/2015**

Looking at the docs on examples like: 

&#x60;&#x60;&#x60;js
wp.posts().id( n ).revisions()
wp.posts().type( type_name )
&#x60;&#x60;&#x60;

How about fetching only a small subset of posts and pages directly on &#x60;posts&#x60; or &#x60;pages&#x60; methods as:

&#x60;&#x60;&#x60;js
wp.posts(&#x27;id&#x27;, n).revisions()
wp.posts(&#x27;type&#x27;, type_name);
&#x60;&#x60;&#x60;

On a future this can be also improved to pass a object with more includes like:

&#x60;&#x60;&#x60;js
wp.posts({
  id: n,
  type: type_name
});
&#x60;&#x60;&#x60;

This proposal should regard it might conflict with a way to set what you want from the posts, let&#x27;s say you only want to fetch the comments:

&#x60;&#x60;&#x60;js
wp.posts({
  type: type_name,
  fetch: [ &#x27;comments&#x27; ]
});
&#x60;&#x60;&#x60;

These ideas are inspired on my previous experience with Ember, and they&#x27;re just suggestions which I&#x27;m sure you&#x27;ll take the best decision if it&#x27;s a good improvement or not for this api.

### Comments

---
> from: [**kadamwhite**](https://github.com/kadamwhite/wordpress-rest-api/issues/121#issuecomment-172935971) on: **1/19/2016**

@leobalter Thank you for the suggestion! I&#x27;ve been thinking about ways to implement this and the object form, such as
&#x60;&#x60;&#x60;js
wp.posts({
  id: 3782
}).get( // ...
&#x60;&#x60;&#x60;
may actually be fairly straightforward to implement. Basically, when a request object is instantiated, it will iterate through the keys of the provided object; if it has a method for that key, as there is an &#x60;.id()&#x60; chaining method to complement the &#x60;id&#x60; key, it would call that method with the value of the key in the object. I think I prefer this approach to passing in the key and variable as two separate parameters, because named arguments makes the most sense to me when there is significant specificity and creating a request object feels very general in comparison.

Thoughts?
---
> from: [**leobalter**](https://github.com/kadamwhite/wordpress-rest-api/issues/121#issuecomment-172938225) on: **1/19/2016**

the way you presented is great because it works better on the single responsibility pattern and it&#x27;s less magical than jQuery-like methods we are used to (e.g.: &#x60;$.ajax&#x60;).

Your approach seems as a great approach as you&#x27;re working on a web application library.
