google-api-nodejs-client icon indicating copy to clipboard operation
google-api-nodejs-client copied to clipboard

How to use maxResults in inappproducts.list

Open AleeeKoi opened this issue 4 years ago • 8 comments

Hello, I'm tring to get full list of in app products of an android application. This is my code:

const androidpublisher = require('@googleapis/androidpublisher')

[...]

const auth = new androidpublisher.auth.GoogleAuth({
  keyFilename: path.join(__dirname, '..', 'config', 'credential.json'),
  scopes: ['https://www.googleapis.com/auth/androidpublisher']
})

const client = await androidpublisher.androidpublisher({
  version: 'v3',
  auth: await auth.getClient()
})

const { data } = await client.inappproducts.list({
  packageName,
  maxResults: 1000,
  token
})

But I'm not able to get more than 100 products per request, maxResults seems not to work. Where I'm wrong?

Thank you

AleeeKoi avatar Jul 01 '21 15:07 AleeeKoi

Do you have a full sample that I can run from the npm command line?

SurferJeffAtGoogle avatar Jul 01 '21 16:07 SurferJeffAtGoogle

Hi @SurferJeffAtGoogle , ok I try to fix a bit, but i can't share the whole code because there are other parts. Also you need to customize it by setting PATH_TO_JSON_CREDENTIALS_FILE and YOUR_PACKAGE_NAME with your configurations.

Thank you.

const androidpublisher = require('@googleapis/androidpublisher')

async function main () {

  const auth = new androidpublisher.auth.GoogleAuth({
    keyFilename: 'PATH_TO_JSON_CREDENTIALS_FILE',
    scopes: ['https://www.googleapis.com/auth/androidpublisher']
  })

  const authClient = await auth.getClient()
  
  const client = await androidpublisher.androidpublisher({
    version: 'v3',
    auth: authClient
  })
  
  const { data } = await client.inappproducts.list({
    packageName: 'YOUR_PACKAGE_NAME',
    maxResults: 1000
  })

  console.log(data.length)
}

main()

AleeeKoi avatar Jul 02 '21 07:07 AleeeKoi

Hi @SurferJeffAtGoogle forgive me, is there any good news? Thank you

AleeeKoi avatar Jul 05 '21 08:07 AleeeKoi

What do I set for YOUR_PACKAGE_NAME?

SurferJeffAtGoogle avatar Jul 20 '21 16:07 SurferJeffAtGoogle

@SurferJeffAtGoogle your android app package name.

AleeeKoi avatar Jul 20 '21 17:07 AleeeKoi

I don't have an android app package name.

SurferJeffAtGoogle avatar Jul 21 '21 21:07 SurferJeffAtGoogle

@tjohns, please help this user.

SurferJeffAtGoogle avatar Jul 21 '21 22:07 SurferJeffAtGoogle

@AleeeKoi the response from list should contain a variable tokenPagination, which you will then pass to subsequent calls to get the next page of results, setting maxResults does not have an effect.

bcoe avatar Oct 20 '21 14:10 bcoe