DEV Community

Mikhail Zub for SerpApi

Posted on

JavaScript SEO Keywords Research Tool: Google Autocomplete, People Also Ask, and People Also Search For

About

js-seo-keywords-generator is a Node.js package designed to generate keywords for SEO purposes. The package is available on npm and can be installed and used in your Node.js project or as CLI. It is used to generate keyword ideas using Google's Autocomplete, People also search and People also ask results and save them to TXT, CSV, JSON file. Scrape results were obtained using SerpApi.

Currently supports:

  • Google search
  • other engines soon.

image

Here's a simple user guide to help you get started with using js-seo-keywords-generator.

Installation

📌Note: If you want to use this tool for personal or commercial purposes, you must register on SerpApi and get your own API key (no credit card needed, free plan available). The default API key used is for informational purposes only.

Make sure you have Node.js installed on your computer.

If you want to use SEO Keywords generator as CLI and save results in a file, you need to install it globally:

npm i -g js-seo-keywords-generator
Enter fullscreen mode Exit fullscreen mode

If you want to get results from SEO Keywords generator in your Node.js app, you need to add it to your project dependency:

npm i js-seo-keywords-generator
Enter fullscreen mode Exit fullscreen mode

Before use, you need to define your API key from SerpApi. There are several ways to do this:

  • Add an environment variable API_KEY with your key. Read more how to add it in different systems;
  • Add your key directly in code: SEO.api_key = "your_api_key" (for in-code usage only).

CLI Usage

You can see available usage options by typing in the terminal:

seo help get
Enter fullscreen mode Exit fullscreen mode

Available arguments

  -e, --engine       Parameter defines the engine(s) of use. It can be set to "paa" (People Also Ask),
                                   "rs" (Related Searches), "ac" (Autocomplete), or in any combination, e.g.
                                   "paa,rs,ac" (default). (default: ["paa","rs","ac"])
  -d, --domain      Parameter defines the Google domain to use. It defaults to google.com. Head to the
                                   https://serpapi.com/google-domains for a full list of supported Google domains.
                                   (default: "google.com")
  -gl, --country     Parameter defines the country to use for the Google search. Head to the
                                   https://serpapi.com/google-countries for a full list of supported Google countries.
                                   (default: "us")
  -hl, --language   Parameter defines the language to use for the Google search. Head to the
                                   https://serpapi.com/google-languages for a full list of supported Google languages.
                                   (default: "en")
  -dl, --depth        Parameter defines the depth of disclosure of questions for People Also Ask (default:
                                   "1")
  -ft, --type           Parameter defines the type of file to save. (choices: "json", "txt", "csv", default:
                                   "json")
  -h, --help                       display help for command
Enter fullscreen mode Exit fullscreen mode

📌Note: You can use any of the available options in any combination. You can see the full description of each of them below.

Engines use example

To get results from all supported engines you need to use the app with no engine argument:

seo get <search  query>
Enter fullscreen mode Exit fullscreen mode

If you want to get results from one or two selected engines you need to define the --engine option (or short: -e) divided by a comma, e.g. paa, ac (People also ask and Autocomplete):

seo get <search  query> -e <engine(s)>
Enter fullscreen mode Exit fullscreen mode
  • paa - People Also Ask engine;
  • rs - Related Searches (People Also Search) engine;
  • ac - Autocomplete engine.

Use different Google domain, country and language

You can change the default google domain google.com to any of supported domains list by defining the --domain (-d) option:

seo get <search  query> -d <google domain>
Enter fullscreen mode Exit fullscreen mode

Also, you can change the default country us (United States) of the search using the --country (-gl) option and set it to any of supported country codes list:

seo get <search  query> -gl <country code>
Enter fullscreen mode Exit fullscreen mode

If you want to change the default language en (English) of the search, you need to use the --language (-hl) option and set it to any of supported language codes list:

seo get <search  query> -hl <language code>
Enter fullscreen mode Exit fullscreen mode

Available file types to save search results

The default file type to save search results is json. You can change it to txt or csv using the --type (-ft) option:

seo get <search  query> -ft <file type>
Enter fullscreen mode Exit fullscreen mode

What is the depth parameter? (only for People Also Ask results)

When you open People Also Ask result, it loads more results:

  • Default:

image

  • One of the results is open:

image

So if you open all initial results that was mean you see next-depth results.

The depth limit parameter can be set from 1 to 3. This limit is set because, for each depth value, the number of results returned grows exponentially, for example, if the number of results is 5 at each level, for a depth of 3, the total number of results will be equal 125.

Output example

  • Terminal output:

image

  • Saved file:
{
  "people_also_ask": [
    "Was ist ein Node in der IT?",
    "Für was brauche ich node js?",
    "Ist Node ein Framework?",
    "Wie installiere ich Node?",
    "Warum eine Bitcoin Node?",
    "Wer steuert den Bitcoin?",
    "Was ist ein Ethereum Node?",
    "Wie funktioniert eine Node?",
    "Was kostet eine Bitcoin Node?",
    "Welcher Coin wird Bitcoin ersetzen?",
    "Was ist der billigste Bitcoin?",
    "Was kostet 1 ganzer Bitcoin?",
    "Ist node js kostenlos?",
    "Was kann man mit Node-RED machen?",
    "Wer nutzt node js?",
    "Was macht ein NPM?",
    "Wie funktioniert eine Node?",
    "Was kostet eine Bitcoin Node?",
    "Was bringt ein Bitcoin Node?",
    "Wer hat den Bitcoin entwickelt?",
    "Was bringt es eine Node zu betreiben?",
    "Was macht ein Bitcoin Node?",
    "Was ist ein Ethereum Node?",
    "Wie funktioniert eine Node?",
    "Wer nutzt node js?",
    "Ist node js kostenlos?",
    "Wie funktioniert eine Node?",
    "Welche Datenbank für node js?",
    "Ist Node-RED kostenlos?",
    "Wie funktioniert eine Node?",
    "Was kann man alles mit Node-RED machen?",
    "Welches Betriebssystem für Node-RED?",
    "Ist node js kostenlos?",
    "Wie funktioniert eine Node?",
    "Was kann man mit Node-RED machen?",
    "Wer nutzt node js?"
  ],
  "related_searches": [
    "node übersetzung",
    "node crypto",
    "node lts",
    "node version check",
    "node update",
    "node.js tutorial",
    "node server",
    "node version manager"
  ]
}
Enter fullscreen mode Exit fullscreen mode

