Skip to content
This repository has been archived by the owner on Mar 12, 2022. It is now read-only.

Search offset doesn't work #18

Open
jmike opened this issue Aug 18, 2015 · 6 comments
Open

Search offset doesn't work #18

jmike opened this issue Aug 18, 2015 · 6 comments

Comments

@jmike
Copy link

jmike commented Aug 18, 2015

Seems that "offset" param in the search() method doesn't do anything.

The code below produces the following results:

client.search('facebook', 5, 0)
  .then((results) => {
    console.log(results[0].child.map((e) => e.details.appDetails.packageName));
  })
[ 'com.facebook.katana',
  'com.facebook.lite',
  'com.facebook.orca',
  'com.facebook.work',
  'com.facebook.stickered' ]

But when I change the offset from 0 to 5 I still get the same results.

client.search('facebook', 5, 5)
  .then((results) => {
    console.log(results[0].child.map((e) => e.details.appDetails.packageName));
  })
[ 'com.facebook.katana',
  'com.facebook.lite',
  'com.facebook.orca',
  'com.facebook.work',
  'com.facebook.stickered' ]

Do you know if Google have changed their API? I am pretty sure this was working fine a few months ago.

@dweinstein
Copy link
Owner

I confirmed locally that the offset parameter isn't working currently. I'm investigating whether the parameter has changed and will get back to you.

@dweinstein
Copy link
Owner

yeah it looks like they got rid of the offset (o) parameter. max size of 100 seems to be all we're able to do now. I'll update the code to reflect that and maybe warn with some kind of deprecation warning on requests with an offset being set.

@jmike
Copy link
Author

jmike commented Aug 19, 2015

FYI search response contains a nextPageUrl property, specifically response.payload.searchResponse.doc[0].containerMetadata.nextPageUrl.

Using that URL one can iterate over the result pages.

@dweinstein
Copy link
Owner

nice. yeah the containerMetadata field is described here https://github.com/dweinstein/google-play-proto/blob/master/googleplay.proto#L546-L554 -- I suppose I could return an iterator that would allow requests to walk the nextPages, but that would probably have to be exposed as a different method name on the API object.

Thoughts on this?

@jmike
Copy link
Author

jmike commented Aug 20, 2015

Iterator is an excellent idea! As for exposing new search functionality under a different method name, I believe this is a matter of preference. The way things are going with Google Play the search method will be useless unless people are only looking to get the 1st page of the results. So why not change it completely and bump the major version of the project? Again, this is a matter of preference.

The only alternative I can think of is iterating the pages internally and collecting the results in a single array to return.

@jberlynn
Copy link

jberlynn commented Aug 3, 2017

How do you go about using the nextPageUrl to navigate to the next page?
I'm new to node.

Right now I am just using the search function example with the command running node search.js etc etc etc

function search (term, n, offset) {
return api.search(term, n, offset).then(function (res) {
console.log('%j', res);
});
}

How can I retrieve the nextPageUrl and navigate to it?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants