Search code examples
javascriptnode.jselectrongoogle-custom-search

search page number - Google custom search API


I m using Google custom search API to fetch some images. Everything is working fine but all my queries result in the same result. Can i use some kind of page number of the starting point of my search or something else to get different images for the same keyword. (eg. "plane").

Here is my code,

async function imgRequest(options, arrayImg) {
    const res = await customsearch.cse.list({
        cx: "-----",
        q: "plane",
        auth: "-----",
        searchType: "image"
    });
    console.log(res.data.items[0].link);
    return res.data;
}

Thanks in advance. Feel free to ask any questions.


Solution

  • There is a 'start' parameter: "The index of the first result to return"

    See https://developers.google.com/custom-search/json-api/v1/reference/cse/list