> ## Content Index
> Fetch the complete content index at: https://serpapi.com/blog/llms.txt
> Use this file to discover other available public pages before exploring further.

# Announcing our new library for JavaScript and TypeScript
- URL: https://serpapi.com/blog/announcing-our-new-library-for-javascript-and-typescript/
- Published: 2023-01-23T16:00:00.000Z
- Updated: 2025-12-15T22:51:30.000Z
- Description: TypeScript types, streamlined API functions, first-class Promises support, straightforward pagination and more. Available on npm and deno.land.
- Author: SerpApi
- Tags: #sebastian

We’re excited to release our new and improved library for JavaScript and TypeScript, `[serpapi](https://github.com/serpapi/serpapi-javascript)`!

SerpApi has grown to be so much more than just supporting Google Search. We support a wide range of search engines including Bing, Baidu, Yandex, Yahoo, Home Depot, eBay and many more. We’ve built this new library to not only reflect our continual commitment to creating *the* API for search engines, but to further improve your experience with SerpApi.

[GitHub](https://github.com/serpapi/serpapi-javascript) | [npm](https://www.npmjs.com/package/serpapi) | [deno.land](https://deno.land/x/serpapi)

## Highlights

- **TypeScript types.** Easily see what search parameters are supported for each search engine.
- **Streamlined API functions.** No instantiation of classes, simply import and call the functions to get the results you want quickly.
- **First-class Promises support.** Simplify your code by using async/await to retrieve search engine results with ease.
- **Straightforward pagination.** Spend less time figuring out how pagination works, just call `.next()` to retrieve the next page of results.
- **Works with Node.js and Deno.** Take your pick, we’ve published the library on [npm](https://www.npmjs.com/package/serpapi) and [deno.land](https://deno.land/x/serpapi).

## How to use it

Install the library using your preferred package manager:

```
npm install serpapi

```

Import `getJson`, specify the target engine and pass in your SerpApi API key. Get your API key from <https://serpapi.com/manage-api-key>.

```javascript
import { getJson } from "serpapi";
const response = await getJson("google", {
  api_key: API_KEY, // Get your API_KEY from https://serpapi.com/manage-api-key
  q: "coffee",
  location: "Austin, Texas",
});
console.log(response);

```

For Deno users, import directly from `deno.land` instead:

```typescript
import { getJson } from "https://deno.land/x/serpapi/mod.ts";

```

## How is this different from   
`google-search-results-nodejs`?

Other than the naming to better express support for many other search engines, we’ve re-worked it in several ways. These are taken from the [migration document](https://github.com/serpapi/serpapi-javascript/blob/master/docs/migrating%5Ffrom%5Fgoogle%5Fsearch%5Fresults%5Fnodejs.md) to help you upgrade and take advantage of the latest features.

### Use functions rather than classes

Our previous approach required importing and instantiating specific search engine classes. This made it difficult to maintain while we added support for more engines. To simplify things, this module exposes functions (`getJson`, `getHtml`) that accept an `engine` parameter instead.

```javascript
// ❌ Previous way.
import { GoogleSearch } from "google-search-results-nodejs";
const engine = new GoogleSearch(API_KEY);
engine.json(...);

// ✅ New way, import and use functions directly.
import { getJson } from "serpapi";
getJson("google", { api_key: API_KEY, ... })

```

### `search_archive` method has been replaced

We’ve replaced the `search_archive` method with `getJsonBySearchId` and `getHtmlBySearchId` to better express their purpose. These functions accept a `searchId` and return JSON/HTML.

```javascript
// ❌ Previous way, only supported JSON output.
engine.search_archive(searchId, console.log);

// ✅ New way, use `getJsonBySearchId`.
getJsonBySearchId(searchId, { api_key: API_KEY }, console.log);

// ✅ New way, use `getHtmlBySearchId` if you want the HTML result.
getHtmlBySearchId(searchId, { api_key: API_KEY }, console.log);

```

### `account` and `location` methods have been renamed

The `account` and `location` methods are now `getAccount` and `getLocations`. Previously, you had to call these methods from a search engine object. This was misleading since these functions are not tied to any specific engine.

```javascript
// ❌ Previous way, was part of the engine class.
engine.account(console.log);
engine.location("Austin", 5, console.log);

// ✅ New way, functions not tied to a class.
import { getAccount, getLocations } from "serpapi";
getAccount({ api_key: API_KEY }, console.log);
getLocations({ q: "Austin" }, console.log);

```

### New features

In addition to the changes above, we’ve exposed TypeScript types, added support for Promises, added support for pagination, added support for global config and exposed error classes. The library can be imported as an ES Module (ESM) or CommonJS module via npm or deno.land.

Behind the scenes, this module is written fully in TypeScript using Deno with a comprehensive test suite and an automated deployment pipeline.

## Still curious?

Check out the [](https://github.com/serpapi/serpapi-javascript)[GitHub](https://github.com/serpapi/serpapi-javascript) repository to take a deeper dive.

- **Want to see more examples?**  
Check out the [examples](https://github.com/serpapi/serpapi-javascript/tree/master/examples) folder or our recent blog posts such as [Web scraping The Home Depot Product Info with Nodejs](https://serpapi.com/blog/web-scraping-the-home-depot-product-info-with-nodejs/) and [Web scraping Apple App Store Product Info And Reviews with Nodejs](https://serpapi.com/blog/web-scraping-apple-app-store-product-info-and-reviews-with-nodejs/).
- **Want to see what functions can be used?**  
Check out the [functions section](https://github.com/serpapi/serpapi-javascript#functions) to get up to speed on what’s possible.
- **Want to get multiple page results easily?**  
Check out the [pagination section](https://github.com/serpapi/serpapi-javascript#pagination) to find out how to use the `.next()` method.
- **Want to set up your API key once?**  
Check out the [configuration section](https://github.com/serpapi/serpapi-javascript#configuration) to find out how to declare a global API key.
- **Saw something amiss and want to contribute?**  
Raise an issue and check out the [contributing guidelines](https://github.com/serpapi/serpapi-javascript/blob/master/CONTRIBUTING.md) to get started.