dataforseo-client 2.0.22 → 2.0.23

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 dataforseo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,154 +1,154 @@
1
- ## OVERVIEW
2
-
3
- This is a TypeScript client providing you, as a developer, with a tool for obtaining the necessary data from DataForSEO APIs. You don't have to figure out how to make a request and process a response - all that is readily available in this client.
4
-
5
- [![GitHub issues](https://img.shields.io/github/issues/dataforseo/TypeScriptClient.svg)](https://github.com/dataforseo/TypeScriptClient/issues)
6
- [![GitHub license](https://img.shields.io/github/license/dataforseo/TypeScriptClient.svg)](https://github.com/dataforseo/TypeScriptClient)
7
-
8
- DataForSEO API uses REST technology for interchanging data between your application and our service. The data exchange is made through the widely used HTTP protocol, which allows using our API with almost any programming language.
9
-
10
- Client contains 12 sections (aka APIs):
11
-
12
- - AI Optimization API ([source docs](https://github.com/dataforseo/PythonClient/blob/master/docs/AiOptimizationApi.md) | [api docs](https://docs.dataforseo.com/v3/ai_optimization/overview/))
13
- - SERP ([source docs](https://github.com/dataforseo/TypeScriptClient/tree/master/docs/SerpApi.md) | [api docs](https://docs.dataforseo.com/v3/serp/overview/?bash))
14
- - Keywords Data ([source docs](https://github.com/dataforseo/TypeScriptClient/tree/master/docs/KeywordsDataApi.md) | [api docs](https://docs.dataforseo.com/v3/keywords_data/overview/?bash))
15
- - Domain Analytics ([source docs](https://github.com/dataforseo/TypeScriptClient/tree/master/docs/DomainAnalyticsApi.md) | [api docs](https://docs.dataforseo.com/v3/domain_analytics/overview/?bash))
16
- - DataForSEO Labs ([source docs](https://github.com/dataforseo/TypeScriptClient/tree/master/docs/DataforseoLabsApi.md) | [api docs](https://docs.dataforseo.com/v3/dataforseo_labs/overview/?bash))
17
- - Backlinks ([source docs](https://github.com/dataforseo/TypeScriptClient/tree/master/docs/BacklinksApi.md) | [api docs](https://docs.dataforseo.com/v3/backlinks/overview/?bash))
18
- - OnPage ([source docs](https://github.com/dataforseo/TypeScriptClient/tree/master/docs/OnPageApi.md) | [api docs](https://docs.dataforseo.com/v3/on_page/overview/?bash))
19
- - Content Analysis ([source docs](https://github.com/dataforseo/TypeScriptClient/tree/master/docs/ContentAnalysisApi.md) | [api docs](https://docs.dataforseo.com/v3/content_analysis/overview/?bash))
20
- - Content Generation ([source docs](https://github.com/dataforseo/TypeScriptClient/tree/master/docs/ContentGenerationApi.md) | [api docs](https://docs.dataforseo.com/v3/content_generation/overview/?bash))
21
- - Merchant ([source docs](https://github.com/dataforseo/TypeScriptClient/tree/master/docs/MerchantApi.md) | [api docs](https://docs.dataforseo.com/v3/merchant/overview/?bash))
22
- - App Data ([source docs](https://github.com/dataforseo/TypeScriptClient/tree/master/docs/AppDataApi.md) | [api docs](https://docs.dataforseo.com/v3/app_data/overview/?bash))
23
- - Business Data ([source docs](https://github.com/dataforseo/TypeScriptClient/tree/master/docs/BusinessDataApi.md) | [api docs](https://docs.dataforseo.com/v3/business_data/overview/?bash))
24
- - Appendix ([source docs](https://github.com/dataforseo/TypeScriptClient/tree/master/docs/AppendixApi.md) | [api docs](https://docs.dataforseo.com/v3/appendix/user_data/?bash))
25
-
26
- API Contains 2 types of requests:
27
-
28
- 1) Live (Simple HTTP request/response message)
29
- 2) Task-based (Requires sending a 'Task' entity to execute, waiting until the 'Task' status is ready, and getting the 'Task' result in a special endpoint. Usually, it is represented by 3 types of endpoints: 'TaskPost', 'TaskReady', and 'TaskGet')
30
-
31
- For more details, please follow [here](https://docs.dataforseo.com/v3/?bash)
32
-
33
- ## YAML Spec
34
-
35
- Our API description is based on the OpenAPI [syntax](https://spec.openapis.org/oas/v3.1.0) in YAML format. The YAML file is attached to the project [here](https://github.com/dataforseo/OpenApiDocumentation)
36
-
37
- ## Documentation
38
-
39
- The documentation for code objects, formatted in Markdown (.md) is available [here](https://github.com/dataforseo/TypeScriptClient/tree/master/docs). Official documentation for DataForSEO API is available [here](https://docs.dataforseo.com/v3/?bash).
40
-
41
- ## Code generation
42
-
43
- Code generated using the [NSwag lib](https://github.com/RicoSuter/NSwag)
44
-
45
- ## Install package from npm
46
-
47
- ```bash
48
- npm install dataforseo-client
49
- ```
50
-
51
- ## Examples of usage
52
-
53
- Example of live request
54
- ```typescript
55
- import * as client from 'dataforseo-client'
56
-
57
- async function main() {
58
-
59
- const username = 'username';
60
- const password = 'password';
61
-
62
- const authFetch = createAuthenticatedFetch(username, password);
63
- let serpApi = new client.SerpApi("https://api.dataforseo.com", { fetch: authFetch });
64
-
65
- let task = new client.SerpGoogleOrganicLiveAdvancedRequestInfo();
66
- task.location_code = 2840;
67
- task.language_code = "en";
68
- task.keyword = "albert einstein"
69
-
70
- let resp = await serpApi.googleOrganicLiveAdvanced([task]);
71
- }
72
-
73
- function createAuthenticatedFetch(username: string, password: string) {
74
- return (url: RequestInfo, init?: RequestInit): Promise<Response> => {
75
- const token = btoa(`${username}:${password}`);
76
- const authHeader = { 'Authorization': `Basic ${token}` };
77
-
78
- const newInit: RequestInit = {
79
- ...init,
80
- headers: {
81
- ...init?.headers,
82
- ...authHeader
83
- }
84
- };
85
-
86
- return fetch(url, newInit);
87
- };
88
- }
89
-
90
- main();
91
- ```
92
-
93
- Example of Task based endpoint
94
- ```typescript
95
- import * as client from 'dataforseo-client'
96
-
97
- async function main() {
98
-
99
- const username = 'username';
100
- const password = 'password';
101
-
102
- const authFetch = createAuthenticatedFetch(username, password);
103
- let serpApi = new client.SerpApi("https://api.dataforseo.com", { fetch: authFetch });
104
-
105
- let task = new client.SerpTaskRequestInfo();
106
- task.location_code = 2840;
107
- task.language_code = "en";
108
- task.keyword = "albert einstein"
109
-
110
- let taskResponse = await serpApi.googleOrganicTaskPost([task])
111
-
112
- let taskID = taskResponse.tasks[0].id;
113
- const startTime = Date.now();
114
-
115
- while (!await isReady(serpApi, taskID) && Date.now() - startTime < 60000) {
116
- await new Promise(resolve => setTimeout(resolve, 1000));
117
- }
118
-
119
- let resp = await serpApi.googleOrganicTaskGetAdvanced(taskID);
120
- }
121
-
122
- async function isReady(serpApi: client.SerpApi, id: string): Promise<boolean> {
123
- let resp = await serpApi.googleOrganicTasksReady();
124
-
125
- let isReadyId = false;
126
-
127
- resp.tasks.forEach(x => {
128
- if (x.id == id) {
129
- isReadyId = true;
130
- }
131
- });
132
-
133
- return isReadyId;
134
- }
135
-
136
- function createAuthenticatedFetch(username: string, password: string) {
137
- return (url: RequestInfo, init?: RequestInit): Promise<Response> => {
138
- const token = btoa(`${username}:${password}`);
139
- const authHeader = { 'Authorization': `Basic ${token}` };
140
-
141
- const newInit: RequestInit = {
142
- ...init,
143
- headers: {
144
- ...init?.headers,
145
- ...authHeader
146
- }
147
- };
148
-
149
- return fetch(url, newInit);
150
- };
151
- }
152
-
153
- main();
154
- ```
1
+ ## OVERVIEW
2
+
3
+ This is a TypeScript client providing you, as a developer, with a tool for obtaining the necessary data from DataForSEO APIs. You don't have to figure out how to make a request and process a response - all that is readily available in this client.
4
+
5
+ [![GitHub issues](https://img.shields.io/github/issues/dataforseo/TypeScriptClient.svg)](https://github.com/dataforseo/TypeScriptClient/issues)
6
+ [![GitHub license](https://img.shields.io/github/license/dataforseo/TypeScriptClient.svg)](https://github.com/dataforseo/TypeScriptClient)
7
+
8
+ DataForSEO API uses REST technology for interchanging data between your application and our service. The data exchange is made through the widely used HTTP protocol, which allows using our API with almost any programming language.
9
+
10
+ Client contains 12 sections (aka APIs):
11
+
12
+ - AI Optimization API ([source docs](https://github.com/dataforseo/PythonClient/blob/master/docs/AiOptimizationApi.md) | [api docs](https://docs.dataforseo.com/v3/ai_optimization/overview/))
13
+ - SERP ([source docs](https://github.com/dataforseo/TypeScriptClient/tree/master/docs/SerpApi.md) | [api docs](https://docs.dataforseo.com/v3/serp/overview/?bash))
14
+ - Keywords Data ([source docs](https://github.com/dataforseo/TypeScriptClient/tree/master/docs/KeywordsDataApi.md) | [api docs](https://docs.dataforseo.com/v3/keywords_data/overview/?bash))
15
+ - Domain Analytics ([source docs](https://github.com/dataforseo/TypeScriptClient/tree/master/docs/DomainAnalyticsApi.md) | [api docs](https://docs.dataforseo.com/v3/domain_analytics/overview/?bash))
16
+ - DataForSEO Labs ([source docs](https://github.com/dataforseo/TypeScriptClient/tree/master/docs/DataforseoLabsApi.md) | [api docs](https://docs.dataforseo.com/v3/dataforseo_labs/overview/?bash))
17
+ - Backlinks ([source docs](https://github.com/dataforseo/TypeScriptClient/tree/master/docs/BacklinksApi.md) | [api docs](https://docs.dataforseo.com/v3/backlinks/overview/?bash))
18
+ - OnPage ([source docs](https://github.com/dataforseo/TypeScriptClient/tree/master/docs/OnPageApi.md) | [api docs](https://docs.dataforseo.com/v3/on_page/overview/?bash))
19
+ - Content Analysis ([source docs](https://github.com/dataforseo/TypeScriptClient/tree/master/docs/ContentAnalysisApi.md) | [api docs](https://docs.dataforseo.com/v3/content_analysis/overview/?bash))
20
+ - Content Generation ([source docs](https://github.com/dataforseo/TypeScriptClient/tree/master/docs/ContentGenerationApi.md) | [api docs](https://docs.dataforseo.com/v3/content_generation/overview/?bash))
21
+ - Merchant ([source docs](https://github.com/dataforseo/TypeScriptClient/tree/master/docs/MerchantApi.md) | [api docs](https://docs.dataforseo.com/v3/merchant/overview/?bash))
22
+ - App Data ([source docs](https://github.com/dataforseo/TypeScriptClient/tree/master/docs/AppDataApi.md) | [api docs](https://docs.dataforseo.com/v3/app_data/overview/?bash))
23
+ - Business Data ([source docs](https://github.com/dataforseo/TypeScriptClient/tree/master/docs/BusinessDataApi.md) | [api docs](https://docs.dataforseo.com/v3/business_data/overview/?bash))
24
+ - Appendix ([source docs](https://github.com/dataforseo/TypeScriptClient/tree/master/docs/AppendixApi.md) | [api docs](https://docs.dataforseo.com/v3/appendix/user_data/?bash))
25
+
26
+ API Contains 2 types of requests:
27
+
28
+ 1) Live (Simple HTTP request/response message)
29
+ 2) Task-based (Requires sending a 'Task' entity to execute, waiting until the 'Task' status is ready, and getting the 'Task' result in a special endpoint. Usually, it is represented by 3 types of endpoints: 'TaskPost', 'TaskReady', and 'TaskGet')
30
+
31
+ For more details, please follow [here](https://docs.dataforseo.com/v3/?bash)
32
+
33
+ ## YAML Spec
34
+
35
+ Our API description is based on the OpenAPI [syntax](https://spec.openapis.org/oas/v3.1.0) in YAML format. The YAML file is attached to the project [here](https://github.com/dataforseo/OpenApiDocumentation)
36
+
37
+ ## Documentation
38
+
39
+ The documentation for code objects, formatted in Markdown (.md) is available [here](https://github.com/dataforseo/TypeScriptClient/tree/master/docs). Official documentation for DataForSEO API is available [here](https://docs.dataforseo.com/v3/?bash).
40
+
41
+ ## Code generation
42
+
43
+ Code generated using the [NSwag lib](https://github.com/RicoSuter/NSwag)
44
+
45
+ ## Install package from npm
46
+
47
+ ```bash
48
+ npm install dataforseo-client
49
+ ```
50
+
51
+ ## Examples of usage
52
+
53
+ Example of live request
54
+ ```typescript
55
+ import * as client from 'dataforseo-client'
56
+
57
+ async function main() {
58
+
59
+ const username = 'username';
60
+ const password = 'password';
61
+
62
+ const authFetch = createAuthenticatedFetch(username, password);
63
+ let serpApi = new client.SerpApi("https://api.dataforseo.com", { fetch: authFetch });
64
+
65
+ let task = new client.SerpGoogleOrganicLiveAdvancedRequestInfo();
66
+ task.location_code = 2840;
67
+ task.language_code = "en";
68
+ task.keyword = "albert einstein"
69
+
70
+ let resp = await serpApi.googleOrganicLiveAdvanced([task]);
71
+ }
72
+
73
+ function createAuthenticatedFetch(username: string, password: string) {
74
+ return (url: RequestInfo, init?: RequestInit): Promise<Response> => {
75
+ const token = btoa(`${username}:${password}`);
76
+ const authHeader = { 'Authorization': `Basic ${token}` };
77
+
78
+ const newInit: RequestInit = {
79
+ ...init,
80
+ headers: {
81
+ ...init?.headers,
82
+ ...authHeader
83
+ }
84
+ };
85
+
86
+ return fetch(url, newInit);
87
+ };
88
+ }
89
+
90
+ main();
91
+ ```
92
+
93
+ Example of Task based endpoint
94
+ ```typescript
95
+ import * as client from 'dataforseo-client'
96
+
97
+ async function main() {
98
+
99
+ const username = 'username';
100
+ const password = 'password';
101
+
102
+ const authFetch = createAuthenticatedFetch(username, password);
103
+ let serpApi = new client.SerpApi("https://api.dataforseo.com", { fetch: authFetch });
104
+
105
+ let task = new client.SerpTaskRequestInfo();
106
+ task.location_code = 2840;
107
+ task.language_code = "en";
108
+ task.keyword = "albert einstein"
109
+
110
+ let taskResponse = await serpApi.googleOrganicTaskPost([task])
111
+
112
+ let taskID = taskResponse.tasks[0].id;
113
+ const startTime = Date.now();
114
+
115
+ while (!await isReady(serpApi, taskID) && Date.now() - startTime < 60000) {
116
+ await new Promise(resolve => setTimeout(resolve, 1000));
117
+ }
118
+
119
+ let resp = await serpApi.googleOrganicTaskGetAdvanced(taskID);
120
+ }
121
+
122
+ async function isReady(serpApi: client.SerpApi, id: string): Promise<boolean> {
123
+ let resp = await serpApi.googleOrganicTasksReady();
124
+
125
+ let isReadyId = false;
126
+
127
+ resp.tasks.forEach(x => {
128
+ if (x.id == id) {
129
+ isReadyId = true;
130
+ }
131
+ });
132
+
133
+ return isReadyId;
134
+ }
135
+
136
+ function createAuthenticatedFetch(username: string, password: string) {
137
+ return (url: RequestInfo, init?: RequestInit): Promise<Response> => {
138
+ const token = btoa(`${username}:${password}`);
139
+ const authHeader = { 'Authorization': `Basic ${token}` };
140
+
141
+ const newInit: RequestInit = {
142
+ ...init,
143
+ headers: {
144
+ ...init?.headers,
145
+ ...authHeader
146
+ }
147
+ };
148
+
149
+ return fetch(url, newInit);
150
+ };
151
+ }
152
+
153
+ main();
154
+ ```
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "dataforseo-client",
3
- "version": "2.0.22",
3
+ "version": "2.0.23",
4
4
  "type": "module",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",
7
7
  "description": "API client that provide services of DataForSeo API \n\n For more information about client code generation, please follow to github",
8
8
  "scripts": {
9
9
  "build:esm": "tsc -p tsconfig.esm.json && node fix-esm-imports.js",
10
- "build:cjs": "tsc -p tsconfig.cjs.json",
10
+ "build:cjs": "tsc -p tsconfig.cjs.json && node -e \"require('fs').writeFileSync('dist/cjs/package.json', '{\\\"type\\\":\\\"commonjs\\\"}')\"",
11
11
  "build": "npm run build:esm && npm run build:cjs",
12
12
  "test": "jest --verbose"
13
13
  },
14
- "files":[
14
+ "files": [
15
15
  "dist",
16
16
  "README.md",
17
17
  "package.json"
@@ -44,4 +44,4 @@
44
44
  "author": "dataforseo",
45
45
  "license": "ISC",
46
46
  "homepage": "https://github.com/dataforseo/TypeScriptClient#readme"
47
- }
47
+ }