export type GetApiTakeArgs = {url?: string | undefined, html?: string | undefined, markdown?: string | undefined, signature?: string | undefined, response_type?: ('by_format' | 'empty' | 'json') | undefined, attachment_name?: string | undefined, dark_mode?: boolean | undefined, reduced_motion?: boolean | undefined, reduce_motion?: boolean | undefined, media_type?: ('screen' | 'print') | undefined, scripts?: string | undefined, scripts_wait_until?: (Array<'load' | 'domcontentloaded' | 'networkidle0' | 'networkidle2'>) | undefined, styles?: string | undefined, hide_selectors?: Array | undefined, hover?: string | undefined, error_on_hover_selector_not_found?: boolean | undefined, click?: string | undefined, error_on_click_selector_not_found?: boolean | undefined, include_shadow_dom?: boolean | undefined, bypass_csp?: boolean | undefined, viewport_device?: ('blackberry_playbook' | 'blackberry_playbook_landscape' | 'blackberry_z30' | 'blackberry_z30_landscape' | 'galaxy_note_3' | 'galaxy_note_3_landscape' | 'galaxy_note_ii' | 'galaxy_note_ii_landscape' | 'galaxy_s_iii' | 'galaxy_s_iii_landscape' | 'galaxy_s5' | 'galaxy_s5_landscape' | 'galaxy_s8' | 'galaxy_s8_landscape' | 'galaxy_s9+' | 'galaxy_s9+_landscape' | 'galaxy_tab_s4' | 'galaxy_tab_s4_landscape' | 'ipad' | 'ipad_landscape' | 'ipad_gen_6' | 'ipad_gen_6_landscape' | 'ipad_gen_7' | 'ipad_gen_7_landscape' | 'ipad_mini' | 'ipad_mini_landscape' | 'ipad_pro' | 'ipad_pro_landscape' | 'ipad_pro_11' | 'ipad_pro_11_landscape' | 'iphone_4' | 'iphone_4_landscape' | 'iphone_5' | 'iphone_5_landscape' | 'iphone_6' | 'iphone_6_landscape' | 'iphone_6_plus' | 'iphone_6_plus_landscape' | 'iphone_7' | 'iphone_7_landscape' | 'iphone_7_plus' | 'iphone_7_plus_landscape' | 'iphone_8' | 'iphone_8_landscape' | 'iphone_8_plus' | 'iphone_8_plus_landscape' | 'iphone_se' | 'iphone_se_landscape' | 'iphone_x' | 'iphone_x_landscape' | 'iphone_xr' | 'iphone_xr_landscape' | 'iphone_11' | 'iphone_11_landscape' | 'iphone_11_pro' | 'iphone_11_pro_landscape' | 'iphone_11_pro_max' | 'iphone_11_pro_max_landscape' | 'iphone_12' | 'iphone_12_landscape' | 'iphone_12_pro' | 'iphone_12_pro_landscape' | 'iphone_12_pro_max' | 'iphone_12_pro_max_landscape' | 'iphone_12_mini' | 'iphone_12_mini_landscape' | 'iphone_13' | 'iphone_13_landscape' | 'iphone_13_pro' | 'iphone_13_pro_landscape' | 'iphone_13_pro_max' | 'iphone_13_pro_max_landscape' | 'iphone_13_mini' | 'iphone_13_mini_landscape' | 'iphone_14' | 'iphone_14_landscape' | 'iphone_14_plus' | 'iphone_14_plus_landscape' | 'iphone_14_pro' | 'iphone_14_pro_landscape' | 'iphone_14_pro_max' | 'iphone_14_pro_max_landscape' | 'iphone_15' | 'iphone_15_landscape' | 'iphone_15_plus' | 'iphone_15_plus_landscape' | 'iphone_15_pro' | 'iphone_15_pro_landscape' | 'iphone_15_pro_max' | 'iphone_15_pro_max_landscape' | 'iphone_16' | 'iphone_16_landscape' | 'iphone_16_plus' | 'iphone_16_plus_landscape' | 'jiophone_2' | 'jiophone_2_landscape' | 'kindle_fire_hdx' | 'kindle_fire_hdx_landscape' | 'lg_optimus_l70' | 'lg_optimus_l70_landscape' | 'microsoft_lumia_550' | 'microsoft_lumia_950' | 'microsoft_lumia_950_landscape' | 'nexus_10' | 'nexus_10_landscape' | 'nexus_4' | 'nexus_4_landscape' | 'nexus_5' | 'nexus_5_landscape' | 'nexus_5x' | 'nexus_5x_landscape' | 'nexus_6' | 'nexus_6_landscape' | 'nexus_6p' | 'nexus_6p_landscape' | 'nexus_7' | 'nexus_7_landscape' | 'nokia_lumia_520' | 'nokia_lumia_520_landscape' | 'nokia_n9' | 'nokia_n9_landscape' | 'pixel_2' | 'pixel_2_landscape' | 'pixel_2_xl' | 'pixel_2_xl_landscape' | 'pixel_3' | 'pixel_3_landscape' | 'pixel_4' | 'pixel_4_landscape' | 'pixel_4a_5g' | 'pixel_4a_5g_landscape' | 'pixel_5' | 'pixel_5_landscape' | 'moto_g4' | 'moto_g4_landscape') | undefined, viewport_width?: number | undefined, viewport_height?: number | undefined, device_scale_factor?: number | undefined, viewport_mobile?: boolean | undefined, viewport_has_touch?: boolean | undefined, viewport_landscape?: boolean | undefined, geolocation_latitude?: number | undefined, geolocation_longitude?: number | undefined, geolocation_accuracy?: number | undefined, ip_country_code?: ('us' | 'gb' | 'de' | 'it' | 'fr' | 'cn' | 'ca' | 'es' | 'jp' | 'kr' | 'in' | 'au' | 'br' | 'mx' | 'nz' | 'pe' | 'is' | 'ie') | undefined, block_cookie_banners?: boolean | undefined, block_banners_by_heuristics?: boolean | undefined, block_chats?: boolean | undefined, block_ads?: boolean | undefined, block_trackers?: boolean | undefined, block_requests?: Array | undefined, block_resources?: (Array<'document' | 'stylesheet' | 'image' | 'media' | 'font' | 'script' | 'texttrack' | 'xhr' | 'fetch' | 'eventsource' | 'websocket' | 'manifest' | 'other'>) | undefined, cache?: boolean | undefined, cache_ttl?: number | undefined, cache_key?: string | undefined, user_agent?: string | undefined, authorization?: string | undefined, headers?: Array | undefined, cookies?: Array | undefined, proxy?: string | undefined, proxy_bypass_hosts?: Array | undefined, time_zone?: ('America/Belize' | 'America/Cayman' | 'America/Chicago' | 'America/Costa_Rica' | 'America/Denver' | 'America/Edmonton' | 'America/El_Salvador' | 'America/Guatemala' | 'America/Guayaquil' | 'America/Hermosillo' | 'America/Jamaica' | 'America/Los_Angeles' | 'America/Mexico_City' | 'America/Nassau' | 'America/New_York' | 'America/Panama' | 'America/Port-au-Prince' | 'America/Santiago' | 'America/Tegucigalpa' | 'America/Tijuana' | 'America/Toronto' | 'America/Vancouver' | 'America/Winnipeg' | 'Asia/Kuala_Lumpur' | 'Asia/Shanghai' | 'Asia/Tashkent' | 'Europe/Berlin' | 'Europe/Kiev' | 'Europe/Lisbon' | 'Europe/London' | 'Europe/Madrid' | 'Pacific/Auckland' | 'Pacific/Majuro') | undefined, delay?: number | undefined, timeout?: number | undefined, navigation_timeout?: number | undefined, wait_until?: (Array<'load' | 'domcontentloaded' | 'networkidle0' | 'networkidle2'>) | undefined, wait_for_selector?: string | undefined, wait_for_selector_algorithm?: ('at_least_one' | 'at_least_by_count') | undefined, fail_if_content_contains?: Array | undefined, fail_if_content_missing?: Array | undefined, fail_if_request_failed?: Array | undefined, ignore_host_errors?: boolean | undefined, request_gpu_rendering?: boolean | undefined, fail_if_gpu_rendering_fails?: boolean | undefined, async?: boolean | undefined, webhook_url?: string | undefined, webhook_sign?: boolean | undefined, webhook_errors?: boolean | undefined, external_identifier?: string | undefined, store?: boolean | undefined, storage_bucket?: string | undefined, storage_path?: string | undefined, storage_endpoint?: string | undefined, storage_access_key_id?: string | undefined, storage_secret_access_key?: string | undefined, storage_acl?: ('public-read' | '') | undefined, storage_class?: ('standard' | 'reduced_redundancy' | 'standard_ia' | 'onezone_ia' | 'intelligent_tiering' | 'glacier' | 'deep_archive' | 'outposts' | 'glacier_ir') | undefined, storage_return_location?: boolean | undefined, metadata_fonts?: boolean | undefined, metadata_content?: boolean | undefined, metadata_content_format?: ('html' | 'markdown') | undefined, metadata_page_title?: boolean | undefined, metadata_open_graph?: boolean | undefined, metadata_http_response_status_code?: boolean | undefined, metadata_http_response_headers?: boolean | undefined, metadata_icon?: boolean | undefined, selector?: string | undefined, selector_algorithm?: ('clip' | 'default') | undefined, selector_scroll_into_view?: boolean | undefined, error_on_selector_not_found?: boolean | undefined, scroll_into_view?: string | undefined, scroll_into_view_adjust_top?: number | undefined, format?: ('png' | 'jpeg' | 'jpg' | 'webp' | 'gif' | 'jp2' | 'tiff' | 'avif' | 'heif' | 'pdf' | 'html' | 'markdown') | undefined, clip_x?: number | undefined, clip_y?: number | undefined, clip_width?: number | undefined, clip_height?: number | undefined, image_quality?: number | undefined, image_width?: number | undefined, image_height?: number | undefined, omit_background?: boolean | undefined, full_page?: boolean | undefined, full_page_scroll?: boolean | undefined, full_page_scroll_delay?: number | undefined, full_page_scroll_by?: number | undefined, full_page_max_height?: number | undefined, full_page_algorithm?: ('by_sections' | 'default') | undefined, full_page_slices?: boolean | undefined, full_page_slice_height?: number | undefined, full_page_slice_overlap_height?: number | undefined, capture_beyond_viewport?: boolean | undefined, pdf_print_background?: boolean | undefined, pdf_fit_one_page?: boolean | undefined, pdf_landscape?: boolean | undefined, pdf_paper_format?: ('a0' | 'a1' | 'a2' | 'a3' | 'a4' | 'a5' | 'a6' | 'legal' | 'letter' | 'tabloid') | undefined, pdf_margin?: string | undefined, pdf_margin_top?: string | undefined, pdf_margin_right?: string | undefined, pdf_margin_bottom?: string | undefined, pdf_margin_left?: string | undefined, metadata_image_size?: boolean | undefined, vision_prompt?: string | undefined, vision_max_tokens?: number | undefined, openai_api_key?: string | undefined}; export type GetApiTakeOptions = {baseUrl?: string | undefined, accessKeyQuery?: string | undefined, fetch?: typeof fetch | undefined}; /** * Generate a screenshot or PDF of a website, render HTML, or Markdown * * GET /take * * Also accepts auth: accessKeyHeader */ export const getApiTake = async (args: GetApiTakeArgs, options?: GetApiTakeOptions) => { const {baseUrl = "https://api.screenshotone.com", fetch: fetchFn = fetch, accessKeyQuery} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "image/png") if (args.url != null) query.append("url", String(args.url)) if (args.html != null) query.append("html", String(args.html)) if (args.markdown != null) query.append("markdown", String(args.markdown)) if (args.signature != null) query.append("signature", String(args.signature)) if (args.response_type != null) query.append("response_type", String(args.response_type)) if (args.attachment_name != null) query.append("attachment_name", String(args.attachment_name)) if (args.dark_mode != null) query.append("dark_mode", String(args.dark_mode)) if (args.reduced_motion != null) query.append("reduced_motion", String(args.reduced_motion)) if (args.reduce_motion != null) query.append("reduce_motion", String(args.reduce_motion)) if (args.media_type != null) query.append("media_type", String(args.media_type)) if (args.scripts != null) query.append("scripts", String(args.scripts)) for (const item of args.scripts_wait_until ?? []) query.append("scripts_wait_until", String(item)) if (args.styles != null) query.append("styles", String(args.styles)) for (const item of args.hide_selectors ?? []) query.append("hide_selectors", String(item)) if (args.hover != null) query.append("hover", String(args.hover)) if (args.error_on_hover_selector_not_found != null) query.append("error_on_hover_selector_not_found", String(args.error_on_hover_selector_not_found)) if (args.click != null) query.append("click", String(args.click)) if (args.error_on_click_selector_not_found != null) query.append("error_on_click_selector_not_found", String(args.error_on_click_selector_not_found)) if (args.include_shadow_dom != null) query.append("include_shadow_dom", String(args.include_shadow_dom)) if (args.bypass_csp != null) query.append("bypass_csp", String(args.bypass_csp)) if (args.viewport_device != null) query.append("viewport_device", String(args.viewport_device)) if (args.viewport_width != null) query.append("viewport_width", String(args.viewport_width)) if (args.viewport_height != null) query.append("viewport_height", String(args.viewport_height)) if (args.device_scale_factor != null) query.append("device_scale_factor", String(args.device_scale_factor)) if (args.viewport_mobile != null) query.append("viewport_mobile", String(args.viewport_mobile)) if (args.viewport_has_touch != null) query.append("viewport_has_touch", String(args.viewport_has_touch)) if (args.viewport_landscape != null) query.append("viewport_landscape", String(args.viewport_landscape)) if (args.geolocation_latitude != null) query.append("geolocation_latitude", String(args.geolocation_latitude)) if (args.geolocation_longitude != null) query.append("geolocation_longitude", String(args.geolocation_longitude)) if (args.geolocation_accuracy != null) query.append("geolocation_accuracy", String(args.geolocation_accuracy)) if (args.ip_country_code != null) query.append("ip_country_code", String(args.ip_country_code)) if (args.block_cookie_banners != null) query.append("block_cookie_banners", String(args.block_cookie_banners)) if (args.block_banners_by_heuristics != null) query.append("block_banners_by_heuristics", String(args.block_banners_by_heuristics)) if (args.block_chats != null) query.append("block_chats", String(args.block_chats)) if (args.block_ads != null) query.append("block_ads", String(args.block_ads)) if (args.block_trackers != null) query.append("block_trackers", String(args.block_trackers)) for (const item of args.block_requests ?? []) query.append("block_requests", String(item)) for (const item of args.block_resources ?? []) query.append("block_resources", String(item)) if (args.cache != null) query.append("cache", String(args.cache)) if (args.cache_ttl != null) query.append("cache_ttl", String(args.cache_ttl)) if (args.cache_key != null) query.append("cache_key", String(args.cache_key)) if (args.user_agent != null) query.append("user_agent", String(args.user_agent)) if (args.authorization != null) query.append("authorization", String(args.authorization)) for (const item of args.headers ?? []) query.append("headers", String(item)) for (const item of args.cookies ?? []) query.append("cookies", String(item)) if (args.proxy != null) query.append("proxy", String(args.proxy)) for (const item of args.proxy_bypass_hosts ?? []) query.append("proxy_bypass_hosts", String(item)) if (args.time_zone != null) query.append("time_zone", String(args.time_zone)) if (args.delay != null) query.append("delay", String(args.delay)) if (args.timeout != null) query.append("timeout", String(args.timeout)) if (args.navigation_timeout != null) query.append("navigation_timeout", String(args.navigation_timeout)) for (const item of args.wait_until ?? []) query.append("wait_until", String(item)) if (args.wait_for_selector != null) query.append("wait_for_selector", String(args.wait_for_selector)) if (args.wait_for_selector_algorithm != null) query.append("wait_for_selector_algorithm", String(args.wait_for_selector_algorithm)) for (const item of args.fail_if_content_contains ?? []) query.append("fail_if_content_contains", String(item)) for (const item of args.fail_if_content_missing ?? []) query.append("fail_if_content_missing", String(item)) for (const item of args.fail_if_request_failed ?? []) query.append("fail_if_request_failed", String(item)) if (args.ignore_host_errors != null) query.append("ignore_host_errors", String(args.ignore_host_errors)) if (args.request_gpu_rendering != null) query.append("request_gpu_rendering", String(args.request_gpu_rendering)) if (args.fail_if_gpu_rendering_fails != null) query.append("fail_if_gpu_rendering_fails", String(args.fail_if_gpu_rendering_fails)) if (args.async != null) query.append("async", String(args.async)) if (args.webhook_url != null) query.append("webhook_url", String(args.webhook_url)) if (args.webhook_sign != null) query.append("webhook_sign", String(args.webhook_sign)) if (args.webhook_errors != null) query.append("webhook_errors", String(args.webhook_errors)) if (args.external_identifier != null) query.append("external_identifier", String(args.external_identifier)) if (args.store != null) query.append("store", String(args.store)) if (args.storage_bucket != null) query.append("storage_bucket", String(args.storage_bucket)) if (args.storage_path != null) query.append("storage_path", String(args.storage_path)) if (args.storage_endpoint != null) query.append("storage_endpoint", String(args.storage_endpoint)) if (args.storage_access_key_id != null) query.append("storage_access_key_id", String(args.storage_access_key_id)) if (args.storage_secret_access_key != null) query.append("storage_secret_access_key", String(args.storage_secret_access_key)) if (args.storage_acl != null) query.append("storage_acl", String(args.storage_acl)) if (args.storage_class != null) query.append("storage_class", String(args.storage_class)) if (args.storage_return_location != null) query.append("storage_return_location", String(args.storage_return_location)) if (args.metadata_fonts != null) query.append("metadata_fonts", String(args.metadata_fonts)) if (args.metadata_content != null) query.append("metadata_content", String(args.metadata_content)) if (args.metadata_content_format != null) query.append("metadata_content_format", String(args.metadata_content_format)) if (args.metadata_page_title != null) query.append("metadata_page_title", String(args.metadata_page_title)) if (args.metadata_open_graph != null) query.append("metadata_open_graph", String(args.metadata_open_graph)) if (args.metadata_http_response_status_code != null) query.append("metadata_http_response_status_code", String(args.metadata_http_response_status_code)) if (args.metadata_http_response_headers != null) query.append("metadata_http_response_headers", String(args.metadata_http_response_headers)) if (args.metadata_icon != null) query.append("metadata_icon", String(args.metadata_icon)) if (args.selector != null) query.append("selector", String(args.selector)) if (args.selector_algorithm != null) query.append("selector_algorithm", String(args.selector_algorithm)) if (args.selector_scroll_into_view != null) query.append("selector_scroll_into_view", String(args.selector_scroll_into_view)) if (args.error_on_selector_not_found != null) query.append("error_on_selector_not_found", String(args.error_on_selector_not_found)) if (args.scroll_into_view != null) query.append("scroll_into_view", String(args.scroll_into_view)) if (args.scroll_into_view_adjust_top != null) query.append("scroll_into_view_adjust_top", String(args.scroll_into_view_adjust_top)) if (args.format != null) query.append("format", String(args.format)) if (args.clip_x != null) query.append("clip_x", String(args.clip_x)) if (args.clip_y != null) query.append("clip_y", String(args.clip_y)) if (args.clip_width != null) query.append("clip_width", String(args.clip_width)) if (args.clip_height != null) query.append("clip_height", String(args.clip_height)) if (args.image_quality != null) query.append("image_quality", String(args.image_quality)) if (args.image_width != null) query.append("image_width", String(args.image_width)) if (args.image_height != null) query.append("image_height", String(args.image_height)) if (args.omit_background != null) query.append("omit_background", String(args.omit_background)) if (args.full_page != null) query.append("full_page", String(args.full_page)) if (args.full_page_scroll != null) query.append("full_page_scroll", String(args.full_page_scroll)) if (args.full_page_scroll_delay != null) query.append("full_page_scroll_delay", String(args.full_page_scroll_delay)) if (args.full_page_scroll_by != null) query.append("full_page_scroll_by", String(args.full_page_scroll_by)) if (args.full_page_max_height != null) query.append("full_page_max_height", String(args.full_page_max_height)) if (args.full_page_algorithm != null) query.append("full_page_algorithm", String(args.full_page_algorithm)) if (args.full_page_slices != null) query.append("full_page_slices", String(args.full_page_slices)) if (args.full_page_slice_height != null) query.append("full_page_slice_height", String(args.full_page_slice_height)) if (args.full_page_slice_overlap_height != null) query.append("full_page_slice_overlap_height", String(args.full_page_slice_overlap_height)) if (args.capture_beyond_viewport != null) query.append("capture_beyond_viewport", String(args.capture_beyond_viewport)) if (args.pdf_print_background != null) query.append("pdf_print_background", String(args.pdf_print_background)) if (args.pdf_fit_one_page != null) query.append("pdf_fit_one_page", String(args.pdf_fit_one_page)) if (args.pdf_landscape != null) query.append("pdf_landscape", String(args.pdf_landscape)) if (args.pdf_paper_format != null) query.append("pdf_paper_format", String(args.pdf_paper_format)) if (args.pdf_margin != null) query.append("pdf_margin", String(args.pdf_margin)) if (args.pdf_margin_top != null) query.append("pdf_margin_top", String(args.pdf_margin_top)) if (args.pdf_margin_right != null) query.append("pdf_margin_right", String(args.pdf_margin_right)) if (args.pdf_margin_bottom != null) query.append("pdf_margin_bottom", String(args.pdf_margin_bottom)) if (args.pdf_margin_left != null) query.append("pdf_margin_left", String(args.pdf_margin_left)) if (args.metadata_image_size != null) query.append("metadata_image_size", String(args.metadata_image_size)) if (args.vision_prompt != null) query.append("vision_prompt", String(args.vision_prompt)) if (args.vision_max_tokens != null) query.append("vision_max_tokens", String(args.vision_max_tokens)) if (args.openai_api_key != null) query.append("openai_api_key", String(args.openai_api_key)) if (accessKeyQuery !== undefined) query.set("access_key", accessKeyQuery) const url = `${baseUrl.replace(/\/+$/, '')}/take${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };