export type CreateApiTakeArgs = {body: {access_key?: string | undefined, url?: string | undefined, html?: string | undefined, markdown?: 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 CreateApiTakeOptions = {baseUrl?: string | undefined, accessKeyQuery?: string | undefined, fetch?: typeof fetch | undefined}; /** * Generate a screenshot or PDF of a website, render HTML, or Markdown * * POST /take * * Also accepts auth: accessKeyHeader */ export const createApiTake = async (args: CreateApiTakeArgs, options?: CreateApiTakeOptions) => { const {baseUrl = "https://api.screenshotone.com", fetch: fetchFn = fetch, accessKeyQuery} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "image/png") if (accessKeyQuery !== undefined) query.set("access_key", accessKeyQuery) const url = `${baseUrl.replace(/\/+$/, '')}/take${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };