Skip to content

Commit e3da1d3

Browse files
Add customHeaders support for standard APIs
Including analyze, article, discussion, event, image, product, and video
1 parent 8e3be09 commit e3da1d3

File tree

5 files changed

+146
-99
lines changed

5 files changed

+146
-99
lines changed

src/diffbot.d.ts

Lines changed: 49 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ declare class Diffbot {
1010
test: boolean;
1111
/**
1212
* Execute an analyze API call
13-
* @param {Object} options The analyze options
13+
* @param {object} options The analyze options
1414
* @param {string} options.url Web page URL of the analyze to process
1515
* @param {string} [options.mode] By default the Analyze API will fully extract all pages that match an existing Automatic API -- articles, products or image pages. Set mode to a specific page-type (e.g., mode=article) to extract content only from that specific page-type. All other pages will simply return the default Analyze fields.
1616
* @param {string} [options.fallback] Force any non-extracted pages (those with a type of "other") through a specific API. For example, to route all "other" pages through the Article API, pass &fallback=article. Pages that utilize this functionality will return a fallbackType field at the top-level of the response and a originalType field within each extracted object, both of which will indicate the fallback API used.
@@ -23,7 +23,8 @@ declare class Diffbot {
2323
* @param {string} [options.proxyAuth] Used to specify the authentication parameters that will be used with the proxy specified in the &proxy parameter. (Ex: &proxyAuth=username:password)
2424
* @param {string} [options.body] Optional HTML markup to pass as POST body
2525
* @param {string} [options.customJS] This functionality is currently in beta. See docs for details: https://docs.diffbot.com/docs/en/api-analyze#custom-javascript
26-
* @returns {Object} The analyze query results
26+
* @param {object} [options.customHeaders] This functionality is currently in beta. See docs for details: https://docs.diffbot.com/docs/en/api-analyze#custom-headers
27+
* @returns {object} The analyze query results
2728
*/
2829
analyze(options: {
2930
url: string;
@@ -38,10 +39,11 @@ declare class Diffbot {
3839
proxyAuth?: string;
3940
body?: string;
4041
customJS?: string;
41-
}): any;
42+
customHeaders?: object;
43+
}): object;
4244
/**
4345
* Execute an article API call
44-
* @param {Object} options The search options
46+
* @param {object} options The search options
4547
* @param {string} [options.url] Web page URL of the article to process (required unless posting plain text)
4648
* @param {string[]} [options.fields] Used to specify optional fields to be returned by the Article API. See fields: https://www.diffbot.com/dev/docs/article/#fields
4749
* @param {boolean} [options.paging] Pass paging=false to disable automatic concatenation of multiple-page articles. (By default, Diffbot will concatenate up to 20 pages of a single article.)
@@ -55,7 +57,8 @@ declare class Diffbot {
5557
* @param {string[]} [options.naturalLanguage] Used to request the output of the Diffbot Natural Language API in the field naturalLanguage. Example: &naturalLanguage=entities,facts,categories,sentiment.
5658
* @param {string} [options.body] Optional HTML markup to pass as POST body
5759
* @param {string} [options.customJS] This functionality is currently in beta. See docs for details: https://docs.diffbot.com/docs/en/api-article#custom-javascript
58-
* @returns {Object} The article query results
60+
* @param {object} [options.customHeaders] This functionality is currently in beta. See docs for details: https://docs.diffbot.com/docs/en/api-analyze#custom-headers
61+
* @returns {object} The article query results
5962
*/
6063
article(options: {
6164
url?: string;
@@ -71,10 +74,11 @@ declare class Diffbot {
7174
naturalLanguage?: string[];
7275
body?: string;
7376
customJS?: string;
74-
}): any;
77+
customHeaders?: object;
78+
}): object;
7579
/**
7680
* Execute a discussion API call
77-
* @param {Object} options The call options
81+
* @param {object} options The call options
7882
* @param {string} options.url Web page URL of the discussion to process
7983
* @param {string[]} [options.fields] Used to specify optional fields to be returned by the Discussion API. See fields: https://www.diffbot.com/dev/docs/discussion/#fields
8084
* @param {number} [options.timeout] Sets a value in milliseconds to wait for the retrieval/fetch of content from the requested URL. The default timeout for the third-party response is 30 seconds (30000).
@@ -84,7 +88,8 @@ declare class Diffbot {
8488
* @param {string} [options.proxyAuth] Used to specify the authentication parameters that will be used with the proxy specified in the &proxy parameter. (Ex: &proxyAuth=username:password)
8589
* @param {string} [options.body] Optional HTML markup to pass as POST body
8690
* @param {string} [options.customJS] This functionality is currently in beta. See docs for details: https://docs.diffbot.com/docs/en/api-discussion#custom-javascript
87-
* @returns {Object} The discussion query results
91+
* @param {object} [options.customHeaders] This functionality is currently in beta. See docs for details: https://docs.diffbot.com/docs/en/api-analyze#custom-headers
92+
* @returns {object} The discussion query results
8893
*/
8994
discussion(options: {
9095
url: string;
@@ -96,10 +101,11 @@ declare class Diffbot {
96101
proxyAuth?: string;
97102
body?: string;
98103
customJS?: string;
99-
}): any;
104+
customHeaders?: object;
105+
}): object;
100106
/**
101107
* Execute an event API call
102-
* @param {Object} options The event options
108+
* @param {object} options The event options
103109
* @param {string} options.url Web page URL of the event to process
104110
* @param {string[]} [options.fields] Used to specify optional fields to be returned by the Event API. See fields: https://docs.diffbot.com/docs/en/api-event
105111
* @param {number} [options.timeout] Sets a value in milliseconds to wait for the retrieval/fetch of content from the requested URL. The default timeout for the third-party response is 30 seconds (30000).
@@ -108,7 +114,8 @@ declare class Diffbot {
108114
* @param {string} [options.proxyAuth] Used to specify the authentication parameters that will be used with the proxy specified in the &proxy parameter. (Ex: &proxyAuth=username:password)
109115
* @param {string} [options.body] Optional HTML markup to pass as POST body
110116
* @param {string} [options.customJS] This functionality is currently in beta. See docs for details: https://docs.diffbot.com/docs/en/api-event#custom-javascript
111-
* @returns {Object} The analyze query results
117+
* @param {object} [options.customHeaders] This functionality is currently in beta. See docs for details: https://docs.diffbot.com/docs/en/api-analyze#custom-headers
118+
* @returns {object} The analyze query results
112119
*/
113120
event(options: {
114121
url: string;
@@ -119,10 +126,11 @@ declare class Diffbot {
119126
proxyAuth?: string;
120127
body?: string;
121128
customJS?: string;
122-
}): any;
129+
customHeaders?: object;
130+
}): object;
123131
/**
124132
* Execute an image API call
125-
* @param {Object} options The call options
133+
* @param {object} options The call options
126134
* @param {string} options.url Web page URL of the image to process
127135
* @param {string[]} [options.fields] Used to specify optional fields to be returned by the Image API. See fields: https://www.diffbot.com/dev/docs/image/#fields
128136
* @param {number} [options.timeout] Sets a value in milliseconds to wait for the retrieval/fetch of content from the requested URL. The default timeout for the third-party response is 30 seconds (30000).
@@ -131,7 +139,8 @@ declare class Diffbot {
131139
* @param {string} [options.proxyAuth] Used to specify the authentication parameters that will be used with the proxy specified in the &proxy parameter. (Ex: &proxyAuth=username:password)
132140
* @param {string} [options.body] Optional HTML markup to pass as POST body
133141
* @param {string} [options.customJS] This functionality is currently in beta. See docs for details: https://docs.diffbot.com/docs/en/api-image#custom-javascript
134-
* @returns {Object} The image query results
142+
* @param {object} [options.customHeaders] This functionality is currently in beta. See docs for details: https://docs.diffbot.com/docs/en/api-analyze#custom-headers
143+
* @returns {object} The image query results
135144
*/
136145
image(options: {
137146
url: string;
@@ -142,10 +151,11 @@ declare class Diffbot {
142151
proxyAuth?: string;
143152
body?: string;
144153
customJS?: string;
145-
}): any;
154+
customHeaders?: object;
155+
}): object;
146156
/**
147157
* Execute a product API call
148-
* @param {Object} options The search options
158+
* @param {object} options The search options
149159
* @param {string} options.url Web page URL of the product to process
150160
* @param {string[]} [options.fields] Used to specify optional fields to be returned by the Product API. See fields: https://www.diffbot.com/dev/docs/product/#fields
151161
* @param {boolean} [options.discussion] Pass discussion=false to disable automatic extraction of product reviews.
@@ -155,7 +165,8 @@ declare class Diffbot {
155165
* @param {string} [options.proxyAuth] Used to specify the authentication parameters that will be used with the proxy specified in the &proxy parameter. (Ex: &proxyAuth=username:password)
156166
* @param {string} [options.body] Optional HTML markup to pass as POST body
157167
* @param {string} [options.customJS] This functionality is currently in beta. See docs for details: https://docs.diffbot.com/docs/en/api-product#custom-javascript
158-
* @returns {Object} The product query results
168+
* @param {object} [options.customHeaders] This functionality is currently in beta. See docs for details: https://docs.diffbot.com/docs/en/api-analyze#custom-headers
169+
* @returns {object} The product query results
159170
*/
160171
product(options: {
161172
url: string;
@@ -167,10 +178,11 @@ declare class Diffbot {
167178
proxyAuth?: string;
168179
body?: string;
169180
customJS?: string;
170-
}): any;
181+
customHeaders?: object;
182+
}): object;
171183
/**
172184
* Execute a video API call
173-
* @param {Object} options The call options
185+
* @param {object} options The call options
174186
* @param {string} options.url Web page URL of the video to process
175187
* @param {string[]} [options.fields] Used to specify optional fields to be returned by the Video API. See fields: https://www.diffbot.com/dev/docs/video/#fields
176188
* @param {number} [options.timeout] Sets a value in milliseconds to wait for the retrieval/fetch of content from the requested URL. The default timeout for the third-party response is 30 seconds (30000).
@@ -179,7 +191,8 @@ declare class Diffbot {
179191
* @param {string} [options.proxyAuth] Used to specify the authentication parameters that will be used with the proxy specified in the &proxy parameter. (Ex: &proxyAuth=username:password)
180192
* @param {string} [options.body] Optional HTML markup to pass as POST body
181193
* @param {string} [options.customJS] This functionality is currently in beta. See docs for details: https://docs.diffbot.com/docs/en/api-video#custom-javascript
182-
* @returns {Object} The video query results
194+
* @param {object} [options.customHeaders] This functionality is currently in beta. See docs for details: https://docs.diffbot.com/docs/en/api-analyze#custom-headers
195+
* @returns {object} The video query results
183196
*/
184197
video(options: {
185198
url: string;
@@ -190,18 +203,19 @@ declare class Diffbot {
190203
proxyAuth?: string;
191204
body?: string;
192205
customJS?: string;
193-
}): any;
206+
customHeaders?: object;
207+
}): object;
194208
/**
195209
* Execute a query against the Knowledge Graph
196-
* @param {Object} options The search options
210+
* @param {object} options The search options
197211
* @param {string} options.query The DQL knowledge base query
198212
* @param {string} [options.type] Type of search: "query", "text", or "queryTextFallback"
199213
* @param {number} [options.size] Max number of results in page
200214
* @param {number} [options.from] Ordinal position of first result to return. (First position is 0.) Default is 0.
201215
* @param {string} [options.jsonmode] jsonmode=extended returns origin information for facts
202216
* @param {boolean} [options.nonCanonicalFacts] Return non-canonical facts. Default is no non-canonical facts.
203217
* @param {boolean} [options.noDedupArticles] Indicates that articles should not be deduplicated but all of them returned
204-
* @returns {Object} The query results
218+
* @returns {object} The query results
205219
*/
206220
knowledgeGraph(options: {
207221
query: string;
@@ -211,13 +225,13 @@ declare class Diffbot {
211225
jsonmode?: string;
212226
nonCanonicalFacts?: boolean;
213227
noDedupArticles?: boolean;
214-
}): any;
228+
}): object;
215229
crawl(): {
216230
token: string;
217231
test: boolean;
218232
/**
219233
* Generate a new Crawlbot crawl job
220-
* @param {Object} options The search options
234+
* @param {object} options The search options
221235
* @param {string} options.name Job name. This should be a unique identifier and can be used to modify your crawl or retrieve its output.
222236
* @param {string[]} options.seeds Seed URL(s). If the seed contains a non-www subdomain ("http://blog.diffbot.com" or "http://support.diffbot.com") Crawlbot will restrict spidering to the specified subdomain.
223237
* @param {string} [options.apiUrl] Full Diffbot API URL through which to process pages. E.g., &apiUrl=https://api.diffbot.com/v3/article to process matching links via the Article API. The Diffbot API URL can include querystring parameters to tailor the output. For example, &apiUrl=https://api.diffbot.com/v3/product?fields=querystring,meta will process matching links using the Product API, and also return the querystring and meta fields. Uses the Analyze API (Smart Processing) by default.
@@ -242,7 +256,7 @@ declare class Diffbot {
242256
* @param {number} [options.seedRecrawlFrequency] Useful for specifying a frequency, in number of days, to recrawl seed urls, which is independent of the overall recrawl frequency given by repeat. Defaults to seedRecrawlFrequency=-1 to use the default frequency.
243257
* @param {boolean} [options.onlyProcessIfNew] By default repeat crawls will only process new (previously unprocessed) pages. Set to false to process all content on repeat crawls.
244258
* @param {number} [options.maxRounds] Specify the maximum number of crawl repeats. By default (maxRounds=0) repeating crawls will continue indefinitely.
245-
* @returns {Object} The response and crawl job objects
259+
* @returns {object} The response and crawl job objects
246260
*/
247261
new: (options: {
248262
name: string;
@@ -269,10 +283,10 @@ declare class Diffbot {
269283
seedRecrawlFrequency?: number;
270284
onlyProcessIfNew?: boolean;
271285
maxRounds?: number;
272-
}) => any;
286+
}) => object;
273287
/**
274288
* Download a Crawlbot crawl job's results
275-
* @param {Object} options The options
289+
* @param {object} options The options
276290
* @param {string} options.name Name of the crawl whose data you wish to download.
277291
* @param {string} [options.format] Request format=csv to download the extracted data in CSV format (default: json). Note that CSV files will only contain top-level fields.
278292
* @param {string} [options.type] Request type=urls to retrieve the crawl URL Report (CSV).
@@ -311,17 +325,17 @@ declare class Diffbot {
311325
delete: (options: any) => any;
312326
/**
313327
* Get Crawlbot job details
314-
* @param {Object} options The options
328+
* @param {object} options The options
315329
* @param {string} [options.name] Name of crawl to retrieve.
316-
* @returns {Object} This will return a JSON response of your token's crawls (and Bulk API) jobs in the jobs object. If you have specified a single job name, only one job's details will be returned.
330+
* @returns {object} This will return a JSON response of your token's crawls (and Bulk API) jobs in the jobs object. If you have specified a single job name, only one job's details will be returned.
317331
*/
318332
details: (options: {
319333
name?: string;
320-
}) => any;
334+
}) => object;
321335
};
322336
/**
323337
* Search a Crawlbot crawl job's results
324-
* @param {Object} options The options
338+
* @param {object} options The options
325339
* @param {string} options.name Name of the crawl whose data you wish to download.
326340
* @param {string} options.query Search query. Must be URL-encoded. Please see query operators: https://www.diffbot.com/dev/docs/search/#query
327341
* @param {number|string} [options.num] Number of results to return. Default is 20. To return all results in the search, pass num=all.
@@ -336,13 +350,13 @@ declare class Diffbot {
336350
}): any;
337351
/**
338352
* Execute an account API call
339-
* @param {Object} options The account options
353+
* @param {object} options The account options
340354
* @param {number} [options.days] Pass the number of days (&days=365) for which you would like to retrieve API call volumes (default = 31).
341355
* @param {boolean} [options.invoices] Pass &invoices=true to return invoice and payment history.
342-
* @returns {Object} The account query results
356+
* @returns {object} The account query results
343357
*/
344358
account(options: {
345359
days?: number;
346360
invoices?: boolean;
347-
}): any;
361+
}): object;
348362
}

0 commit comments

Comments
 (0)