Automattic / jetpack

Security, performance, marketing, and design tools — Jetpack is made by WordPress experts to make WP sites safer and faster, and help you grow your traffic.
https://jetpack.com/
Other
1.59k stars 798 forks source link

JSON API: allow more query parameters #5860

Open jeherve opened 7 years ago

jeherve commented 7 years ago

wpcom_json_api_request_as_blog() is currently used by Jetpack itself, but can also be used by third-party plugin authors via functions like stats_get_from_restapi().

Unfortunately, one cannot make custom API queries via stats_get_from_restapi() right now, because the query parameters are filtered out here: https://github.com/Automattic/jetpack/blob/4.4.2/class.jetpack-client.php#L273

Would it be possible to allow more parameters, so one can do requests like this for example:

// Retrieve the 50 more popular posts every week in the past 7 weeks.
$args = array(
    'num' => 7,
    'period' => 'week',
    'max' => 50,
);
$stats = stats_get_from_restapi( $args, 'top-posts' );

Reported in 2872802-t

jeherve commented 7 years ago

Related: #7059

stale[bot] commented 6 years ago

This issue has been marked as stale. This happened because:

No further action is needed. But it's worth checking if this ticket has clear reproduction steps and it is still reproducible. Feel free to close this issue if you think it's not valid anymore — if you do, please add a brief explanation.

danielbachhuber commented 5 years ago

FYI (came across this via search) - I think you can work around the argument limit with something like this:

stats_get_from_restapi( array(), 'top-posts?max=100&summarize=1&num=2' );
stale[bot] commented 5 years ago

This issue has been marked as stale. This happened because:

No further action is needed. But it's worth checking if this ticket has clear reproduction steps and it is still reproducible. Feel free to close this issue if you think it's not valid anymore — if you do, please add a brief explanation.