Skip to content

Commit

Permalink
serphouse-nodejs npm package
Browse files Browse the repository at this point in the history
  • Loading branch information
patoliya-dev authored and jjadhav-js committed May 7, 2024
1 parent bf0573d commit b29f227
Show file tree
Hide file tree
Showing 26 changed files with 1,459 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
env: {
browser: true,
es2021: true,
node: true,
},
extends: ["eslint:recommended"],
parserOptions: {
ecmaVersion: 12,
sourceType: "commonJs",
},
rules: {
"no-console": "off",
indent: ["error", 2],
"linebreak-style": ["error", "unix"],
quotes: ["error", "single"],
semi: ["error", "always"],
},
};
31 changes: 31 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: ESLint and Prettier Check

on:
push:
branches: [master]
pull_request:
branches: [master]
workflow_dispatch:

jobs:
lint:
name: ESLint and Prettier Check
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "16"

- name: Install dependencies
run: npm install

- name: Run ESLint
run: npm run lint

- name: Run Prettier
run: npx prettier --check prettierrc.js
28 changes: 28 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: run-tests

on:
push:
branches: ["master"]
pull_request:
branches: ["master"]
workflow_dispatch:

jobs:
run-tests:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "16"

- name: Install dependencies
run: npm install

- name: Run tests
run: npm test
env:
API_KEY: ${{ vars.API_KEY }}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/node_modules/
package-lock.json

# Avoid environment variables file
# .env
310 changes: 310 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,312 @@
# serphouse-nodejs

High Volume SERP API for SEO professionals and data scientist. We built reliable, accurate and cost efficient solution, We take cares of resolving captcha, managing proxy to ensure you get reliable Structured JSON data.

This API supported Serphouse's standard REST API that accepts/returns JSON requests. Here is the [API reference](https://docs.serphouse.com/)

##### It does supports EcmaScript 5, EcmaScript 6, EcmaScript 8, TypeScript, async-await, Promises, Callback!!!

##### It supports pure JSON response.

##### All methods support Promise and Callback both.

##### Please Feel free to create issue for any help!

##### Please make sure Test Cases be passed.

## Get started

Using the Serphouse API wrapper for Node.js is really simple.
Given that you already have a Node.js project with an NPM setup just follow these steps:

## Documentation

Documentation of Serphouse's API and their usage is available at [https://docs.serphouse.com/](https://docs.serphouse.com/)

## Prerequisites

Node version up to 14.21.3 to 20.9.0 for use
You need have node version between 14.21.3 to 20.9.0 for use package.

## Installation

```bash
npm install serphouse-nodejs --save
```

## Pull Request

- Contributors can send their Pull Request to `develop` branch.
- Kindly validate test cases before opening new PR.

## Get API Key From Using Below Link and Overview Details

[https://app.serphouse.com/register](https://app.serphouse.com/register)

## Configuration Using JavaScript

```bash
export SERPHOUSE_API_TOKEN=API_KEY

var serphouse = require("serphouse-nodejs")("YOUR_API_KEY");

OR

var SerphouseAPI = require("serphouse-nodejs");
var serphouse = new SerphouseAPI("YOUR_API_KEY");

OR

var SerphouseAPI = require("serphouse-nodejs");
var serphouse = new SerphouseAPI();
serphouse.setApiToken("YOUR_API_KEY");
```

## Configuration Using TypeScript

```js
import * as SerphouseAPI from "serphouse-nodejs";
var serphouse = new SerphouseAPI();
serphouse.setApiToken("YOUR_API_KEY");
```

## Examples

1. [SERP_API](#serp_api)

2. [DOMAINS](#domains)

3. [LANGUAGE](#language)

4. [LOCATIONS](#location)

5. [ACCOUNT](#account)

6. [TRENDS](#trends)

---

> ### [SERP_API](#examples)
```js
/** Performing a realtime search */
var payload = {
data: {
q: "Coffee",
domain: "google.com",
lang: "en",
device: "desktop",
serp_type: "web",
loc: "Alba,Texas,United States",
verbatim: 0,
postback_url: "https://webhook.site/8f885f1f-c38a-4a10-8506-335441213208",
page: 1,
num_result: 10,
},
path: { responseType: "json" },
};

try {
var response = await serphouse.SerpApi.live(payload);
} catch (error) {
return;
}
```

```js
/** Create a new schedule */
var payload = {
data: [
{
q: "Coffee",
domain: "google.com",
lang: "en",
device: "desktop",
serp_type: "web",
loc: "Alba,Texas,United States",
verbatim: 0,
postback_url: "https://webhook.site/8f885f1f-c38a-4a10-8506-335441213208",
page: 1,
num_result: 10,
},
],
};

try {
var response = await serphouse.SerpApi.schedule(payload);
} catch (error) {
return;
}
```

```js
/** You will get a status of your serp task */
var payload = { query: { id: 127105618 } };
try {
var response = await serphouse.SerpApi.check(payload);
} catch (error) {
return;
}
```

```js
/** you will receive an json array containing a result of your serp query */
var payload = {
query: { id: 127673427 },
path: { responseType: "html" }, // path is optional default get json
};
try {
var response = await serphouse.SerpApi.get(payload);
} catch (error) {
return;
}
```

---

> ### [DOMAINS](#examples)
```js
/** Get domains list */
try {
var response = await serphouse.Domains.list();
} catch (error) {
return;
}
```

---

> ### [LANGUAGE](#examples)
```js
/** Get list of languages by Google, Bing and Yahoo */
try {
const payload = { path: { type: "google" } }; // type can be google,bing,yahoo
var response = await serphouse.Languages.list();
} catch (error) {
return;
}
```

---

> ### [LOCATIONS](#examples)
```js
/** Get locations available for our SERP API */
try {
const payload = {
query: {
q: "india",
type: "google",
},
};
var response = await serphouse.Location.search(payload);
} catch (error) {
return;
}
```

---

> ### [ACCOUNT](#examples)
```js
/** Get your account information */
try {
var response = await serphouse.Account.fetch();
} catch (error) {
return;
}
```

> ### [TRENDS](#examples)
```js
/** Performing a realtime google trends search */
try {
var payload = {
time_zone_offset: -330,
keywords: "google,youtube",
time: "now 1-d",
};
var response = await serphouse.Trends.search(payload);
} catch (error) {
return;
}
```

```js
/** Create trend schedule */
try {
var payload = {
data: [
{
time_zone_offset: -330,
keywords: "google,youtube",
time: "now 1-d",
},
],
};
var response = await serphouse.Trends.schedule(payload);
} catch (error) {
return;
}
```

```js
/** Retrieve full list of timezone and its offset value */
try {
var response = await serphouse.Trends.timeZoneList();
} catch (error) {
return;
}
```

```js
/** Retrieve full list of categories and sub category */
try {
var response = await serphouse.Trends.categoryList();
} catch (error) {
return;
}
```

```js
/** Retrieve full list of country and state */
try {
var response = await serphouse.Trends.countryStateList();
} catch (error) {
return;
}
```

```js
/** Retrieve full list of language. */
try {
var response = await serphouse.Trends.languageList();
} catch (error) {
return;
}
```

```js
/** Get result of your trend search query. */
try {
var payload = { query: { id: 127105618 } };
var response = await serphouse.Trends.get(payload);
} catch (error) {
return;
}
```

```js
/** Check search status. */
try {
var payload = { query: { id: 127105618 } };
var response = await serphouse.Trends.check(payload);
} catch (error) {
return;
}
```
Loading

0 comments on commit b29f227

Please sign in to comment.