semrush-api-client 0.1.6 → 0.1.8

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.
@@ -23,5 +23,5 @@ async function backlinksOverview({ target, target_type = "domain", export_column
23
23
  target_type,
24
24
  export_columns: export_columns.join(","),
25
25
  };
26
- return this.get(this.ANALYTICS_URL, params, outputObj);
26
+ return this.get(this.ANALYTICS_URL + "v1/", params, outputObj);
27
27
  }
@@ -1,9 +1,13 @@
1
1
  import { getDomainOverview } from "../overview/getDomainOverview";
2
- import { getPhraseAll } from "../keyword/getPhrase";
2
+ import { getKeywordOverview } from "../keyword/getKeywordOverview";
3
3
  import { backlinksOverview } from "../backlinks/backlinksOverview";
4
4
  import { getRankDifference } from "../overview/getRankDifference";
5
5
  import { getDomainOrganic } from "../domain/getDomainOrganic";
6
+ import { getDomainPaidSearchKeywords } from "../domain/getDomainPaidSearchKeywords";
7
+ import { getAdsCopies } from "../domain/getAdsCopies";
8
+ import { getTrafficSummary } from "../trend/getTrafficSummary";
6
9
  import { getSemrushRank } from "../overview/getSemrushRank";
10
+ import { getKeywordDifficulty } from "../keyword/getKeywordDifficulty";
7
11
  export declare class SemrushAPIClient {
8
12
  private client;
9
13
  private api_key;
@@ -15,9 +19,13 @@ export declare class SemrushAPIClient {
15
19
  parseCsvToObjects(csvString: string, delimiter?: string): Record<string, string>[];
16
20
  get<T>(url: string, params?: Record<string, any>, outputObj?: boolean): Promise<T>;
17
21
  getDomainOverview: typeof getDomainOverview;
18
- getPhrase: typeof getPhraseAll;
22
+ getKeywordOverview: typeof getKeywordOverview;
19
23
  backlinksOverview: typeof backlinksOverview;
20
24
  getRankDifference: typeof getRankDifference;
21
25
  getSemrushRank: typeof getSemrushRank;
22
26
  getDomainOrganic: typeof getDomainOrganic;
27
+ getDomainPaidSearchKeywords: typeof getDomainPaidSearchKeywords;
28
+ getAdsCopies: typeof getAdsCopies;
29
+ getTrafficSummary: typeof getTrafficSummary;
30
+ getKeywordDifficulty: typeof getKeywordDifficulty;
23
31
  }
@@ -6,20 +6,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.SemrushAPIClient = void 0;
7
7
  const axios_1 = __importDefault(require("axios"));
8
8
  const getDomainOverview_1 = require("../overview/getDomainOverview");
9
- const getPhrase_1 = require("../keyword/getPhrase");
9
+ const getKeywordOverview_1 = require("../keyword/getKeywordOverview");
10
10
  const backlinksOverview_1 = require("../backlinks/backlinksOverview");
11
11
  const getRankDifference_1 = require("../overview/getRankDifference");
12
12
  const getDomainOrganic_1 = require("../domain/getDomainOrganic");
13
+ const getDomainPaidSearchKeywords_1 = require("../domain/getDomainPaidSearchKeywords");
14
+ const getAdsCopies_1 = require("../domain/getAdsCopies");
15
+ const getTrafficSummary_1 = require("../trend/getTrafficSummary");
13
16
  const getSemrushRank_1 = require("../overview/getSemrushRank");
17
+ const getKeywordDifficulty_1 = require("../keyword/getKeywordDifficulty");
14
18
  class SemrushAPIClient {
15
19
  client;
16
20
  api_key;
17
21
  BASE_URL = "https://api.semrush.com/";
18
- ANALYTICS_URL = "https://api.semrush.com/analytics/v1/";
22
+ ANALYTICS_URL = "https://api.semrush.com/analytics/";
19
23
  constructor({ api_key }) {
20
24
  this.api_key = api_key;
21
25
  this.client = axios_1.default.create({
22
- timeout: 10000,
26
+ timeout: 14000,
23
27
  });
24
28
  }
25
29
  parseCsvToObjects(csvString, delimiter = ";") {
@@ -57,10 +61,14 @@ class SemrushAPIClient {
57
61
  }
58
62
  }
59
63
  getDomainOverview = getDomainOverview_1.getDomainOverview;
60
- getPhrase = getPhrase_1.getPhraseAll;
64
+ getKeywordOverview = getKeywordOverview_1.getKeywordOverview;
61
65
  backlinksOverview = backlinksOverview_1.backlinksOverview;
62
66
  getRankDifference = getRankDifference_1.getRankDifference;
63
67
  getSemrushRank = getSemrushRank_1.getSemrushRank;
64
68
  getDomainOrganic = getDomainOrganic_1.getDomainOrganic;
69
+ getDomainPaidSearchKeywords = getDomainPaidSearchKeywords_1.getDomainPaidSearchKeywords;
70
+ getAdsCopies = getAdsCopies_1.getAdsCopies;
71
+ getTrafficSummary = getTrafficSummary_1.getTrafficSummary;
72
+ getKeywordDifficulty = getKeywordDifficulty_1.getKeywordDifficulty;
65
73
  }
66
74
  exports.SemrushAPIClient = SemrushAPIClient;
@@ -0,0 +1,11 @@
1
+ import { SemrushAPIClient } from "../client";
2
+ import { Database } from "../type/general/database";
3
+ type ExportColumns = "Tt" | "Ds" | "Vu" | "Ur" | "Pc" | "Un";
4
+ export declare function getAdsCopies(this: SemrushAPIClient, { domain, export_columns, database, display_limit, outputObj, }: {
5
+ domain: string;
6
+ export_columns?: ExportColumns[];
7
+ database?: Database;
8
+ outputObj?: boolean;
9
+ display_limit?: number;
10
+ }): Promise<string>;
11
+ export {};
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAdsCopies = getAdsCopies;
4
+ async function getAdsCopies({ domain, export_columns = ["Tt", "Ds", "Vu", "Ur", "Pc", "Un"], database = "us", display_limit = 1000, outputObj = true, }) {
5
+ const params = {
6
+ type: "domain_adwords_unique",
7
+ export_columns: export_columns.join(","),
8
+ domain,
9
+ database,
10
+ display_limit,
11
+ };
12
+ return this.get(this.BASE_URL, params, outputObj);
13
+ }
@@ -1,12 +1,12 @@
1
1
  import { SemrushAPIClient } from "../client";
2
2
  import { Database } from "../type/general/database";
3
3
  type ExportColumns = "Ph" | "Po" | "Pp" | "Pd" | "Nq" | "Cp" | "Ur" | "Tr" | "Tg" | "Tc" | "Co" | "Nr" | "Td" | "Kd" | "Fp" | "Fk" | "Ts" | "In" | "Pt";
4
- type displayPostions = "new" | "lost" | "rise" | "fall";
4
+ type displayPositions = "new" | "lost" | "rise" | "fall";
5
5
  type displayPositionType = "organic" | "all" | "serp_features";
6
6
  export declare function getDomainOrganic(this: SemrushAPIClient, { domain, export_columns, database, displayPosition, displayPositionsType, display_limit, outputObj, }: {
7
7
  domain: string;
8
8
  export_columns?: ExportColumns[];
9
- displayPosition?: displayPostions;
9
+ displayPosition?: displayPositions;
10
10
  database?: Database;
11
11
  outputObj?: boolean;
12
12
  displayPositionsType?: displayPositionType;
@@ -0,0 +1,13 @@
1
+ import { SemrushAPIClient } from "../client";
2
+ import { Database } from "../type/general/database";
3
+ type ExportColumns = "Ph" | "Po" | "Pp" | "Pd" | "Ab" | "Nq" | "Cp" | "Ur" | "Tr" | "Tg" | "Tc" | "Co" | "Nr" | "Td" | "Tt" | "Ds" | "Vu" | "Ur" | "Ts" | "Un";
4
+ type displayPositions = "new" | "lost" | "rise" | "fall";
5
+ export declare function getDomainPaidSearchKeywords(this: SemrushAPIClient, { domain, export_columns, database, displayPosition, display_limit, outputObj, }: {
6
+ domain: string;
7
+ export_columns?: ExportColumns[];
8
+ displayPosition?: displayPositions;
9
+ database?: Database;
10
+ outputObj?: boolean;
11
+ display_limit?: number;
12
+ }): Promise<string>;
13
+ export {};
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getDomainPaidSearchKeywords = getDomainPaidSearchKeywords;
4
+ async function getDomainPaidSearchKeywords({ domain, export_columns = [
5
+ "Ph",
6
+ "Po",
7
+ "Pp",
8
+ "Pd",
9
+ "Nq",
10
+ "Cp",
11
+ "Vu",
12
+ "Tr",
13
+ "Tc",
14
+ "Co",
15
+ "Nr",
16
+ "Td",
17
+ ], database = "us", displayPosition, display_limit = 1000, outputObj = true, }) {
18
+ const params = {
19
+ type: "domain_adwords",
20
+ export_columns: export_columns.join(","),
21
+ domain,
22
+ database,
23
+ display_position: displayPosition,
24
+ display_limit,
25
+ };
26
+ return this.get(this.BASE_URL, params, outputObj);
27
+ }
@@ -0,0 +1,10 @@
1
+ import { SemrushAPIClient } from "../client";
2
+ import { Database } from "../type/general/database";
3
+ type ExportColumns = "Ph" | "Kd";
4
+ export declare function getKeywordDifficulty(this: SemrushAPIClient, { phrases, export_columns, database, outputObj, }: {
5
+ phrases: string[];
6
+ export_columns?: ExportColumns[];
7
+ database?: Database;
8
+ outputObj?: boolean;
9
+ }): Promise<string>;
10
+ export {};
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getKeywordDifficulty = getKeywordDifficulty;
4
+ async function getKeywordDifficulty({ phrases, export_columns = ["Ph", "Kd"], database = "us", outputObj = true, // Default to true for output object
5
+ }) {
6
+ const params = {
7
+ type: "phrase_kdi",
8
+ export_columns: export_columns.join(","),
9
+ phrase: phrases.join(";"),
10
+ database,
11
+ };
12
+ return this.get(this.BASE_URL, params, outputObj);
13
+ }
@@ -1,7 +1,7 @@
1
1
  import { SemrushAPIClient } from "../client";
2
2
  import { Database } from "../type/general/database";
3
3
  type KeywordExportColumns = "Dt" | "Db" | "Ph" | "Nq" | "Cp" | "Co" | "Nr" | "In" | "Kd";
4
- export declare function getPhraseAll(this: SemrushAPIClient, { phrase, export_columns, database, outputObj, }: {
4
+ export declare function getKeywordOverview(this: SemrushAPIClient, { phrase, export_columns, database, outputObj, }: {
5
5
  phrase: string;
6
6
  export_columns?: KeywordExportColumns[];
7
7
  database?: Database;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
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", outputObj = true, // Default to true for output object
3
+ exports.getKeywordOverview = getKeywordOverview;
4
+ async function getKeywordOverview({ phrase, export_columns = ["Dt", "Db", "Ph", "Nq", "Cp", "Co", "Nr"], database = "us", outputObj = true, // Default to true for output object
5
5
  }) {
6
6
  const params = {
7
7
  type: "phrase_all",
@@ -0,0 +1,9 @@
1
+ import { SemrushAPIClient } from "../client";
2
+ import { Country } from "../type/general/country";
3
+ export type ExportColumns = "target" | "rank" | "visits" | "categories" | "desktop_visits" | "mobile_visits" | "users" | "desktop_users" | "mobile_users" | "direct" | "referral" | "social" | "search" | "paid" | "search_organic" | "search_paid" | "social_organic" | "social_paid" | "mail" | "display_ad" | "unknown_channel" | "time_on_site" | "desktop_time_on_site" | "mobile_time_on_site" | "pages_per_visit" | "desktop_pages_per_visit" | "mobile_pages_per_visit" | "bounce_rate" | "desktop_bounce_rate" | "mobile_bounce_rate" | "desktop_share" | "mobile_share" | "accuracy" | "display_date" | "country" | "device_type" | "desktop_hits" | "mobile_hits";
4
+ export declare function getTrafficSummary(this: SemrushAPIClient, { domains, export_columns, country, outputObj, }: {
5
+ domains: string[];
6
+ export_columns?: ExportColumns[];
7
+ country?: Country;
8
+ outputObj?: boolean;
9
+ }): Promise<string>;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getTrafficSummary = getTrafficSummary;
4
+ function getTrafficSummary({ domains, export_columns = ["target", "visits", "users"], country, outputObj = true, // Default to true for output object
5
+ }) {
6
+ const params = {
7
+ targets: domains.join(","),
8
+ export_columns: export_columns.join(","),
9
+ country: country,
10
+ };
11
+ return this.get(this.ANALYTICS_URL + "ta/api/v3/summary", params, outputObj);
12
+ }
@@ -0,0 +1 @@
1
+ export type Country = "AD" | "AE" | "AF" | "AG" | "AI" | "AL" | "AM" | "AN" | "AO" | "AQ" | "AR" | "AS" | "AT" | "AU" | "AW" | "AX" | "AZ" | "BA" | "BB" | "BD" | "BE" | "BF" | "BG" | "BH" | "BI" | "BJ" | "BL" | "BM" | "BN" | "BO" | "BQ" | "BR" | "BS" | "BT" | "BV" | "BW" | "BY" | "BZ" | "CA" | "CC" | "CD" | "CF" | "CG" | "CH" | "CI" | "CK" | "CL" | "CM" | "CN" | "CO" | "CR" | "CU" | "CV" | "CW" | "CX" | "CY" | "CZ" | "DE" | "DJ" | "DK" | "DM" | "DO" | "DZ" | "EC" | "EE" | "EG" | "EH" | "ER" | "ES" | "ET" | "FI" | "FJ" | "FK" | "FM" | "FO" | "FR" | "GA" | "GB" | "GD" | "GE" | "GF" | "GG" | "GH" | "GI" | "GL" | "GM" | "GN" | "GP" | "GQ" | "GR" | "GS" | "GT" | "GU" | "GW" | "GY" | "HK" | "HM" | "HN" | "HR" | "HT" | "HU" | "ID" | "IE" | "IL" | "IM" | "IN" | "IO" | "IQ" | "IR" | "IS" | "IT" | "JE" | "JM" | "JO" | "JP" | "KE" | "KG" | "KH" | "KI" | "KM" | "KN" | "KP" | "KR" | "KW" | "KY" | "KZ" | "LA" | "LB" | "LC" | "LI" | "LK" | "LR" | "LS" | "LT" | "LU" | "LV" | "LY" | "MA" | "MC" | "MD" | "ME" | "MF" | "MG" | "MH" | "MK" | "ML" | "MM" | "MN" | "MO" | "MP" | "MQ" | "MR" | "MS" | "MT" | "MU" | "MV" | "MW" | "MX" | "MY" | "MZ" | "NA" | "NC" | "NE" | "NF" | "NG" | "NI" | "NL" | "NO" | "NP" | "NR" | "NU" | "NZ" | "OM" | "PA" | "PE" | "PF" | "PG" | "PH" | "PK" | "PL" | "PM" | "PN" | "PR" | "PS" | "PT" | "PW" | "PY" | "QA" | "RE" | "RO" | "RS" | "RU" | "RW" | "SA" | "SB" | "SC" | "SD" | "SE" | "SG" | "SH" | "SI" | "SJ" | "SK" | "SL" | "SM" | "SN" | "SO" | "SR" | "SS" | "ST" | "SV" | "SX" | "SY" | "SZ" | "TC" | "TD" | "TF" | "TG" | "TH" | "TJ" | "TK" | "TL" | "TM" | "TN" | "TO" | "TR" | "TT" | "TV" | "TW" | "TZ" | "UA" | "UG" | "UM" | "US" | "UY" | "UZ" | "VA" | "VC" | "VE" | "VG" | "VI" | "VN" | "VU" | "WF" | "WS" | "XK" | "YE" | "YT" | "ZA" | "ZM" | "ZW";
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "semrush-api-client",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
8
+ "homepage": "https://github.com/RenKoya1/semrush-api-client",
8
9
  "exports": {
9
10
  ".": {
10
11
  "import": "./dist/index.js",
@@ -18,7 +19,10 @@
18
19
  "engines": {
19
20
  "node": "20"
20
21
  },
21
- "keywords": [],
22
+ "keywords": [
23
+ "semrush",
24
+ "api"
25
+ ],
22
26
  "author": "",
23
27
  "type": "commonjs",
24
28
  "dependencies": {