Documentation has been updated: see help center and changelog in one place.

JavaScript SDK

Learn how to use the AI Studio JavaScript SDK.

YouTube

We offer a JavaScript SDK for seamlessly interacting with Oxylabs AI Studio API services, including AI-Scraper, AI-Crawler, AI-Browser-Agent, and other data extraction tools.

Installation

Install the SDK:

Either add OXYLABS_AI_STUDIO_API_URL and OXYLABS_AI_STUDIO_API_KEY values to the .env file, or as your environment variables:

Usage

AI-Scraper

Basic usage

Input parameters

  • url (string): The target URL to process.

  • user_prompt (string): Instructions for what data to extract. This is used to automatically generate the openapi_schema when using the scrapeWithAutoSchema method.

  • output_format (string): The desired format for the output. Can be either markdown or json. Defaults to markdown.

  • render_html (boolean): Specifies whether to render JavaScript on the page before extraction. Defaults to false.

  • openapi_schema (Record<string, any>): A JSON Schema object that defines the structure of the output data. This is required when output_format is set to json.

  • geo_location (string): Specifies the geographic location (ISO2 format) from which the request should be simulated.

AI-Crawler

Basic usage

Input parameters

  • url (string): The starting URL for the crawl.

  • crawl_prompt (string): Instructions defining the types of pages to find and crawl.

  • parse_prompt (string): Instructions for what data to extract from the crawled pages. This is used to automatically generate the openapi_schema when using the crawlWithAutoSchema method.

  • output_format (string): The desired format for the output. Can be either markdown or json. Defaults to markdown.

  • max_pages (integer): The maximum number of pages or sources to return. Defaults to 25.

  • render_html (boolean): Specifies whether to render JavaScript on the pages before extraction. Defaults to false.

  • openapi_schema (Record<string, any>): A JSON Schema object that defines the structure of the output data. This is required when output_format is set to json.

  • geo_location (string): Specifies the geographic location (ISO2 format) from which the request should be simulated.

Browser-Agent

Basic usage

Input parameters

  • url (string): The target URL for the browser agent to start at.

  • browse_prompt (string): Instructions defining the actions the browser agent should perform.

  • parse_prompt (string): Instructions for what data to extract after performing the browser actions. This is used to automatically generate the openapi_schema when using the browseWithAutoSchema method.

  • output_format (string): The desired format for the output. Can be markdown, html, json, or screenshot. Defaults to markdown.

  • render_html (boolean): Specifies whether to render JavaScript on the page. Although this is a browser agent, this flag might influence certain behaviors. Defaults to false.

  • openapi_schema (Record<string, any>): A JSON Schema object that defines the structure of the output data. This is required when output_format is set to json.

  • geo_location (string): Specifies the geographic location (ISO2 format) from which the request should be simulated.

Basic usage

Input parameters

  • query (string): The search query.

  • limit (integer): The maximum number of search results to return. Maximum: 50.

  • render_javascript (boolean): Whether to render JavaScript on the page. Defaults to false.

  • return_content (boolean): Whether to return the markdown content of each of the search result. Defaults to true.

  • geo_location (string): Specifies the geographic location (ISO2 format) from which the request should be simulated.

AI-Map

Basic usage

Input parameters

  • url (string): The target URL to map and extract data from.

  • user_prompt (string): Instructions for what data to extract from the mapped pages.

  • return_sources_limit (integer): The maximum number of sources/pages to return from the mapping process.

  • geo_location (string): The geographical location to use for the mapping request (e.g., 'US', 'UK').

  • render_javascript (boolean): Specifies whether to render JavaScript on the pages before mapping. Defaults to false.

Usage examples

You can find more examples of each application here:

Last updated

Was this helpful?