In-code Usage

Import SEO to your file:

import SEO from "seo-keywords";
Enter fullscreen mode Exit fullscreen mode

Available methods:

getAll(query[, domain[, country[, language[, depthlimit]]]])
getCustom(engines, query[, domain[, country[, language[, depthlimit]]]])
getPeopleAlsoAsk(query[, domain[, country[, language[, depthlimit]]]])
getRelatedSearch(query[, domain[, country[, language]]])
getAutocomplete(query[, domain[, country[, language]]])
Enter fullscreen mode Exit fullscreen mode
  • query - search query.
  • engines - parameter defines the engine(s) of use:
    • paa (People Also Ask)
    • rs (Related Searches)
    • ac (Autocomplete)
    • could be combined: paa, ac
  • domain - parameter defines the Google domain to use. Head to the Google domains page for a full list of supported Google domains. Default is google.com.
  • country - parameter defines the country to use for the Google search. Head to the Google countries page for a full list of supported Google countries. Default is us.
  • language - parameter defines the language to use for the Google search. Head to the Google languages page for a full list of supported Google languages. Default is en.
  • depthlimit - parameter defines the depth of disclosure of questions for People Also Ask. Default is 1 (Only for People Also Ask engine).

Engines use example

To get results from all supported engines you need to use getAll method:

(async () => {
  console.log(await SEO.getAll(query[, domain[, country[, language[, depthlimit]]]]));
})();
Enter fullscreen mode Exit fullscreen mode
  • query argument is required;
  • domain, country, language, and depthlimit are optional arguments.

If you want to get results from one or two selected engines you need to use getCustom method with the engines argument divided by a comma, e.g.paa, ac (Peaople also ask and Autocomplete):

(async () => {
  console.log(await SEO.getCustom(engines, query[, domain[, country[, language[, depthlimit]]]]));
})();
Enter fullscreen mode Exit fullscreen mode
  • engines argument is required;
    • paa - People Also Ask engine;
    • rs - Related Searches (People Also Search) engine;
    • ac - Autocomplete engine.
  • query argument is required;
  • domain, country, language, and depthlimit are optional arguments.

If you want to get results from only one engine you need to use getPeopleAlsoAsk, getRelatedSearch, or getAutocomplete methods:

(async () => {
  console.log(await SEO.ggetPeopleAlsoAsk(query[, domain[, country[, language[, depthlimit]]]]));
  console.log(await SEO.getRelatedSearch(query[, domain[, country[, language]]]));
  console.log(await SEO.getAutocomplete(query[, domain[, country[, language]]]));
})();
Enter fullscreen mode Exit fullscreen mode
  • query argument is required;
  • domain, country, language, and depthlimit are optional arguments.

Use different Google domain, country and language

You can change the default google domain google.com to any of supported domains list by adding a domain argument for any method.

Also, you can change the default country us (United States) of the search using the country argument and set it to any of supported country codes list.

If you want to change the default language en (English) of the search, you need to use the language argument and set it to any of supported language codes list.

What is the depth parameter? (only for People Also Ask results)

When you open People Also Ask result, it loads more results:

  • Default:

image

  • One of the results is open:

image

So if you open all initial results that was mean you see next-depth results.

The depth limit parameter can be set from 1 to 3. This limit is set because, for each depth value, the number of results returned grows exponentially, for example, if the number of results is 5 at each level, for a depth of 3, the total number of results will be equal 125.

Output example

{
  "people_also_ask": ["What exactly is a node?", "What is node used for?", "Why it is called node?", "Why is node better than Python?"],
  "related_searches": [
    "node js",
    "what is node in networking",
    "node plant",
    "node version",
    "node js documentation",
    "nodes meaning in human body",
    "how does node work?",
    "node js download"
  ],
  "autocomplete": ["node js", "nodes of ranvier", "node unblocker", "node js download", "node red", "node definition", "node-fetch", "node version"]
}
Enter fullscreen mode Exit fullscreen mode

If you want other functionality added to this demo project or if you want to see some other projects made with SerpApi, write me a message.


Join us on Twitter | YouTube

Add a Feature Request💫 or a Bug🐞

Top comments (1)

Collapse
 
vagatasa profile image
Vagatasa • Edited

Want to reconnect with long lost friends or find out someone's personal history? Check out radaris.de/p/Olga/Heymann/ - the ultimate people search engine! With powerful search capabilities, accessing current addresses and finding people has never been easier. Check out the rave reviews (including mine) in the special section to see for yourself. Whether you're looking for old classmates, former colleagues or distant relatives, it really helps. With a quick and comprehensive search, you will be able to reconnect with someone from your past in no time.