UNPKG

@langchain/community

Version:
1 lines • 6.28 kB
{"version":3,"file":"dataforseo_api_search.d.ts","names":["Tool","DataForSeoApiConfig","Record","Array","Task","Result","ApiResponse","DataForSeoAPISearch","Promise","HeadersInit","BodyInit"],"sources":["../../src/tools/dataforseo_api_search.d.ts"],"sourcesContent":["import { Tool } from \"@langchain/core/tools\";\n/**\n * @interface DataForSeoApiConfig\n * @description Represents the configuration object used to set up a DataForSeoAPISearch instance.\n */\nexport interface DataForSeoApiConfig {\n /**\n * @property apiLogin\n * @type {string}\n * @description The API login credential for DataForSEO. If not provided, it will be fetched from environment variables.\n */\n apiLogin?: string;\n /**\n * @property apiPassword\n * @type {string}\n * @description The API password credential for DataForSEO. If not provided, it will be fetched from environment variables.\n */\n apiPassword?: string;\n /**\n * @property params\n * @type {Record<string, string | number | boolean>}\n * @description Additional parameters to customize the API request.\n */\n params?: Record<string, string | number | boolean>;\n /**\n * @property useJsonOutput\n * @type {boolean}\n * @description Determines if the output should be in JSON format.\n */\n useJsonOutput?: boolean;\n /**\n * @property jsonResultTypes\n * @type {Array<string>}\n * @description Specifies the types of results to include in the output.\n */\n jsonResultTypes?: Array<string>;\n /**\n * @property jsonResultFields\n * @type {Array<string>}\n * @description Specifies the fields to include in each result object.\n */\n jsonResultFields?: Array<string>;\n /**\n * @property topCount\n * @type {number}\n * @description Specifies the maximum number of results to return.\n */\n topCount?: number;\n}\n/**\n * Represents a task in the API response.\n */\ntype Task = {\n id: string;\n status_code: number;\n status_message: string;\n time: string;\n result: Result[];\n};\n/**\n * Represents a result in the API response.\n */\ntype Result = {\n keyword: string;\n check_url: string;\n datetime: string;\n spell?: string;\n item_types: string[];\n se_results_count: number;\n items_count: number;\n items: any[];\n};\n/**\n * Represents the API response.\n */\ntype ApiResponse = {\n status_code: number;\n status_message: string;\n tasks: Task[];\n};\n/**\n * @class DataForSeoAPISearch\n * @extends {Tool}\n * @description Represents a wrapper class to work with DataForSEO SERP API.\n */\nexport declare class DataForSeoAPISearch extends Tool {\n static lc_name(): string;\n name: string;\n description: string;\n protected apiLogin: string;\n protected apiPassword: string;\n /**\n * @property defaultParams\n * @type {Record<string, string | number | boolean>}\n * @description These are the default parameters to be used when making an API request.\n */\n protected defaultParams: Record<string, string | number | boolean>;\n protected params: Record<string, string | number | boolean>;\n protected jsonResultTypes: Array<string> | undefined;\n protected jsonResultFields: Array<string> | undefined;\n protected topCount: number | undefined;\n protected useJsonOutput: boolean;\n /**\n * @constructor\n * @param {DataForSeoApiConfig} config\n * @description Sets up the class, throws an error if the API login/password isn't provided.\n */\n constructor(config?: DataForSeoApiConfig);\n /**\n * @method _call\n * @param {string} keyword\n * @returns {Promise<string>}\n * @description Initiates a call to the API and processes the response.\n */\n _call(keyword: string): Promise<string>;\n /**\n * @method results\n * @param {string} keyword\n * @returns {Promise<Array<any>>}\n * @description Fetches the results from the API for the given keyword.\n */\n results(keyword: string): Promise<Array<any>>;\n /**\n * @method prepareRequest\n * @param {string} keyword\n * @returns {{url: string; headers: HeadersInit; data: BodyInit}}\n * @description Prepares the request details for the API call.\n */\n protected prepareRequest(keyword: string): {\n url: string;\n headers: HeadersInit;\n data: BodyInit;\n };\n /**\n * @method getResponseJson\n * @param {string} keyword\n * @returns {Promise<ApiResponse>}\n * @description Executes a POST request to the provided URL and returns a parsed JSON response.\n */\n protected getResponseJson(keyword: string): Promise<ApiResponse>;\n /**\n * @method checkResponse\n * @param {ApiResponse} response\n * @returns {ApiResponse}\n * @description Checks the response status code.\n */\n private checkResponse;\n /**\n * @method filterResults\n * @param {ApiResponse} res\n * @param {Array<string> | undefined} types\n * @returns {Array<any>}\n * @description Filters the results based on the specified result types.\n */\n private filterResults;\n /**\n * @method cleanupUnnecessaryItems\n * @param {any} d\n * @description Removes unnecessary items from the response.\n */\n private cleanupUnnecessaryItems;\n /**\n * @method processResponse\n * @param {ApiResponse} res\n * @returns {string}\n * @description Processes the response to extract meaningful data.\n */\n protected processResponse(res: ApiResponse): string;\n}\nexport {};\n//# sourceMappingURL=dataforseo_api_search.d.ts.map"],"mappings":";;;;;;AAKA;;AA8BsBG,UA9BLF,mBAAAA,CA8BKE;EAMCA;AAAK;AAO3B;AASiB;AAKP;EAuBUI,QAAAA,CAAAA,EAAAA,MAAAA;EAWQL;;;;;EAkBDM,WAAAA,CAAAA,EAAAA,MAAAA;EAOUL;;;;;EAkBUK,MAAAA,CAAAA,EApHnCN,MAoHmCM,CAAAA,MAAAA,EAAAA,MAAAA,GAAAA,MAAAA,GAAAA,OAAAA,CAAAA;EA4BbF;;AAlFkB;;;;;;;;;oBAlD/BH;;;;;;qBAMCA;;;;;;;;;;;KAWlBC,IAAAA;;;;;UAKOC;;;;;KAKPA,MAAAA;;;;;;;;;;;;;KAaAC,WAAAA;;;SAGMF;;;;;;;cAOUG,mBAAAA,SAA4BP,IAAAA;;;;;;;;;;;2BAWpBE;oBACPA;6BACSC;8BACCA;;;;;;;;uBAQPF;;;;;;;0BAOGO;;;;;;;4BAOEA,QAAQL;;;;;;;;;aASrBM;UACHC;;;;;;;;8CAQkCF,QAAQF;;;;;;;;;;;;;;;;;;;;;;;;;;;;iCA4BrBA"}