### Get Dataforseo Labs Available Filters Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/DataforseoLabsApi.md This example shows how to retrieve a list of available filters for the Dataforseo Labs API. It includes the basic setup for the API client with authentication. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new DataforseoLabsApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); let response = await api.availableFilters(); ``` -------------------------------- ### Baidu Locations Request Example Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/SerpApi.md Demonstrates how to fetch Baidu location data using the TypeScript client. This example includes the necessary authentication setup. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new SerpApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); let response = await api.baiduLocations(); ``` -------------------------------- ### Get Google Keywords for Site Live Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/DataforseoLabsApi.md Example of calling the googleKeywordsForSiteLive endpoint with specified parameters. This includes setting target, language, location, and filtering options. ```typescript let task = new DataforseoLabsGoogleKeywordsForSiteLiveRequestInfo(); task.target = "apple.com"; task.language_code = "en"; task.location_code = 2840; task.include_serp_info = true; task.include_subdomains = true; task.filters = [ "serp_info.se_results_count", ">", 0, ]; task.limit = 3; let response = await api.googleKeywordsForSiteLive([task]); ``` -------------------------------- ### Get Google Related Keywords Live Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/DataforseoLabsApi.md This example shows how to set up the DataforseoLabsApi client with authentication and then retrieve related keywords for a given term. It configures a task with a keyword, language, location, and a limit for the results. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new DataforseoLabsApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); let task = new DataforseoLabsGoogleRelatedKeywordsLiveRequestInfo(); task.keyword = "phone"; task.language_name = "English"; task.location_code = 2840; task.limit = 3; let response = await api.googleRelatedKeywordsLive([task]); ``` -------------------------------- ### Get Available WHOIS Filters Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/DomainAnalyticsApi.md This example demonstrates how to retrieve a list of available filters for WHOIS data. It initializes the API with basic authentication and calls the whoisAvailableFilters endpoint. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new DomainAnalyticsApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); let response = await api.whoisAvailableFilters(); ``` -------------------------------- ### Get Competitors Live Data Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/BacklinksApi.md This example shows how to retrieve live competitor data for a specified target domain. It covers API client initialization with authentication and task configuration, including target, filters, order, and limit. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new BacklinksApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); let task = new BacklinksCompetitorsLiveRequestInfo(); task.target = "dataforseo.com"; task.filters = [ "rank", ">", 100, ]; task.order_by = [ "rank,desc", ]; task.limit = 5; let response = await api.competitorsLive([task]); ``` -------------------------------- ### Initialize SerpApi Client for YouTube Video Info Live Advanced Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/SerpApi.md Sets up the SerpApi client to fetch live advanced YouTube video information. This example shows how to configure the client and prepare a request object. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new SerpApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); let task = new SerpYoutubeVideoInfoLiveAdvancedRequestInfo(); task.language_code = "en"; task.location_code = 2840; task.video_id = "vQXvyV0zIP4"; let response = await api.youtubeVideoInfoLiveAdvanced([task]); ``` -------------------------------- ### Get Redirect Chains Data Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/OnPageApi.md Analyzes redirect chains starting from a given URL. Requires basic authentication setup. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new OnPageApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); let task = new OnPageRedirectChainsRequestInfo(); task.id = "03051327-4536-0216-1000-3b458a2cfcca"; task.url = "https://test_rdr.dataforseo.com/a/"; let response = await api.redirectChains([task]); ``` -------------------------------- ### Initialize SerpApi Client and Fetch Seznam Organic Task (Regular) Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/SerpApi.md Demonstrates initializing the SerpApi client with basic authentication and fetching regular Seznam organic task results. Requires username and password for authentication. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new SerpApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); let id = "00000000-0000-0000-0000-000000000000"; let response = await api.seznamOrganicTaskGetRegular(id); ``` -------------------------------- ### Initialize SerpApi Client and Fetch Seznam Organic Task (HTML) Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/SerpApi.md Demonstrates initializing the SerpApi client with basic authentication and fetching HTML Seznam organic task results. Requires username and password for authentication. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new SerpApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); let id = "00000000-0000-0000-0000-000000000000"; let response = await api.seznamOrganicTaskGetHtml(id); ``` -------------------------------- ### Get Google Competitors Domain Live Data Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/DataforseoLabsApi.md Use this example to find live domain competitors for a target domain. The snippet requires API client setup with authentication and task configuration including the target domain, intersecting domains, language, location, and limits. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new DataforseoLabsApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); let task = new DataforseoLabsGoogleCompetitorsDomainLiveRequestInfo(); task.target = "newmouth.com"; task.intersecting_domains = [ "dentaly.org", "health.com", "trysnow.com", ]; task.language_name = "English"; task.location_code = 2840; task.limit = 3; let response = await api.googleCompetitorsDomainLive([task]); ``` -------------------------------- ### Initialize SerpApi Client and Post Google Finance Explore Task Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/SerpApi.md Demonstrates initializing the SerpApi client with basic authentication and posting a Google Finance explore task. Requires username and password for authentication and specifies location and language. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new SerpApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); let task = new SerpGoogleFinanceExploreTaskPostRequestInfo(); task.location_code = 2840; task.language_name = "English"; let response = await api.googleFinanceExploreTaskPost([task]); ``` -------------------------------- ### Get Categories Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/DataforseoLabsApi.md Example of calling the categories endpoint. This endpoint does not require any parameters. ```typescript let response = await api.categories(); ``` -------------------------------- ### Fetch Ready Google Local Finder Tasks Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/SerpApi.md Demonstrates how to initialize the SerpApi client with authentication and then retrieve ready tasks for Google Local Finder. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new SerpApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); let response = await api.googleLocalFinderTasksReady(); ``` -------------------------------- ### Get Locations and Languages Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/DataforseoLabsApi.md Example of calling the locationsAndLanguages endpoint. This endpoint does not require any parameters. ```typescript let response = await api.locationsAndLanguages(); ``` -------------------------------- ### Initialize SerpApi Client for YouTube Video Info Tasks Fixed Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/SerpApi.md Shows how to set up the SerpApi client with basic authentication for the youtubeVideoInfoTasksFixed endpoint. Requires username and password for token generation. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new SerpApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); let response = await api.youtubeVideoInfoTasksFixed(); ``` -------------------------------- ### Get Bing Keyword Performance Tasks Ready Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/KeywordsDataApi.md Call the bingKeywordPerformanceTasksReady endpoint to get ready tasks for Bing keyword performance. This example assumes the API client is already initialized. ```typescript let response = await api.bingKeywordPerformanceTasksReady(); ``` -------------------------------- ### Initialize SerpApi Client and Fetch Seznam Organic Task (Advanced) Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/SerpApi.md Demonstrates initializing the SerpApi client with basic authentication and fetching advanced Seznam organic task results. Requires username and password for authentication. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new SerpApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); let id = "00000000-0000-0000-0000-000000000000"; let response = await api.seznamOrganicTaskGetAdvanced(id); ``` -------------------------------- ### Get Google Available History Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/DataforseoLabsApi.md Example of calling the googleAvailableHistory endpoint. This endpoint does not require any parameters. ```typescript let response = await api.googleAvailableHistory(); ``` -------------------------------- ### Initialize SerpApi Client with Basic Auth Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/SerpApi.md Demonstrates how to initialize the SerpApi client with basic authentication credentials. This setup is required for most API calls. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new SerpApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); let response = await api.googleLocalFinderTasksFixed(); ``` -------------------------------- ### Get TripAdvisor Locations Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/BusinessDataApi.md Retrieves a list of TripAdvisor locations. Requires basic authentication setup. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new BusinessDataApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); let response = await api.tripadvisorLocations(); ``` -------------------------------- ### Initialize SerpApi Client for YouTube Locations Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/SerpApi.md Demonstrates how to initialize the SerpApi client with basic authentication for fetching YouTube locations. Ensure your username and password are set correctly. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new SerpApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); let response = await api.youtubeLocations(); ``` -------------------------------- ### Initialize SerpApi Client with Custom Fetch Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/SerpApi.md Demonstrates how to initialize the SerpApi client with a custom fetch implementation to include basic authentication headers. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new SerpApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); let response = await api.googleLocations(); ``` -------------------------------- ### Get TripAdvisor Languages Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/BusinessDataApi.md Retrieves a list of supported languages for TripAdvisor. Requires basic authentication setup. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new BusinessDataApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); let response = await api.tripadvisorLanguages(); ``` -------------------------------- ### Get Google Trends Categories Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/KeywordsDataApi.md Fetches available categories for Google Trends. Requires basic authentication setup. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new KeywordsDataApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); let response = await api.googleTrendsCategories(); ``` -------------------------------- ### Initialize SerpApi Client and Fetch YouTube Video Comments Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/SerpApi.md Demonstrates how to initialize the SerpApi client with basic authentication and fetch YouTube video comments using the `youtubeVideoCommentsTaskGetAdvanced` method. Ensure you have your username and password correctly set. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new SerpApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); let id = "00000000-0000-0000-0000-000000000000"; let response = await api.youtubeVideoCommentsTaskGetAdvanced(id); ``` -------------------------------- ### Get TripAdvisor Locations by Country Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/BusinessDataApi.md Retrieves TripAdvisor locations for a specific country. Requires basic authentication setup. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new BusinessDataApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); let country = "us"; let response = await api.tripadvisorLocationsCountry(country); ``` -------------------------------- ### Initialize SerpApi Client for YouTube Video Info Tasks Ready Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/SerpApi.md Demonstrates how to initialize the SerpApi client with custom fetch logic for authentication. This is used for the youtubeVideoInfoTasksReady endpoint. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new SerpApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` } const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); let response = await api.youtubeVideoInfoTasksReady(); ``` -------------------------------- ### Initialize SerpApi Client and Fetch Google Jobs HTML Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/SerpApi.md Demonstrates initializing the SerpApi client with basic authentication and fetching HTML for a Google Jobs task. Ensure you have your username and password defined. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new SerpApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); let id = "00000000-0000-0000-0000-000000000000"; let response = await api.googleJobsTaskGetHtml(id); ``` -------------------------------- ### Get Bing Supported Languages Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/SerpApi.md Retrieves a list of supported languages for Bing searches. Requires basic authentication setup. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new SerpApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); let response = await api.bingLanguages(); ``` -------------------------------- ### Perform Live Google Dataset Info Search (Advanced) Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/SerpApi.md This example demonstrates how to perform a live advanced search for Google dataset information. It requires setting up the SerpApi client with authentication and providing a list of tasks, each with a dataset ID. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new SerpApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); let task = new SerpGoogleDatasetInfoLiveAdvancedRequestInfo(); task.dataset_id = "L2cvMTFqbl85ZHN6MQ=="; let response = await api.googleDatasetInfoLiveAdvanced([task]); ``` -------------------------------- ### Get Bing Locations Country Data Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/SerpApi.md Fetches country data for Bing searches. Requires basic authentication setup. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new SerpApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); let country = "us"; let response = await api.bingLocationsCountry(country); ``` -------------------------------- ### Initialize SerpApi Client with Custom Fetch Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/SerpApi.md Demonstrates how to initialize the SerpApi client with a custom fetch function to include basic authentication headers. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new SerpApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); let id = "00000000-0000-0000-0000-000000000000"; let response = await api.googleAiModeTaskGetHtml(id); ``` -------------------------------- ### Get Google Trends Languages Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/KeywordsDataApi.md Retrieves a list of supported languages for Google Trends. Requires basic authentication setup. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new KeywordsDataApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); let response = await api.googleTrendsLanguages(); ``` -------------------------------- ### Fetch AI Summary with Basic Authentication Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/SerpApi.md This example demonstrates how to use the aiSummary endpoint of the DataForSEO API. It includes setting up the authenticated API client and constructing a request with a task ID and prompt. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new SerpApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); let task = new SerpAiSummaryRequestInfo(); task.task_id = "07031739-1535-0139-0000-9d1e639a5b7d"; task.prompt = "explain what DataForSEO is"; task.include_links = true; task.fetch_content = true; let response = await api.aiSummary([task]); ``` -------------------------------- ### index Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/BacklinksApi.md Provides an index of backlink data. This endpoint can be used to get an overview or a starting point for exploring backlink information. ```APIDOC ## GET /v3/backlinks/index ### Description Provides an index of backlink data. This endpoint can be used to get an overview or a starting point for exploring backlink information. ### Method GET ### Endpoint /v3/backlinks/index ### Response #### Success Response (200) - **BacklinksIndexResponseInfo** - ### Authorization basicAuth ### HTTP request headers - **Accept**: application/json ``` -------------------------------- ### Get Google Trends Locations by Country Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/KeywordsDataApi.md Fetches Google Trends locations for a specified country. Requires basic authentication setup. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new KeywordsDataApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); let country = "us"; let response = await api.googleTrendsLocationsCountry(country); ``` -------------------------------- ### Setup ContentAnalysisApi with Basic Authentication Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/ContentAnalysisApi.md Demonstrates how to initialize the ContentAnalysisApi client with basic authentication credentials. This setup is common across multiple API calls. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new ContentAnalysisApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); ``` -------------------------------- ### Initialize SerpApi Client for YouTube Video Info Task Get Advanced Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/SerpApi.md Illustrates initializing the SerpApi client for retrieving advanced YouTube video information using a task ID. Includes custom fetch for authentication. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new SerpApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); let id = "00000000-0000-0000-0000-000000000000"; let response = await api.youtubeVideoInfoTaskGetAdvanced(id); ``` -------------------------------- ### Get Duplicate Content Data Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/OnPageApi.md Initiates a request to find duplicate content on a given URL. Requires basic authentication setup. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new OnPageApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); let task = new OnPageDuplicateContentRequestInfo(); task.id = "07281559-0695-0216-0000-c269be8b7592"; task.url = "https://www.etsy.com/"; let response = await api.duplicateContent([task]); ``` -------------------------------- ### Initialize and Use Google Maps Live Advanced API Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/SerpApi.md Demonstrates how to initialize the SerpApi client with custom fetch logic for authentication and then perform a Google Maps Live Advanced search. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new SerpApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); let task = new SerpGoogleMapsLiveAdvancedRequestInfo(); task.language_code = "en"; task.location_code = 2840; task.keyword = "albert einstein"; let response = await api.googleMapsLiveAdvanced([task]); ``` -------------------------------- ### Get Apple App Listings Categories Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/AppDataApi.md Retrieves a list of categories for Apple App Listings. Requires basic authentication setup. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new AppDataApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); let response = await api.appleAppListingsCategories(); ``` -------------------------------- ### Get Backlinks History Live Data Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/BacklinksApi.md Retrieves historical backlink data for a specified target. Requires basic authentication setup. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new BacklinksApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); let task = new BacklinksHistoryLiveRequestInfo(); task.target = "cnn.com"; let response = await api.historyLive([task]); ``` -------------------------------- ### Initialize Merchant API and Check Google Product Info Tasks Ready Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/MerchantApi.md Illustrates initializing the Merchant API with basic authentication and checking for ready Google Product Information tasks. This is useful for monitoring the status of submitted product information requests. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new MerchantApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); let response = await api.googleProductInfoTasksReady(); ``` -------------------------------- ### Initialize SerpApi Client with Custom Fetch Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/SerpApi.md Demonstrates how to initialize the SerpApi client with a custom fetch function to include Basic Authentication headers. This is useful for setting up authentication for API requests. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new SerpApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); ``` -------------------------------- ### Execute Google AI Mode Task (Get HTML) Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/SerpApi.md Example of calling the googleAiModeTaskGetHtml endpoint to retrieve HTML content for a specific task ID. ```typescript let id = "00000000-0000-0000-0000-000000000000"; let response = await api.googleAiModeTaskGetHtml(id); ``` -------------------------------- ### Get On-Page Uncrawlable Resources Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/OnPageApi.md This example shows how to retrieve a list of uncrawlable resources for a URL. It includes setting an ID, filters, and a limit for the request. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new OnPageApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); let task = new OnPageUncrawlableResourcesRequestInfo(); task.id = "07281559-0695-0216-0000-c269be8b7592"; task.filters = [ , "and", , ]; task.limit = 10; let response = await api.uncrawlableResources([task]); ``` -------------------------------- ### Initialize DataforseoLabsApi with Basic Authentication Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/DataforseoLabsApi.md Demonstrates how to initialize the DataforseoLabsApi client with custom fetch logic for basic authentication. This setup is required for all API calls. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new DataforseoLabsApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); ``` -------------------------------- ### Initialize SerpApi Client with Custom Fetch Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/SerpApi.md Demonstrates how to initialize the SerpApi client with a custom fetch function to include Basic Authentication headers. This is useful for setting up authenticated API requests. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new SerpApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); ``` -------------------------------- ### Get Dataforseo Labs Status Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/DataforseoLabsApi.md This example demonstrates how to retrieve the current status of the Dataforseo Labs API. It initializes the API client with authentication credentials. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new DataforseoLabsApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); let response = await api.status(); ``` -------------------------------- ### Initialize SerpApi Client and Get Languages Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/SerpApi.md Initializes the SerpApi client with basic authentication and retrieves a list of supported languages. Ensure you have your username and password defined. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new SerpApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); let response = await api.seznamLanguages(); ``` -------------------------------- ### Get Google Locations Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/MerchantApi.md Retrieves a list of supported Google locations. The example demonstrates setting up the API client with basic authentication. No parameters are needed for this request. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new MerchantApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); let response = await api.merchantGoogleLocations(); ``` -------------------------------- ### Initialize Merchant API and Post Google Product Info Task Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/MerchantApi.md Demonstrates initializing the Merchant API with basic authentication and submitting a new Google Product Information task. This is used to request specific product data from Google. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new MerchantApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); let task = new MerchantGoogleProductInfoTaskPostRequestInfo(); task.language_code = "en"; task.location_code = 2840; task.product_id = "1113158713975221117"; let response = await api.googleProductInfoTaskPost([task]); ``` -------------------------------- ### Initialize Merchant API and Check Google Sellers Tasks Ready Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/MerchantApi.md Demonstrates how to initialize the Merchant API with basic authentication and check for ready Google Sellers tasks. This is useful for initiating data retrieval processes. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new MerchantApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); let response = await api.googleSellersTasksReady(); ``` -------------------------------- ### Content Analysis Rating Distribution Live Request Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/ContentAnalysisApi.md Example of how to get the rating distribution for content. It covers authentication and setting up the task for rating distribution analysis. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new ContentAnalysisApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); let task = new ContentAnalysisRatingDistributionLiveRequestInfo(); task.keyword = "logitech"; task.search_mode = "as_is"; task.internal_list_limit = 10; let response = await api.ratingDistributionLive([task]); ``` -------------------------------- ### Get YouTube Organic Task Results Source: https://github.com/dataforseo/typescriptclient/blob/master/docs/SerpApi.md Retrieves advanced YouTube organic search results for a given task ID. Requires basic authentication setup. ```typescript const username = 'USERNAME'; const password = 'PASSWORD'; let api = new SerpApi("https://api.dataforseo.com", { fetch: (url: RequestInfo, init?: RequestInit): Promise => { const token = btoa(`${username}:${password}`); const authHeader = { 'Authorization': `Basic ${token}` }; const newInit: RequestInit = { ...init, headers: { ...init?.headers, ...authHeader, } }; return fetch(url, newInit); } }); let id = "00000000-0000-0000-0000-000000000000"; let response = await api.youtubeOrganicTaskGetAdvanced(id); ```