semrush-api-client 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,7 +1,63 @@
1
1
  # semrush-api
2
2
 
3
+ A Node.js/TypeScript client for accessing the SEMrush API easily.
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ npm install semrush-api-client
9
+ ```
10
+
11
+ ## Usage Example
12
+
13
+ First, set your SEMrush API key in your environment variables (e.g., in a `.env` file):
3
14
 
4
- ## Usage
5
15
  ```
6
- npm i semrush-api
16
+ SEMRUSH_API_KEY=your_api_key_here
7
17
  ```
18
+
19
+ Then, use the client in your code:
20
+
21
+ ```ts
22
+ import { SemrushAPIClient } from "semrush-api";
23
+ const client = new SemrushAPIClient({
24
+ api_key: process.env.SEMRUSH_API_KEY!,
25
+ });
26
+
27
+ // Get domain rank
28
+ client.getDomainRank({ domain: "apple.com" }).then((data) => {
29
+ console.log(data);
30
+ });
31
+
32
+ // Get keyword data
33
+ client.getPhrase({ phrase: "apple" }).then((data) => {
34
+ console.log(data);
35
+ });
36
+ ```
37
+
38
+ ## API Methods
39
+
40
+ ### `getDomainRank(options)`
41
+
42
+ Fetches ranking information for a specified domain.
43
+
44
+ - `domain` (string): Target domain
45
+ - `export_columns` (string[], optional): Columns to retrieve
46
+ - `database` (string, optional): Database (country code)
47
+ - `display_limit` (number, optional): Number of results
48
+
49
+ ### `getPhrase(options)`
50
+
51
+ Fetches information for a specified keyword.
52
+
53
+ - `phrase` (string): Keyword
54
+ - `export_columns` (string[], optional): Columns to retrieve
55
+ - `database` (string, optional): Database (country code)
56
+
57
+ ## Contributing
58
+
59
+ Contributions are welcome! Feel free to open issues or submit pull requests to improve this project.
60
+
61
+ ## License
62
+
63
+ See [LICENSE](LICENSE).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "semrush-api-client",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "license": "Apache-2.0",
@@ -1,29 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.SemrushAPIClient = void 0;
7
- const axios_1 = __importDefault(require("axios"));
8
- const getDomainRank_1 = require("../domain/getDomainRank");
9
- const getPhrase_1 = require("../keyword/getPhrase");
10
- class SemrushAPIClient {
11
- client;
12
- api_key;
13
- BASE_URL = "https://api.semrush.com/";
14
- constructor({ api_key }) {
15
- this.api_key = api_key;
16
- this.client = axios_1.default.create({
17
- baseURL: this.BASE_URL,
18
- timeout: 5000,
19
- });
20
- }
21
- async get(url, params) {
22
- const allParams = { ...params, key: this.api_key };
23
- const response = await this.client.get(url, { params: allParams });
24
- return response.data;
25
- }
26
- getDomainRank = getDomainRank_1.getDomainRank;
27
- getPhrase = getPhrase_1.getPhraseAll;
28
- }
29
- exports.SemrushAPIClient = SemrushAPIClient;
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getDomainRank = getDomainRank;
4
- async function getDomainRank({ domain, export_columns = ["Dn", "Or", "Rk", "Ot", "Oc"], database = "us", display_limit = 1000, }) {
5
- const params = {
6
- type: "domain_ranks",
7
- export_columns: export_columns.join(","),
8
- domain,
9
- database,
10
- display_limit,
11
- };
12
- return this.get("", params);
13
- }
package/dist/index.js DELETED
@@ -1,22 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- var __importDefault = (this && this.__importDefault) || function (mod) {
17
- return (mod && mod.__esModule) ? mod : { "default": mod };
18
- };
19
- Object.defineProperty(exports, "__esModule", { value: true });
20
- const dotenv_1 = __importDefault(require("dotenv"));
21
- dotenv_1.default.config();
22
- __exportStar(require("./client"), exports);
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPhraseAll = getPhraseAll;
4
- async function getPhraseAll({ phrase, export_columns = ["Dt", "Db", "Ph", "Nq", "Cp", "Co", "Nr"], database = "us", }) {
5
- const params = {
6
- type: "phrase_all",
7
- export_columns: export_columns.join(","),
8
- phrase,
9
- database,
10
- };
11
- return this.get("", params);
12
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });