{"id":21130380,"url":"https://github.com/serpapi/serpapi-javascript","last_synced_at":"2025-07-09T01:33:24.179Z","repository":{"id":64497637,"uuid":"572882308","full_name":"serpapi/serpapi-javascript","owner":"serpapi","description":"Scrape and parse search engine results using SerpApi.","archived":false,"fork":false,"pushed_at":"2024-03-12T09:01:02.000Z","size":263,"stargazers_count":48,"open_issues_count":7,"forks_count":5,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-11-17T19:45:19.563Z","etag":null,"topics":["deno","javascript","json","nodejs","scraping","serp-api","serpapi","typescript","web-scraping-nodejs"],"latest_commit_sha":null,"homepage":"https://serpapi.com","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/serpapi.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-01T08:29:34.000Z","updated_at":"2024-09-29T23:26:20.000Z","dependencies_parsed_at":"2023-12-05T03:28:15.945Z","dependency_job_id":"979bfeaa-ad62-418b-bd6a-8858299f6a74","html_url":"https://github.com/serpapi/serpapi-javascript","commit_stats":{"total_commits":120,"total_committers":1,"mean_commits":120.0,"dds":0.0,"last_synced_commit":"db00ddac152d0eb8e3f9d70d81f0eac70380c4dd"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serpapi%2Fserpapi-javascript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serpapi%2Fserpapi-javascript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serpapi%2Fserpapi-javascript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serpapi%2Fserpapi-javascript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/serpapi","download_url":"https://codeload.github.com/serpapi/serpapi-javascript/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225476380,"owners_count":17480215,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deno","javascript","json","nodejs","scraping","serp-api","serpapi","typescript","web-scraping-nodejs"],"created_at":"2024-11-20T05:32:45.823Z","updated_at":"2024-11-20T05:32:47.778Z","avatar_url":"https://github.com/serpapi.png","language":"TypeScript","readme":"# SerpApi for JavaScript/TypeScript\n\n[![npm version](https://img.shields.io/npm/v/serpapi)](https://www.npmjs.com/package/serpapi)\n[![Deno version](https://deno.land/badge/serpapi/version)](https://deno.land/x/serpapi)\n[![Build status](https://github.com/serpapi/serpapi-javascript/workflows/Build/badge.svg?branch=master)](https://github.com/serpapi/serpapi-javascript/actions/workflows/build.yml)\n[![License](https://img.shields.io/github/license/serpapi/serpapi-javascript)](https://github.com/serpapi/serpapi-javascript/blob/master/LICENSE)\n[![SerpApi Libraries](https://img.shields.io/badge/SerpApi-Libraries-blue)](https://serpapi.com/integrations)\n\nScrape and parse search engine results using [SerpApi](https://serpapi.com). Get\nsearch results from Google, Bing, Baidu, Yandex, Yahoo, Home Depot, eBay and\nmore.\n\n| 🪧 Coming from `google-search-results-nodejs`? \u003cbr /\u003e Check out the [migration document](https://github.com/serpapi/serpapi-javascript/blob/master/docs/migrating_from_google_search_results_nodejs.md) to find out how to upgrade. |\n| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n\n## Quick start\n\n### Node.js\n\n- Supports Node.js 7.10.1 and newer.\n- Refer to\n  [this example](https://github.com/serpapi/serpapi-javascript/tree/master/examples/node/js_node_7_up)\n  for help.\n\n```bash\nnpm install serpapi\n```\n\n```js\nconst { getJson } = require(\"serpapi\");\ngetJson({\n  engine: \"google\",\n  api_key: API_KEY, // Get your API_KEY from https://serpapi.com/manage-api-key\n  q: \"coffee\",\n  location: \"Austin, Texas\",\n}, (json) =\u003e {\n  console.log(json[\"organic_results\"]);\n});\n```\n\n### Node.js with ES Modules (ESM) and top-level await\n\n- If you prefer using the `import` syntax and top-level `await`, you need to use\n  at least Node.js 14.8.0.\n- Refer to\n  [this example](https://github.com/serpapi/serpapi-javascript/tree/master/examples/node/js_node_14_up)\n  for help.\n\nYou will need to add `\"type\": \"module\"` to your `package.json`:\n\n```js\n{\n  \"type\": \"module\",\n  // rest of package.json\n}\n```\n\n```js\nimport { getJson } from \"serpapi\";\nconst response = await getJson({\n  engine: \"google\",\n  api_key: API_KEY, // Get your API_KEY from https://serpapi.com/manage-api-key\n  q: \"coffee\",\n  location: \"Austin, Texas\",\n});\nconsole.log(response);\n```\n\n### Deno\n\n- Import directly from deno.land.\n- Usage is otherwise the same as above.\n- Refer to\n  [this example](https://github.com/serpapi/serpapi-javascript/tree/master/examples/deno)\n  for help.\n\n```ts\nimport { getJson } from \"https://deno.land/x/serpapi/mod.ts\";\nconst response = await getJson({\n  engine: \"google\",\n  api_key: API_KEY, // Get your API_KEY from https://serpapi.com/manage-api-key\n  q: \"coffee\",\n  location: \"Austin, Texas\",\n});\nconsole.log(response);\n```\n\n## Features\n\n- TypeScript support.\n- Works out-of-the-box with [Node.js](https://www.npmjs.com/package/serpapi) and\n  [Deno](https://deno.land/x/serpapi).\n- Promises and async/await support.\n- Callbacks support.\n- [Examples in JavaScript/TypeScript on Node.js/Deno using ESM/CommonJS, and more](https://github.com/serpapi/serpapi-javascript/tree/master/examples).\n\n## Configuration\n\nYou can declare a global `api_key` and `timeout` value by modifying the `config`\nobject. `timeout` is defined in milliseconds and defaults to 60 seconds.\n\nAll functions, other than `getLocations`, accepts an optional `api_key` and\n`timeout` that will take precedence over the values defined in `config`.\n\n`getLocations` doesn't require an API key.\n\n```js\nimport { config, getJson } from \"serpapi\";\n\nconfig.api_key = API_KEY;\nconfig.timeout = 60000;\n\nawait getJson({ engine: \"google\", q: \"coffee\" }); // uses the API key defined in the config\nawait getJson({ engine: \"google\", api_key: API_KEY_2, q: \"coffee\" }); // API_KEY_2 will be used\n```\n\n## Pagination\n\nBuilt-in pagination is not supported. Please refer to our pagination examples\nfor a manual approach:\n\n- [Pagination example (Node.js \u003e= 7)](https://github.com/serpapi/serpapi-javascript/tree/master/examples/node/js_node_7_up/pagination_example.js)\n- [Pagination example (Node.js \u003e= 14)](https://github.com/serpapi/serpapi-javascript/tree/master/examples/node/js_node_14_up/pagination_example.js)\n- [Pagination example (Deno)](https://github.com/serpapi/serpapi-javascript/tree/master/examples/deno/pagination_example.ts)\n\n## Functions\n\n\u003c!-- Generated by documentation.js. Update this documentation by updating the source code. --\u003e\n\n#### Table of Contents\n\n- [getJson](#getjson)\n  - [Parameters](#parameters)\n  - [Examples](#examples)\n- [getHtml](#gethtml)\n  - [Parameters](#parameters-1)\n  - [Examples](#examples-1)\n- [getJsonBySearchId](#getjsonbysearchid)\n  - [Parameters](#parameters-2)\n  - [Examples](#examples-2)\n- [getHtmlBySearchId](#gethtmlbysearchid)\n  - [Parameters](#parameters-3)\n  - [Examples](#examples-3)\n- [getAccount](#getaccount)\n  - [Parameters](#parameters-4)\n  - [Examples](#examples-4)\n- [getLocations](#getlocations)\n  - [Parameters](#parameters-5)\n  - [Examples](#examples-5)\n\n### getJson\n\nGet a JSON response based on search parameters.\n\n#### Parameters\n\n- `parameters`\n  **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**\n  search query parameters for the engine\n- `callback` **fn?** optional callback\n\n#### Examples\n\n```javascript\n// single call (async/await)\nconst json = await getJson({ engine: \"google\", api_key: API_KEY, q: \"coffee\" });\n\n// single call (callback)\ngetJson({ engine: \"google\", api_key: API_KEY, q: \"coffee\" }, console.log);\n```\n\n### getHtml\n\nGet a HTML response based on search parameters.\n\n- Accepts an optional callback.\n- Responds with a JSON string if the search request hasn't completed.\n\n#### Parameters\n\n- `parameters`\n  **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**\n  search query parameters for the engine\n- `callback` **fn?** optional callback\n\n#### Examples\n\n```javascript\n// async/await\nconst html = await getHtml({ engine: \"google\", api_key: API_KEY, q: \"coffee\" });\n\n// callback\ngetHtml({ engine: \"google\", api_key: API_KEY, q: \"coffee\" }, console.log);\n```\n\n### getJsonBySearchId\n\nGet a JSON response given a search ID.\n\n- This search ID can be obtained from the `search_metadata.id` key in the\n  response.\n- Typically used together with the `async` parameter.\n- Accepts an optional callback.\n\n#### Parameters\n\n- `searchId`\n  **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**\n  search ID\n- `parameters`\n  **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**\n  (optional, default `{}`)\n\n  - `parameters.api_key`\n    **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?**\n    API key\n  - `parameters.timeout`\n    **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?**\n    timeout in milliseconds\n- `callback` **fn?** optional callback\n\n#### Examples\n\n```javascript\nconst response = await getJson({\n  engine: \"google\",\n  api_key: API_KEY,\n  async: true,\n  q: \"coffee\",\n});\nconst { id } = response.search_metadata;\nawait delay(1000); // wait for the request to be processed.\n\n// async/await\nconst json = await getJsonBySearchId(id, { api_key: API_KEY });\n\n// callback\ngetJsonBySearchId(id, { api_key: API_KEY }, console.log);\n```\n\n### getHtmlBySearchId\n\nGet a HTML response given a search ID.\n\n- This search ID can be obtained from the `search_metadata.id` key in the\n  response.\n- Typically used together with the `async` parameter.\n- Accepts an optional callback.\n- Responds with a JSON if the search request hasn't completed.\n\n#### Parameters\n\n- `searchId`\n  **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**\n  search ID\n- `parameters`\n  **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**\n  (optional, default `{}`)\n\n  - `parameters.api_key`\n    **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?**\n    API key\n  - `parameters.timeout`\n    **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?**\n    timeout in milliseconds\n- `callback` **fn?** optional callback\n\n#### Examples\n\n```javascript\nconst response = await getJson({\n  engine: \"google\",\n  api_key: API_KEY,\n  async: true,\n  q: \"coffee\",\n});\nconst { id } = response.search_metadata;\nawait delay(1000); // wait for the request to be processed.\n\n// async/await\nconst html = await getHtmlBySearchId(id, { api_key: API_KEY });\n\n// callback\ngetHtmlBySearchId(id, { api_key: API_KEY }, console.log);\n```\n\n### getAccount\n\nGet account information of an API key. \u003chttps://serpapi.com/account-api\u003e\n\n#### Parameters\n\n- `parameters`\n  **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**\n  (optional, default `{}`)\n\n  - `parameters.api_key`\n    **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?**\n    API key\n  - `parameters.timeout`\n    **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?**\n    timeout in milliseconds\n- `callback` **fn?** optional callback\n\n#### Examples\n\n```javascript\n// async/await\nconst info = await getAccount({ api_key: API_KEY });\n\n// callback\ngetAccount({ api_key: API_KEY }, console.log);\n```\n\n### getLocations\n\nGet supported locations. Does not require an API key.\n\u003chttps://serpapi.com/locations-api\u003e\n\n#### Parameters\n\n- `parameters`\n  **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**\n  (optional, default `{}`)\n\n  - `parameters.q`\n    **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?**\n    query for a location\n  - `parameters.limit`\n    **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?**\n    limit on number of locations returned\n  - `parameters.timeout`\n    **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?**\n    timeout in milliseconds\n- `callback` **fn?** optional callback\n\n#### Examples\n\n```javascript\n// async/await\nconst locations = await getLocations({ limit: 3 });\n\n// callback\ngetLocations({ limit: 3 }, console.log);\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserpapi%2Fserpapi-javascript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fserpapi%2Fserpapi-javascript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserpapi%2Fserpapi-javascript/lists"}