### Quick Start with JigsawStack HTML To Any API in JavaScript Source: https://github.com/jigsawstack/docs/blob/main/docs/examples/computer-vision/screenshot.mdx Demonstrates how to quickly get started with the JigsawStack HTML To Any API using JavaScript. It shows how to initialize the client, set parameters for URL, quality, full page, type, and dark mode, and save the resulting image to a file. ```JavaScript import { JigsawStack } from 'jigsawstack'; import fs from 'fs'; import path from 'path'; const jigsaw = new JigsawStack('your-api-key'); const params = { url: "https://jigsawstack.com", quality: 80, full_page: true, type: "jpeg", dark_mode: true }; const result = await jigsaw.web.html_to_any(params); const buffer = await result.arrayBuffer(); fs.writeFileSync( path.join(__dirname, 'screenshot.jpeg'), Buffer.from(buffer) ); ``` -------------------------------- ### Install JigsawStack SDK Source: https://github.com/jigsawstack/docs/blob/main/docs/introduction.mdx Instructions to install the JigsawStack SDK using various package managers for Node.js and Python environments. ```bash npm install jigsawstack # or yarn add jigsawstack # or pnpm add jigsawstack # or bun add jigsawstack ``` ```bash pip install jigsawstack ``` -------------------------------- ### Install JigsawStack Node.js SDK Source: https://github.com/jigsawstack/docs/blob/main/docs/quick-start/node/introduction.mdx Instructions for installing the JigsawStack SDK using various Node.js package managers like npm, yarn, pnpm, and bun. ```bash npm install jigsawstack ``` ```bash yarn add jigsawstack ``` ```bash pnpm add jigsawstack ``` ```bash bun add jigsawstack ``` -------------------------------- ### Install JigsawStack Python SDK Source: https://github.com/jigsawstack/docs/blob/main/docs/quick-start/python/introduction.mdx Instructions to install the JigsawStack Python SDK using popular package managers like pip, pipenv, and poetry. ```bash pip install jigsawstack ``` ```bash pipenv install jigsawstack ``` ```bash poetry add jigsawstack ``` -------------------------------- ### Complete Web Application Integration Example Source: https://github.com/jigsawstack/docs/blob/main/docs/quick-start/node/window-ai.mdx A full HTML example demonstrating the integration of JigsawStack with `window.ai` in a web page, including initialization and a functional sentiment analysis input field. ```html JigsawStack window.ai Demo

JigsawStack window.ai Demo

Sentiment Analysis

``` -------------------------------- ### Install JigsawStack SDK Source: https://github.com/jigsawstack/docs/blob/main/docs/integration/groq.mdx Install the JigsawStack SDK using npm for JavaScript projects or pip for Python projects. ```bash npm i jigsawstack ``` ```bash pip install jigsawstack ``` -------------------------------- ### Retrieve Prompt Engine Entry by ID Source: https://github.com/jigsawstack/docs/blob/main/snippets/code-req-examples/prompt-engine-retrieve.mdx These code examples demonstrate how to fetch a specific prompt engine entry from the JigsawStack API using its unique identifier. The examples cover both SDK usage (where available) and direct HTTP GET requests, requiring an API key for authentication. ```Javascript import { JigsawStack } from "jigsawstack"; const jigsaw = JigsawStack({ apiKey: "your-api-key" }); const response = await jigsaw.prompt_engine.get({ "id": "14d675d5-b309-463d-8906-1be65af74c43" }) ``` ```Python from jigsawstack import JigsawStack jigsaw = JigsawStack(api_key="your-api-key") response = jigsaw.prompt_engine.get({ "id": "14d675d5-b309-463d-8906-1be65af74c43" }) ``` ```Curl curl https://api.jigsawstack.com/v1/prompt_engine/14d675d5-b309-463d-8906-1be65af74c43?id=14d675d5-b309-463d-8906-1be65af74c43 \ -X GET \ -H 'Content-Type: application/json' \ -H 'x-api-key: your-api-key' ``` ```PHP '14d675d5-b309-463d-8906-1be65af74c43', } uri.query = URI.encode_www_form(params) req = Net::HTTP::Get.new(uri) req.content_type = 'application/json' req['x-api-key'] = 'your-api-key' req_options = { use_ssl: uri.scheme == 'https' } res = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http| http.request(req) end ``` ```Go package main import ( "fmt" "io" "log" "net/http" ) func main() { client := &http.Client{} req, err := http.NewRequest("GET", "https://api.jigsawstack.com/v1/prompt_engine/14d675d5-b309-463d-8906-1be65af74c43?id=14d675d5-b309-463d-8906-1be65af74c43", nil) if err != nil { log.Fatal(err) } req.Header.Set("Content-Type", "application/json") req.Header.Set("x-api-key", "your-api-key") resp, err := client.Do(req) if err != nil { log.Fatal(err) } defer resp.Body.Close() bodyText, err := io.ReadAll(resp.Body) if err != nil { log.Fatal(err) } fmt.Printf("%s\n", bodyText) } ``` ```Java import java.io.IOException; import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://api.jigsawstack.com/v1/prompt_engine/14d675d5-b309-463d-8906-1be65af74c43?id=14d675d5-b309-463d-8906-1be65af74c43")) .GET() .setHeader("Content-Type", "application/json") .setHeader("x-api-key", "your-api-key") .build(); HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); ``` ```Swift import Foundation let url = URL(string: "https://api.jigsawstack.com/v1/prompt_engine/14d675d5-b309-463d-8906-1be65af74c43?id=14d675d5-b309-463d-8906-1be65af74c43")! let headers = [ "Content-Type": "application/json", "x-api-key": "your-api-key" ] var request = URLRequest(url: url) request.allHTTPHeaderFields = headers let task = URLSession.shared.dataTask(with: request) { (data, response, error) in if let error = error { print(error) } else if let data = data { let str = String(data: data, encoding: .utf8) print(str ?? "") } } task.resume() ``` ```Dart import 'package:http/http.dart' as http; void main() async { final headers = { 'Content-Type': 'application/json', 'x-api-key': 'your-api-key', }; final params = { 'id': '14d675d5-b309-463d-8906-1be65af74c43', }; final url = Uri.parse('https://api.jigsawstack.com/v1/prompt_engine/14d675d5-b309-463d-8906-1be65af74c43') .replace(queryParameters: params); final res = await http.get(url, headers: headers); final status = res.statusCode; if (status != 200) throw Exception('http.get error: statusCode= $status'); print(res.body); } ``` ```Kotlin import java.io.IOException import okhttp3.OkHttpClient import okhttp3.Request val client = OkHttpClient() val request = Request.Builder() .url("https://api.jigsawstack.com/v1/prompt_engine/14d675d5-b309-463d-8906-1be65af74c43?id=14d675d5-b309-463d-8906-1be65af74c43") .header("Content-Type", "application/json") .header("x-api-key", "your-api-key") .build() client.newCall(request).execute().use { response -> if (!response.isSuccessful) throw IOException("Unexpected code $response") response.body!!.string() } ``` ```C# using System.Net.Http; using System.Net.Http.Headers; HttpClient client = new HttpClient(); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "https://api.jigsawstack.com/v1/prompt_engine/14d675d5-b309-463d-8906-1be65af74c43?id=14d675d5-b309-463d-8906-1be65af74c43"); ``` -------------------------------- ### Install Mintlify CLI Globally Source: https://github.com/jigsawstack/docs/blob/main/README.md This command installs the Mintlify Command Line Interface globally using npm, which is necessary for previewing JigsawStack documentation changes locally. ```shell npm i -g mintlify ``` -------------------------------- ### Quick Start: Summarize Text and Generate Bullet Points with JigsawStack Source: https://github.com/jigsawstack/docs/blob/main/docs/examples/core-ai/summary.mdx This JavaScript example demonstrates how to initialize the JigsawStack client and use the Summarization API to generate both a paragraph-style summary and a bullet-point summary from a given text input. ```JavaScript import { JigsawStack } from 'jigsawstack'; const jigsaw = new JigsawStack('your-api-key'); // Text summary example const response = await jigsaw.ai.summary({ text: "The renewable energy sector saw unprecedented growth in 2022, with solar and wind installation rates exceeding forecasts by 25%. Despite supply chain challenges related to the pandemic, global clean energy investment topped $500 billion for the first time. Notably, several major oil companies increased their renewable investments, with commitments to achieve carbon neutrality by 2050. However, challenges remain, including grid integration issues, regulatory hurdles in developing markets, and the need for advanced energy storage solutions. Experts project continued acceleration through 2023, particularly in utility-scale solar and offshore wind development." }); console.log(response); // Bullet point summary example const bulletResponse = await jigsaw.ai.summary({ text: "The renewable energy sector saw unprecedented growth in 2022...", type: "points", max_points: 5 }); console.log(bulletResponse); ``` -------------------------------- ### Install JigsawStack SDK Source: https://github.com/jigsawstack/docs/blob/main/docs/learn/prompt/how-prompt-engine-works.mdx This snippet demonstrates how to install the JigsawStack SDK using npm for JavaScript projects or pip for Python projects. This is the first step to integrate the SDK into your application. ```JavaScript npm i jigsawstack ``` ```Python pip install jigsawstack ``` -------------------------------- ### Quick Start: Extracting Data with JigsawStack AI Web Scraper (JavaScript) Source: https://github.com/jigsawstack/docs/blob/main/docs/examples/web/web-scraper.mdx This example demonstrates how to initialize the JigsawStack client with an API key and use the web.ai_scrape method to extract specific information (post titles, points, and usernames) from a website like Hacker News using natural language prompts. ```Javascript import { JigsawStack } from "jigsawstack"; const jigsaw = JigsawStack({ apiKey: "your-api-key" }); const response = await jigsaw.web.ai_scrape({ url: "https://news.ycombinator.com", element_prompts: ["post_titles", "post_points", "post_username"], }); console.log(response); ``` -------------------------------- ### Perform Sentiment Analysis with JigsawStack API Source: https://github.com/jigsawstack/docs/blob/main/docs/examples/language-models/sentiment.mdx This example demonstrates how to use the JigsawStack SDK/API to perform sentiment analysis on a given text. It shows initialization with an API key and making a request to the sentiment endpoint, then printing the response. ```Javascript import { JigsawStack } from "jigsawstack"; const jigsaw = JigsawStack({ apiKey: "your-api-key" }); const response = await jigsaw.sentiment({ text: "I absolutely love this product! It's amazing." }); console.log(response); ``` ```Python from jigsawstack import JigsawStack jigsaw = JigsawStack(api_key="your-api-key") response = jigsaw.sentiment({ "text": "I absolutely love this product! It's amazing." }) print(response) ``` ```bash curl -X POST https://api.jigsawstack.com/v1/ai/sentiment \ -H "Content-Type: application/json" \ -H "x-api-key: your-api-key" \ -d '{ "text": "I absolutely love this product! It'\''s amazing." }' ``` -------------------------------- ### Run Mintlify Local Development Server Source: https://github.com/jigsawstack/docs/blob/main/README.md Execute this command at the root of your documentation directory (where mint.json is located) to start the local development server for previewing JigsawStack documentation. ```shell mintlify dev ``` -------------------------------- ### Sample Prompt Payloads for Direct Run Source: https://github.com/jigsawstack/docs/blob/main/docs/api-reference/prompt-engine/run-direct.mdx Examples demonstrating different structures for the `return_prompt` field when running a prompt directly, including string, array of objects, and object formats. ```javascript { prompt: "Tell me a story about {about}", inputs: [ { key: "about", optional: false, }, ], return_prompt: "Return the result in a markdown format", "prompt_guard": ["sexual_content", "defamation"], "input_values": { "about": "Santorini" } } ``` ```javascript { prompt: "Tell me a story about {about}", inputs: [ { key: "about", optional: false, initial_value: "Leaning Tower of Pisa" }, ], return_prompt: [{ excerpt: "short story text", summary: "summary of story" }], "prompt_guard": ["sexual_content", "defamation"], "input_values": { "about": "Santorini" } } ``` ```javascript { prompt: "Tell me a story about {about}", inputs: [ { key: "about", optional: false, initial_value: "Leaning Tower of Pisa" }, ], return_prompt: { excerpt: "short story text", summary: "summary of story" }, "prompt_guard": ["sexual_content", "defamation"], "input_values": { "about": "Santorini" } } ``` -------------------------------- ### Example API Response for Prompt Creation (APIDOC) Source: https://github.com/jigsawstack/docs/blob/main/snippets/code-req-examples/prompt-engine-retrieve.mdx This API documentation snippet illustrates the typical JSON structure returned by a Jigsawstack API endpoint, specifically for prompt creation. It details various fields such as success status, unique ID, input parameters, prompt definitions, guard settings, and usage statistics, providing a comprehensive example of a successful response payload. ```JSON { "success": true, "id": "14d675d5-b309-463d-8906-1be65af74c43", "inputs": [ { "key": "about", "optional": false } ], "prompt": "Tell me a story about {about}", "return_prompt": "Return the result in a markdown format", "created_at": "2025-04-11T21:34:29.434339+00:00", "prompt_guard": [ "sexual_content", "defamation" ], "optimized_prompt": "Create a captivating story centered around the theme of {about}, incorporating vivid characters and an engaging plot.", "use_internet": false, "public": false, "name": null, "user_id": null, "public_status": null, "updated_at": "2025-04-11T21:34:29.434339+00:00", "_usage": { "input_tokens": 1, "output_tokens": 142, "inference_time_tokens": 202, "total_tokens": 345 } } ``` -------------------------------- ### Generate Images with JigsawStack API Source: https://github.com/jigsawstack/docs/blob/main/snippets/code-req-examples/image-generation.mdx This snippet demonstrates how to make a POST request to the JigsawStack Image Generation API endpoint, providing a text prompt to generate an image. It includes examples using SDKs where available, and direct HTTP requests for other languages. ```Javascript import { JigsawStack } from "jigsawstack"; const jigsaw = JigsawStack({ apiKey: "your-api-key" }); const response = await jigsaw.image_generation({ "prompt": "A beautiful sunset over a calm ocean" }) ``` ```Python from jigsawstack import JigsawStack jigsaw = JigsawStack(api_key="your-api-key") response = jigsaw.image_generation({ "prompt": "A beautiful sunset over a calm ocean" }) ``` ```Bash curl https://api.jigsawstack.com/v1/ai/image_generation \ -X POST \ -H 'Content-Type: application/json' \ -H 'x-api-key: your-api-key' \ -d '{"prompt":"A beautiful sunset over a calm ocean"}' ``` ```PHP 'A beautiful sunset over a calm ocean' }.to_json req_options = { use_ssl: uri.scheme == 'https' } res = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http| http.request(req) end ``` ```Go package main import ( "fmt" "io" "log" "net/http" "strings" ) func main() { client := &http.Client{} var data = strings.NewReader(`{"prompt":"A beautiful sunset over a calm ocean"}`) req, err := http.NewRequest("POST", "https://api.jigsawstack.com/v1/ai/image_generation", data) if err != nil { log.Fatal(err) } req.Header.Set("Content-Type", "application/json") req.Header.Set("x-api-key", "your-api-key") resp, err := client.Do(req) if err != nil { log.Fatal(err) } defer resp.Body.Close() bodyText, err := io.ReadAll(resp.Body) if err != nil { log.Fatal(err) } fmt.Printf("%s\n", bodyText) } ``` ```Java import java.io.IOException; import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpRequest.BodyPublishers; import java.net.http.HttpResponse; HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://api.jigsawstack.com/v1/ai/image_generation")) .POST(BodyPublishers.ofString("{\"prompt\":\"A beautiful sunset over a calm ocean\"}")) .setHeader("Content-Type", "application/json") .setHeader("x-api-key", "your-api-key") .build(); HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); ``` ```Swift import Foundation let jsonData = [ "prompt": "A beautiful sunset over a calm ocean" ] as [String : Any] let data = try! JSONSerialization.data(withJSONObject: jsonData, options: []) let url = URL(string: "https://api.jigsawstack.com/v1/ai/image_generation")! let headers = [ "Content-Type": "application/json", "x-api-key": "your-api-key" ] var request = URLRequest(url: url); request.httpMethod = "POST"; request.allHTTPHeaderFields = headers; request.httpBody = data as Data; let task = URLSession.shared.dataTask(with: request) { (data, response, error) in if let error = error { print(error) } else if let data = data { let str = String(data: data, encoding: .utf8) print(str ?? "") } } task.resume(); ``` ```Dart import 'package:http/http.dart' as http; void main() async { final headers = { 'Content-Type': 'application/json', 'x-api-key': 'your-api-key', }; final data = '{"prompt":"A beautiful sunset over a calm ocean"}'; final url = Uri.parse('https://api.jigsawstack.com/v1/ai/image_generation'); final res = await http.post(url, headers: headers, body: data); final status = res.statusCode; if (status != 200) throw Exception('http.post error: statusCode= $status'); print(res.body); } ``` ```Kotlin import java.io.IOException import okhttp3.MediaType.Companion.toMediaType import okhttp3.OkHttpClient import okhttp3.Request import okhttp3.RequestBody.Companion.toRequestBody val client = OkHttpClient() val MEDIA_TYPE = "application/json".toMediaType() val requestBody = "{\"prompt\":\"A beautiful sunset over a calm ocean\"}" val request = Request.Builder() .url("https://api.jigsawstack.com/v1/ai/image_generation") .post(requestBody.toRequestBody(MEDIA_TYPE)) .header("Content-Type", "application/json") .header("x-api-key", "your-api-key") .build() client.newCall(request).execute().use { response -> if (!response.isSuccessful) throw IOException("Unexpected code $response") ``` -------------------------------- ### Create Audio Clone with JigsawStack API Source: https://github.com/jigsawstack/docs/blob/main/snippets/code-req-examples/text-to-speech-create-clone.mdx This example demonstrates how to create an audio clone using the JigsawStack API's Text-to-Speech (TTS) service. It sends a POST request to the `/v1/ai/tts/clone` endpoint with a URL to an audio file and a desired name for the clone. An API key is required for authentication. ```Javascript import { JigsawStack } from "jigsawstack"; const jigsaw = JigsawStack({ apiKey: "your-api-key" }); const response = await jigsaw.audio.create_clone({ "url": "https://jigsawstack.com/preview/tts-clone-example.mp3", "name": "Elon Musk" }) ``` ```Python from jigsawstack import JigsawStack jigsaw = JigsawStack(api_key="your-api-key") response = jigsaw.audio.create_clone({ "url": "https://jigsawstack.com/preview/tts-clone-example.mp3", "name": "Elon Musk" }) ``` ```Bash curl https://api.jigsawstack.com/v1/ai/tts/clone \ -X POST \ -H 'Content-Type: application/json' \ -H 'x-api-key: your-api-key' \ -d '{"url":"https://jigsawstack.com/preview/tts-clone-example.mp3","name":"Elon Musk"}' ``` ```PHP 'https://jigsawstack.com/preview/tts-clone-example.mp3', 'name' => 'Elon Musk' }.to_json req_options = { use_ssl: uri.scheme == 'https' } res = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http| http.request(req) end ``` ```Go package main import ( "fmt" "io" "log" "net/http" "strings" ) func main() { client := &http.Client{} var data = strings.NewReader(`{"url":"https://jigsawstack.com/preview/tts-clone-example.mp3","name":"Elon Musk"}`) req, err := http.NewRequest("POST", "https://api.jigsawstack.com/v1/ai/tts/clone", data) if err != nil { log.Fatal(err) } req.Header.Set("Content-Type", "application/json") req.Header.Set("x-api-key", "your-api-key") resp, err := client.Do(req) if err != nil { log.Fatal(err) } defer resp.Body.Close() bodyText, err := io.ReadAll(resp.Body) if err != nil { log.Fatal(err) } fmt.Printf("%s\n", bodyText) } ``` ```Java import java.io.IOException; import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpRequest.BodyPublishers; import java.net.http.HttpResponse; HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://api.jigsawstack.com/v1/ai/tts/clone")) .POST(BodyPublishers.ofString("{\"url\":\"https://jigsawstack.com/preview/tts-clone-example.mp3\",\"name\":\"Elon Musk\"}")) .setHeader("Content-Type", "application/json") .setHeader("x-api-key", "your-api-key") .build(); HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); ``` ```Swift import Foundation let jsonData = [ "url": "https://jigsawstack.com/preview/tts-clone-example.mp3", "name": "Elon Musk" ] as [String : Any] let data = try! JSONSerialization.data(withJSONObject: jsonData, options: []) let url = URL(string: "https://api.jigsawstack.com/v1/ai/tts/clone")! let headers = [ "Content-Type": "application/json", "x-api-key": "your-api-key" ] var request = URLRequest(url: url) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = data as Data let task = URLSession.shared.dataTask(with: request) { (data, response, error) in if let error = error { print(error) } else if let data = data { let str = String(data: data, encoding: .utf8) print(str ?? "") } } task.resume() ``` ```Dart import 'package:http/http.dart' as http; void main() async { final headers = { 'Content-Type': 'application/json', 'x-api-key': 'your-api-key', }; final data = '{"url":"https://jigsawstack.com/preview/tts-clone-example.mp3","name":"Elon Musk"}'; final url = Uri.parse('https://api.jigsawstack.com/v1/ai/tts/clone'); final res = await http.post(url, headers: headers, body: data); final status = res.statusCode; if (status != 200) throw Exception('http.post error: statusCode= $status'); print(res.body); } ``` ```Kotlin import java.io.IOException import okhttp3.MediaType.Companion.toMediaType import okhttp3.OkHttpClient import okhttp3.Request import okhttp3.RequestBody.Companion.toRequestBody val client = OkHttpClient() val MEDIA_TYPE = "application/json".toMediaType() val requestBody = "{\"url\":\"https://jigsawstack.com/preview/tts-clone-example.mp3\",\"name\":\"Elon Musk\"}" val request = Request.Builder() ``` -------------------------------- ### JavaScript vOCR Prompt Examples Source: https://github.com/jigsawstack/docs/blob/main/docs/api-reference/ai/vocr.mdx Examples demonstrating how to structure the `prompt` parameter in the vOCR API request body. The prompt can be a single string to describe the image in detail, or an array of strings to retrieve specific data points from the image file. ```javascript { prompt: "Describe the image in detail."; } ``` ```javascript { prompt: ["first name", "last name"]; } ``` -------------------------------- ### Example API Response for Query Suggestions and Usage Metrics Source: https://github.com/jigsawstack/docs/blob/main/snippets/code-req-examples/search-suggestions.mdx This JSON snippet illustrates the structure of an API response from Jigsawstack. It includes a `suggestions` array, providing a list of example queries (e.g., for autocomplete or search features), and an `_usage` object, which details the token consumption for the API call, including input, output, inference time, and total tokens. ```json "suggestions": [ "what is the capital of california", "what is the capital of australia", "what is the capital of canada", "what is the capital of the united states", "what is the capital of england", "what is the capital of texas", "what is the capital of france", "what is the capital of florida", "what is the capital of new york", "what is the capital of italy", "what is the capital of japan", "what is the capital of turkey", "what is the capital of alaska", "what is the capital of georgia", "what is the capital of brazil" ], "_usage": { "input_tokens": 8, "output_tokens": 133, "inference_time_tokens": 332, "total_tokens": 473 } } ``` -------------------------------- ### Example API Response for Listing Prompt Engines Source: https://github.com/jigsawstack/docs/blob/main/snippets/code-req-examples/prompt-engine-list.mdx This JSON snippet shows a typical successful response from the JigsawStack API when listing prompt engines. It includes a success status and an array of prompt engine objects with their IDs, prompts, and input definitions. ```JSON { "success": true, "prompt_engines": [ { "id": "8c769fc6-1d97-4e42-b3c2-414684bc6eba", "prompt": "Tell me a story about {about}", "inputs": [ { ``` -------------------------------- ### Generate Image with Jigsawstack AI API in C# Source: https://github.com/jigsawstack/docs/blob/main/snippets/code-req-examples/image-generation.mdx Illustrates how to make a POST request to the Jigsawstack AI image generation API using C#. This example sets the API key, constructs a JSON payload with a prompt, and sends the request to generate an image. It handles the HTTP response and reads the content as a string. ```csharp using System.Net.Http; using System.Net.Http.Headers; HttpClient client = new HttpClient(); HrttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "https://api.jigsawstack.com/v1/ai/image_generation"); request.Headers.Add("x-api-key", "your-api-key"); request.Content = new StringContent("{\"prompt\":\"A beautiful sunset over a calm ocean\"}"); request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); HttpResponseMessage response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); ``` -------------------------------- ### Jigsawstack Prompt Engine API Response Example Source: https://github.com/jigsawstack/docs/blob/main/snippets/code-req-examples/prompt-engine-create.mdx This JSON snippet provides an example of a successful response received from the Jigsawstack Prompt Engine API after processing a prompt. It includes a success indicator, a unique ID for the prompt engine operation, the optimized prompt, and detailed usage statistics. ```JSON { "success": true, "prompt_engine_id": "8af1dc58-8e2c-4b92-b870-4d5550796646", "optimized_prompt": "Write a detailed and engaging story about {about}, including vivid descriptions, well-developed characters, and a clear beginning, middle, and end.", "_usage": { "input_tokens": 58, "output_tokens": 61, "inference_time_tokens": 1437, "total_tokens": 1556 } } ``` -------------------------------- ### Convert Text to Speech with JigsawStack Source: https://github.com/jigsawstack/docs/blob/main/docs/quick-start/python/introduction.mdx Example of using the JigsawStack Python SDK to convert text into an audio file, specifying the desired voice, and saving the output to a local file. ```python speech = jigsawstack.audio.text_to_speech({ "text": "Welcome to JigsawStack Python SDK!", "voice": "en-US-female" }) # Save the audio to a file with open("welcome_message.mp3", "wb") as audio_file: audio_file.write(speech.content) ``` -------------------------------- ### Authenticate JigsawStack SDK Source: https://github.com/jigsawstack/docs/blob/main/docs/api-reference/authentication.mdx Shows how to initialize the JigsawStack SDK using an API key retrieved from environment variables, providing examples for both JavaScript/TypeScript and Python. ```javascript const jigsawstack = JigsawStack({ apiKey: process.env.JIGSAWSTACK_API_KEY }); ``` ```python jigsawstack = JigsawStack(api_key=os.environ["JIGSAWSTACK_API_KEY"]) ``` -------------------------------- ### Sample Prompt Payload: String Return Type Source: https://github.com/jigsawstack/docs/blob/main/docs/api-reference/prompt-engine/create.mdx Example JSON payload for creating a prompt where the `return_prompt` field is a string, specifying the desired output format for the prompt's result. ```javascript { prompt: "Tell me a story about {about}", inputs: [ { key: "about", optional: false, initial_value: "Leaning Tower of Pisa" } ], return_prompt: "Return the result in a markdown format", "prompt_guard": ["sexual_content", "defamation"] } ``` -------------------------------- ### JigsawStack AI Scraper Response Format Source: https://github.com/jigsawstack/docs/blob/main/docs/quick-start/node/introduction.mdx Example JSON structure returned by the JigsawStack AI web scraper, illustrating how extracted context and selectors are organized in the response. ```json { "page_position": 1, "page_position_length": 3, "context": { "Plan title": ["Free", "Pro", "Team", "Enterprise"], "Plan price": ["$0", "$25", "$599", "Custom"] }, "selectors": { "Plan title": [ "h3.text-foreground.text-2xl.font-normal.uppercase.flex.items-center.gap-4.font-mono" ], "Plan price": [ "div.text-foreground.flex.items-baseline.text-5xl.font-normal.lg\\:text-4xl.xl\\:text-4xl.border-b.border-default.lg\\:min-h-\\[175px\\].py-8.lg\\:pb-0.lg\\:pt-10 p.mt-2.pb-1.font-mono.text-5xl", "div.text-foreground.flex.items-baseline.text-5xl.font-normal.lg\\:text-4xl.xl\\:text-4xl.border-b.border-default.lg\\:min-h-\\[175px\\].py-6.lg\\:pb-0.pt-6 p.mt-2.pb-1.font-mono.text-5xl", "div.text-foreground.flex.items-baseline.text-5xl.font-normal.lg\\:text-4xl.xl\\:text-4xl.border-b.border-default.lg\\:min-h-\\[175px\\].py-8.lg\\:pb-0.lg\\:pt-10 p.mt-2.pb-1.font-mono.text-4xl" ] }, ... ``` -------------------------------- ### Define Prompt with String Return Type Source: https://github.com/jigsawstack/docs/blob/main/docs/learn/prompt/introduction.mdx Example JSON structure for a prompt definition where the expected output is a simple string. It includes a dynamic variable 'item' and a specific instruction for the return format. ```javascript { prompt: "Tell me about {item}", inputs: [ { key: "item", optional: false, initial_value: "Leaning Tower of Pisa", }, ], return_prompt: "Return the result in a markdown format", } ``` -------------------------------- ### JSON Response Fragment for Timed Text and Usage Data Source: https://github.com/jigsawstack/docs/blob/main/snippets/code-req-examples/speech-to-text.mdx This JSON snippet represents a portion of an API response. It shows the structure for an array of text segments, each containing a 'timestamp' array (start and end times) and the corresponding 'text'. Following the segments, a '_usage' object provides metrics such as 'input_tokens', 'output_tokens', 'inference_time_tokens', and 'total_tokens', detailing the API call's resource consumption. Note that this is a fragment and may require an enclosing object and array start for full JSON validity. ```json "text": " She blushed when he" }, { "timestamp": [ 41.59, 43.94 ], "text": "gave her a white orchid" }, { "timestamp": [ 43.94, 46.22 ], "text": " The beetle droned in" }, { "timestamp": [ 46.22, 48.5 ], "text": "the hot June sun" } ], "_usage": { "input_tokens": 8, "output_tokens": 227, "inference_time_tokens": 441, "total_tokens": 676 } } ``` -------------------------------- ### Initialize and Use JigsawStack SDK for AI Scraping Source: https://github.com/jigsawstack/docs/blob/main/docs/introduction.mdx Example code demonstrating how to initialize the JigsawStack SDK with an API key and perform an AI-powered web scraping operation to extract specific elements like prices from a given URL. ```javascript import { JigsawStack } from "jigsawstack"; const jigsawstack = JigsawStack({ apiKey: "your-api-key" }); const result = await jigsawstack.web.ai_scrape({ url: "https://www.amazon.com/Cadbury-Mini-Caramel-Eggs-Bulk/dp/B0CWM99G5W", element_prompts: ["prices"] }); ``` ```python from jigsawstack import JigsawStack jigsawstack = JigsawStack(api_key="your-api-key") params = { "url": "https://www.amazon.com/Cadbury-Mini-Caramel-Eggs-Bulk/dp/B0CWM99G5W", "element_prompts": ["prices"] } result = jigsawstack.web.ai_scrape(params) ``` -------------------------------- ### APIDOC: Define 'Get Person Information' Prompt Source: https://github.com/jigsawstack/docs/blob/main/snippets/code-req-examples/prompt-engine-list.mdx This API documentation defines a prompt to retrieve information about a specific person. It typically expects a 'name' input, which is mandatory, and returns a JSON object with a 'person_story' field. Some variations might not explicitly list inputs, implying the name is handled contextually or inferred. ```APIDOC { "id": "159f6b55-33d1-4c0f-9ca2-bc1d4e2021a8", "prompt": "Who is this person {name}", "inputs": [ { "key": "name", "optional": false } ], "return_prompt": "{\"person_story\":\"the story of the person\"}", "return_prompt_type": "json", "created_at": "2025-05-22T22:31:49.460307+00:00" } ``` ```APIDOC { "id": "d5a310a4-4097-4646-82d8-df2d8b6b574e", "prompt": "Who is this person {name}", "inputs": [ { "key": "name", "optional": false } ], "return_prompt": "{\"person_story\":\"the story of the person\"}", "return_prompt_type": "json", "created_at": "2025-05-22T22:23:09.774412+00:00" } ``` ```APIDOC { "id": "8c46d13f-fe6d-4628-860f-ac8065293e9f", "prompt": "Who is this person {name}", "inputs": null, "return_prompt": "{\"person_story\":\"the story of the person\"}", "return_prompt_type": "json", "created_at": "2025-05-22T22:20:19.735801+00:00" } ``` -------------------------------- ### Initialize JigsawStack and Assign to window.ai Source: https://github.com/jigsawstack/docs/blob/main/docs/quick-start/node/window-ai.mdx Demonstrates how to import and initialize the JigsawStack SDK with your public API key, then assign the initialized instance to the global `window.ai` object for browser-based AI capabilities. Includes examples for both module environments and direct script tag inclusion. ```javascript // Import JigsawStack in a module environment import { JigsawStack } from "jigsawstack"; // Initialize with your public key const jigsawstack = JigsawStack({ apiKey: "pk_fecc....92je9" // Use your public key here }); // Assign to window.ai window.ai = jigsawstack; ``` ```html ``` -------------------------------- ### Translate Text using JigsawStack API Source: https://github.com/jigsawstack/docs/blob/main/docs/examples/language-models/translate.mdx This snippet demonstrates how to use the JigsawStack API to translate a given text into a target language. It shows examples using the JigsawStack SDK in Javascript and Python, as well as a direct cURL command for API interaction. The input includes the text to be translated and the desired target language code (e.g., 'es' for Spanish). The output is the translated text. ```Javascript import { JigsawStack } from "jigsawstack"; const jigsaw = JigsawStack({ apiKey: "your-api-key" }); const response = await jigsaw.translate({ text: "Hello, how are you?", target_language: "es" }); console.log(response); ``` ```Python from jigsawstack import JigsawStack jigsaw = JigsawStack(api_key="your-api-key") response = jigsaw.translate({ "text": "Hello, how are you?", "target_language": "es" }) print(response) ``` ```cURL curl -X POST https://api.jigsawstack.com/v1/ai/translate \ -H "Content-Type: application/json" \ -H "x-api-key: your-api-key" \ -d '{ "text": "Hello, how are you?", "target_language": "es" }' ``` -------------------------------- ### Configure JigsawStack SDK Directly in JavaScript Source: https://github.com/jigsawstack/docs/blob/main/docs/quick-start/node/introduction.mdx Initialize the JigsawStack SDK by passing your API key directly during instantiation, providing an alternative to environment variable configuration. ```javascript import { JigsawStack } from "jigsawstack"; const jigsawstack = JigsawStack({ apiKey: "your-api-key" }); ``` -------------------------------- ### Install JigsawStack LangChain Integration Package Source: https://github.com/jigsawstack/docs/blob/main/docs/integration/langchain.mdx Commands to install the JigsawStack integration package for LangChain.js using npm, Yarn, or pnpm. ```bash # npm npm install @langchain/jigsawstack ``` ```bash # Yarn yarn add @langchain/jigsawstack ``` ```bash # pnpm pnpm add @langchain/jigsawstack ``` -------------------------------- ### Initialize JigsawStack Python SDK Source: https://github.com/jigsawstack/docs/blob/main/docs/quick-start/python/introduction.mdx Shows two methods to initialize the JigsawStack Python SDK: automatically reading the API key from environment variables or providing it directly during initialization. ```python from jigsawstack import JigsawStack jigsawstack = JigsawStack() # API key will be read from environment ``` ```python from jigsawstack import JigsawStack jigsawstack = JigsawStack(api_key="your-api-key") ``` -------------------------------- ### Example AI Translate API Response (JSON) Source: https://github.com/jigsawstack/docs/blob/main/snippets/code-req-examples/translate.mdx This JSON snippet provides an example of the successful response structure from the Jigsawstack AI Translate API. It includes the translated text array, a success flag, and usage statistics such as input/output tokens and inference time. ```JSON { "success": true, "translated_text": [ "你好", "你好吗?", "谢谢你" ], "_usage": { "input_tokens": 18, "output_tokens": 18, "inference_time_tokens": 867, "total_tokens": 903 } } ``` -------------------------------- ### HTML To Any API Page Load Timeout and `goto_options` Source: https://github.com/jigsawstack/docs/blob/main/docs/examples/computer-vision/screenshot.mdx Explains the default page load timeout of 15 seconds and how to customize it using the `goto_options` parameter with `wait_until` events like `domcontentloaded` or `networkidle0`. ```APIDOC Default timeout: 15 seconds, waiting for `window.load` event. Customization: Use `goto_options` parameter. `goto_options.wait_until`: `domcontentloaded`, `networkidle0` `goto_options.timeout`: Custom timeout in milliseconds ``` -------------------------------- ### Jigsawstack TTS Voice Cloning API Response Example Source: https://github.com/jigsawstack/docs/blob/main/snippets/code-req-examples/text-to-speech-create-clone.mdx This JSON snippet provides an example of a successful response from the Jigsawstack AI TTS voice cloning API. It includes the unique 'voice_id' generated for the cloned voice and detailed usage statistics for the API call. ```JSON { "voice_id": "09706c90-28f0-4df5-ba54-9c16db45d686", "_usage": { "input_tokens": 7, "output_tokens": 4, "inference_time_tokens": 1302, "total_tokens": 1313 } } ``` -------------------------------- ### Extract Product Information with JigsawStack AI Web Scraper (JavaScript) Source: https://github.com/jigsawstack/docs/blob/main/docs/quick-start/node/introduction.mdx Demonstrates how to use the JigsawStack SDK to perform AI-powered web scraping, extracting specific elements like plan titles and prices from a given URL. ```javascript import { JigsawStack } from "jigsawstack"; // Initialize the SDK (API key from environment variables) const jigsawstack = JigsawStack(); // Basic usage - extract pricing information const result = await jigsawstack.web.ai_scrape({ url: "https://supabase.com/pricing", element_prompts: ["Plan title", "Plan price"] }); ``` -------------------------------- ### Configure JigsawStack SDK with Environment Variables Source: https://github.com/jigsawstack/docs/blob/main/docs/quick-start/node/introduction.mdx Create a .env file in your project root to store your JigsawStack API key, which is the recommended configuration method for the SDK. ```.env JIGSAWSTACK_API_KEY=your-api-key ``` -------------------------------- ### Spam Detection API Response Example Source: https://github.com/jigsawstack/docs/blob/main/docs/examples/content-validation/spam-check.mdx An example of a successful JSON response from the Spam Detection API, indicating whether the text is spam and its confidence score. ```json { "success": true, "check": { "is_spam": true, "score": 0.92 } } ``` -------------------------------- ### Quick Start: Convert Text to Speech with JigsawStack (JavaScript) Source: https://github.com/jigsawstack/docs/blob/main/docs/examples/audio-processing/text-to-speech.mdx Demonstrates how to quickly convert text to speech using a predefined accent with the JigsawStack SDK. It initializes the SDK with an API key and calls the `text_to_speech` method, then retrieves the audio as a blob. ```Javascript import { JigsawStack } from "jigsawstack"; const jigsaw = JigsawStack({ apiKey: "your-api-key", }); const response = await jigsaw.audio.text_to_speech({ text: "Hello, how are you doing?", accent: "en-US-female-27", }); const data = await response.blob(); ``` -------------------------------- ### Quick Start: Perform a Web Search with JigsawStack Source: https://github.com/jigsawstack/docs/blob/main/docs/examples/web/web-search.mdx Demonstrates how to initialize the JigsawStack client with an API key and perform a basic web search query, including options for AI overview and safe search. It also shows how to access geo-location results. ```javascript import { JigsawStack } from "jigsawstack"; const jigsaw = JigsawStack({ apiKey: "your-api-key" }); const response = await jigsaw.web.search({ query: "capital of France", ai_overview: true, safe_search: "moderate" }); console.log(response); console.log(response.geo_results[0].geoloc); ``` -------------------------------- ### JigsawStack Summarization API Response Examples Source: https://github.com/jigsawstack/docs/blob/main/docs/examples/core-ai/summary.mdx These JSON examples illustrate the typical successful responses from the JigsawStack Summarization API, showing both a paragraph-style summary and an array of bullet points. ```JSON { "success": true, "summary": "Renewable energy had record growth in 2022 with solar and wind exceeding forecasts, despite pandemic-related supply chain issues. Global clean energy investment surpassed $500 billion for the first time, with major oil companies investing in renewables to reach carbon neutrality by 2050. Challenges include grid integration, regulatory barriers, and energy storage needs. Growth is expected to continue in 2023, especially in utility-scale solar and offshore wind." } ``` ```JSON { "success": true, "summary": [ "Renewable energy growth exceeded forecasts by 25% in 2022", "Global clean energy investment topped $500 billion", "Major oil companies committed to carbon neutrality by 2050", "Challenges include grid integration, regulations, and energy storage", "Growth expected to continue in utility-scale solar and offshore wind" ] } ``` -------------------------------- ### Capturing Single-Page Applications with HTML To Any in JavaScript Source: https://github.com/jigsawstack/docs/blob/main/docs/examples/computer-vision/screenshot.mdx Shows how to configure the API to capture dynamic content or Single-Page Applications by waiting for `networkidle0` and extending the timeout to allow more time for JavaScript to render. ```JavaScript // Give more time for JavaScript-heavy pages to render const result = await jigsaw.web.html_to_any({ url: "https://dynamic-spa-example.com", goto_options: { wait_until: "networkidle0", // Wait until network is idle timeout: 15000 // Extended timeout for dynamic content }, full_page: true }); ``` -------------------------------- ### Create Prompt Engine Request with JigsawStack API Source: https://github.com/jigsawstack/docs/blob/main/snippets/code-req-examples/prompt-engine-create.mdx This snippet demonstrates how to make a request to the JigsawStack Prompt Engine API to generate content based on a specified prompt. It includes defining dynamic inputs, setting the desired return format (e.g., markdown), and applying content moderation guardrails to ensure safe and appropriate output. The examples cover direct API calls and SDK usage where applicable. ```Javascript import { JigsawStack } from "jigsawstack"; const jigsaw = JigsawStack({ apiKey: "your-api-key" }); const response = await jigsaw.prompt_engine.create({ "prompt": "Tell me a story about {about}", "inputs": [ { "key": "about", "optional": false, "initial_value": "Leaning Tower of Pisa" } ], "return_prompt": "Return the result in a markdown format", "prompt_guard": [ "sexual_content", "defamation" ] }) ``` ```Python from jigsawstack import JigsawStack jigsaw = JigsawStack(api_key="your-api-key") response = jigsaw.prompt_engine.create({ "prompt": "Tell me a story about {about}", "inputs": [ { "key": "about", "optional": false, "initial_value": "Leaning Tower of Pisa" } ], "return_prompt": "Return the result in a markdown format", "prompt_guard": [ "sexual_content", "defamation" ] }) ``` ```Curl curl https://api.jigsawstack.com/v1/prompt_engine \ -X POST \ -H 'Content-Type: application/json' \ -H 'x-api-key: your-api-key' \ -d '{"prompt":"Tell me a story about {about}","inputs":[{"key":"about","optional":false,"initial_value":"Leaning Tower of Pisa"}],"return_prompt":"Return the result in a markdown format","prompt_guard":["sexual_content","defamation"]}' ``` ```PHP 'Tell me a story about {about}', 'inputs' => [ { 'key' => 'about', 'optional' => false, 'initial_value' => 'Leaning Tower of Pisa' } ], 'return_prompt' => 'Return the result in a markdown format', 'prompt_guard' => [ 'sexual_content', 'defamation' ] }.to_json req_options = { use_ssl: uri.scheme == 'https' } res = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http| http.request(req) end ``` ```Go package main import ( "fmt" "io" "log" "net/http" "strings" ) func main() { client := &http.Client{} var data = strings.NewReader(`{"prompt":"Tell me a story about {about}","inputs":[{"key":"about","optional":false,"initial_value":"Leaning Tower of Pisa"}],"return_prompt":"Return the result in a markdown format","prompt_guard":["sexual_content","defamation"]}`) req, err := http.NewRequest("POST", "https://api.jigsawstack.com/v1/prompt_engine", data) if err != nil { log.Fatal(err) } req.Header.Set("Content-Type", "application/json") req.Header.Set("x-api-key", "your-api-key") resp, err := client.Do(req) if err != nil { log.Fatal(err) } defer resp.Body.Close() bodyText, err := io.ReadAll(resp.Body) if err != nil { log.Fatal(err) } fmt.Printf("%s\n", bodyText) } ``` ```Java import java.io.IOException; import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpRequest.BodyPublishers; import java.net.http.HttpResponse; HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://api.jigsawstack.com/v1/prompt_engine")) .POST(BodyPublishers.ofString("{\"prompt\":\"Tell me a story about {about}\",\"inputs\":[{\"key\":\"about\",\"optional\":false,\"initial_value\":\"Leaning Tower of Pisa\"}],\"return_prompt\":\"Return the result in a markdown format\",\"prompt_guard\":[\"sexual_content\",\"defamation\"]}")) .setHeader("Content-Type", "application/json") .setHeader("x-api-key", "your-api-key") .build(); HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); ``` ```Swift import Foundation let jsonData = [ "prompt": "Tell me a story about {about}", "inputs": [ [ "key": "about", "optional": false, "initial_value": "Leaning Tower of Pisa" ] ], "return_prompt": "Return the result in a markdown format", "prompt_guard": [ "sexual_content", "defamation" ] ``` -------------------------------- ### Example JSON Response for AI Web Scraper Source: https://github.com/jigsawstack/docs/blob/main/docs/examples/web/web-scraper.mdx An example of the JSON output returned by the AI Web Scraper API, showing the extracted data organized by the specified element_prompts. ```json { "context": { "post_titles": [ "The Grug Brained Developer (2022)", "Honda conducts successful launch and landing of experimental reusable rocket", "Resurrecting a dead torrent tracker and finding 3M peers", "Building Effective AI Agents", "Bzip2 crate switches from C to 100% rust", "AMD's CDNA 4 Architecture Announcement", "Making 2.5 Flash and 2.5 Pro GA, and introducing Gemini 2.5 Flash-Lite", "Foundry (YC F24) Hiring Early Engineer to Build Web Agent Infrastructure", "LLMs pose an interesting problem for DSL designers", "Time Series Forecasting with Graph Transformers", "What Google Translate Can Tell Us About Vibecoding", "Why JPEGs still rule the web (2024)", "AI will shrink Amazon's workforce in the coming years, CEO Jassy says", "Tetrachromatic Vision", "After millions of years, why are carnivorous plants still so small?", "From SDR to 'Fake HDR': Mario Kart World on Switch 2", "The hamburger-menu icon today: Is it recognizable?", "A Rural Public Transit Odyssey", "Bots are overwhelming websites with their hunger for AI data", "AMD's Pre-Zen Interconnect: Testing Trinity's Northbridge", "O3 Turns Pro", "Real-time action chunking with large models", "The magic of through running", "Voyager: Real-Time Splatting City-Scale 3D Gaussians on Your Phone", "Attempting to Make the Smallest* Electric Motor [video]", "CPU-Based Layout Design for Picker-to-Parts Pallet Warehouses", "Miscalculation by Spanish power grid operator REE contributed to blackout", "What happens when clergy take psilocybin", "Calculating Oil Storage Tank Occupancy with Help of Satellite Imagery", "Guidelines on how to be a scientific sleuth released" ], "post_points": [ "213 points", "682 points", "264 points", "161 points", "48 points", "73 points", "240 points", "64 points", "50 points", "43 points", "107 points", "51 points", "14 points", "25 points", "21 points", "57 points", "9 points", "18 points", "94 points", "143 points", "29 points", "154 points", "40 points", "81 points", "15 points", "327 points", "28 points" ], "post_username": [ "smartmic", "LorenDB", "k-ian", "Anon84", "Bogdanp", "rbanffy", "meetpateltech", "gopiandcode", "turntable_pride", "todsacerdoti", "purpleko", "rntn", "surprisetalk", "gmays", "ibobev", "thm", "herbertl", "Bender", "zdw", "jsnider3", "pr337h4m", "ortegaygasset", "PaulHoule", "croes", "bookofjoe", "marklit", "crescit_eundo" ] } } ``` -------------------------------- ### Spell Check API Response Example Source: https://github.com/jigsawstack/docs/blob/main/docs/examples/content-validation/spell-check.mdx An example JSON response from the JigsawStack Spell Check API, showing the success status, message, number of misspellings found, and the auto-corrected text. ```json { "success": true, "message": "Validated successfully", "misspellings_found": 3, "auto_correct_text": "This sentence has some spelling errors that need to be corrected." } ``` -------------------------------- ### Run JigsawStack Prompt Engine with Input Values Source: https://github.com/jigsawstack/docs/blob/main/snippets/code-req-examples/prompt-engine-run.mdx This snippet demonstrates how to make a POST request to the JigsawStack Prompt Engine API to execute a specific prompt. It requires an API key for authentication and sends input values along with the prompt engine's ID. The response contains the output from the prompt engine. ```Javascript import { JigsawStack } from "jigsawstack"; const jigsaw = JigsawStack({ apiKey: "your-api-key" }); const response = await jigsaw.prompt_engine.run({ "input_values": { "text": "How to get started with JigsawStack?" }, "id": "0073d008-da9b-4c27-90a8-0240f3ecd4f5" }) ``` ```Python from jigsawstack import JigsawStack jigsaw = JigsawStack(api_key="your-api-key") response = jigsaw.prompt_engine.run({ "input_values": { "text": "How to get started with JigsawStack?" }, "id": "0073d008-da9b-4c27-90a8-0240f3ecd4f5" }) ``` ```Bash curl https://api.jigsawstack.com/v1/prompt_engine/0073d008-da9b-4c27-90a8-0240f3ecd4f5?id=0073d008-da9b-4c27-90a8-0240f3ecd4f5 \ -X POST \ -H 'Content-Type: application/json' \ -H 'x-api-key: your-api-key' \ -d '{"input_values":{"text":"How to get started with JigsawStack?"}}' ``` ```PHP '0073d008-da9b-4c27-90a8-0240f3ecd4f5', } uri.query = URI.encode_www_form(params) req = Net::HTTP::Post.new(uri) req.content_type = 'application/json' req['x-api-key'] = 'your-api-key' req.body = { 'input_values' => { 'text' => 'How to get started with JigsawStack?' } }.to_json req_options = { use_ssl: uri.scheme == 'https' } res = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http| http.request(req) end ``` ```Go package main import ( "fmt" "io" "log" "net/http" "strings" ) func main() { client := &http.Client{} var data = strings.NewReader(`{"input_values":{"text":"How to get started with JigsawStack?"}}`) req, err := http.NewRequest("POST", "https://api.jigsawstack.com/v1/prompt_engine/0073d008-da9b-4c27-90a8-0240f3ecd4f5?id=0073d008-da9b-4c27-90a8-0240f3ecd4f5", data) if err != nil { log.Fatal(err) } req.Header.Set("Content-Type", "application/json") req.Header.Set("x-api-key", "your-api-key") resp, err := client.Do(req); if err != nil { log.Fatal(err) } defer resp.Body.Close() bodyText, err := io.ReadAll(resp.Body) if err != nil { log.Fatal(err) } fmt.Printf("%s\n", bodyText) } ``` ```Java import java.io.IOException; import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpRequest.BodyPublishers; import java.net.http.HttpResponse; HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://api.jigsawstack.com/v1/prompt_engine/0073d008-da9b-4c27-90a8-0240f3ecd4f5?id=0073d008-da9b-4c27-90a8-0240f3ecd4f5")) .POST(BodyPublishers.ofString("{\"input_values\":{\"text\":\"How to get started with JigsawStack?\"}}")) .setHeader("Content-Type", "application/json") .setHeader("x-api-key", "your-api-key") .build(); HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); ``` ```Swift import Foundation let jsonData = [ "input_values": [ "text": "How to get started with JigsawStack?" ] ] as [String : Any] let data = try! JSONSerialization.data(withJSONObject: jsonData, options: []) let url = URL(string: "https://api.jigsawstack.com/v1/prompt_engine/0073d008-da9b-4c27-90a8-0240f3ecd4f5?id=0073d008-da9b-4c27-90a8-0240f3ecd4f5")! let headers = [ "Content-Type": "application/json", "x-api-key": "your-api-key" ] var request = URLRequest(url: url) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = data as Data let task = URLSession.shared.dataTask(with: request) { (data, response, error) in if let error = error { print(error) } else if let data = data { let str = String(data: data, encoding: .utf8) print(str ?? "") } } task.resume() ``` ```Dart import 'package:http/http.dart' as http; void main() async { final headers = { 'Content-Type': 'application/json', 'x-api-key': 'your-api-key', }; final params = { 'id': '0073d008-da9b-4c27-90a8-0240f3ecd4f5', }; final data = '{"input_values":{"text":"How to get started with JigsawStack?"}}'; final url = Uri.parse('https://api.jigsawstack.com/v1/prompt_engine/0073d008-da9b-4c27-90a8-0240f3ecd4f5') ``` -------------------------------- ### CSS Selector: Attribute Starts With (`[attribute^=value]`) Source: https://github.com/jigsawstack/docs/blob/main/docs/additional-resources/selector.mdx Shows how to select elements based on an attribute's value starting with a specific string. Useful for targeting links or elements with specific prefixes in their attributes. ```CSS a[href^="https"] ``` -------------------------------- ### Create a JigsawStack Prompt Engine Source: https://github.com/jigsawstack/docs/blob/main/docs/learn/prompt/how-prompt-engine-works.mdx This snippet shows how to initialize the JigsawStack client with your API key and create a new prompt engine. The prompt defines a template with input variables and specifies the desired return format for the AI's response. ```JavaScript import { JigsawStack } from "jigsawstack"; const jigsaw = JigsawStack({ apiKey: "your-api-key" }); const result = await jigsaw.prompt_engine.create({ prompt: "How to cook {dish}", inputs: [{ key: "dish" }], return_prompt: [ { step: "step counter", instructions: "details of this step", }, ], }); ``` ```Python from jigsawstack import JigsawStack jigsaw = JigsawStack(api_key="your-api-key") params = { "prompt": "How to cook {dish}", "inputs": [{ "key": "dish" }], "return_prompt": "Return the result in a markdown format", } result = jigsaw.prompt_engine.create(params) ``` -------------------------------- ### Summarize Text with JigsawStack API Source: https://github.com/jigsawstack/docs/blob/main/docs/examples/language-models/summary.mdx This snippet demonstrates how to use the JigsawStack API to summarize a given text. It initializes the JigsawStack client with an API key and then calls the 'summary' method, passing the text to be summarized as an input. The response will contain the summarized content. ```Javascript import { JigsawStack } from "jigsawstack"; const jigsaw = JigsawStack({ apiKey: "your-api-key" }); const response = await jigsaw.summary({ text: "The quick brown fox jumps over the lazy dog. The lazy dog, being lazy, did not move. The fox, being quick, easily cleared the obstacle." }); console.log(response); ``` ```Python from jigsawstack import JigsawStack jigsaw = JigsawStack(api_key="your-api-key") response = jigsaw.summary({ "text": "The quick brown fox jumps over the lazy dog. The lazy dog, being lazy, did not move. The fox, being quick, easily cleared the obstacle." }) print(response) ``` ```cURL curl -X POST https://api.jigsawstack.com/v1/ai/summary \ -H "Content-Type: application/json" \ -H "x-api-key: your-api-key" \ -d '{ "text": "The quick brown fox jumps over the lazy dog. The lazy dog, being lazy, did not move. The fox, being quick, easily cleared the obstacle." }' ``` -------------------------------- ### Dataset Structure and Example for Prediction API (JavaScript) Source: https://github.com/jigsawstack/docs/blob/main/docs/examples/data/prediction.mdx Defines the required structure for the input dataset, which must be an array of objects containing 'date' (string) and 'value' (number or string) keys. A concrete example of a valid dataset is provided. ```javascript type Dataset = { date: string, value: number | string, }; const dataset: Array = [ { date: "2023-01-01", value: 353459 }, { date: "2023-01-02", value: 313734 }, { date: "2023-01-03", value: 333774 }, { date: "2023-01-04", value: 348636 }, { date: "2023-01-05", value: 278903 }, ]; ``` -------------------------------- ### Page Loading Configuration for Web Content Capture Source: https://github.com/jigsawstack/docs/blob/main/docs/api-reference/web/html-to-any.mdx This section details settings for managing page loading behavior when capturing web content. It includes using `wait_until: "networkidle0"` for dynamic sites, setting appropriate `timeout` values, and specifying explicit `width` and `height` to match content dimensions. ```APIDOC Page Loading Configuration: - Use wait_until: "networkidle0" for dynamic websites that load content via JavaScript - Set appropriate timeout values for websites that take longer to load - Consider using explicit width and height to match the content dimensions ``` -------------------------------- ### Make Web Search Suggestions Request Source: https://github.com/jigsawstack/docs/blob/main/snippets/code-req-examples/search-suggestions.mdx This snippet demonstrates how to send a GET request to the JigsawStack Web Search Suggestions API. It requires an API key for authentication and a 'query' parameter to get suggestions. ```javascript import { JigsawStack } from "jigsawstack"; const jigsaw = JigsawStack({ apiKey: "your-api-key" }); const response = await jigsaw.web.search_suggestions({ "query": "What is the capital" }) ``` ```python from jigsawstack import JigsawStack jigsaw = JigsawStack(api_key="your-api-key") response = jigsaw.web.search_suggestions({ "query": "What is the capital" }) ``` ```bash curl https://api.jigsawstack.com/v1/web/search/suggest?query=What+is+the+capital \ -X GET \ -H 'Content-Type: application/json' \ -H 'x-api-key: your-api-key' ``` ```php 'What is the capital', } uri.query = URI.encode_www_form(params) req = Net::HTTP::Get.new(uri) req.content_type = 'application/json' req['x-api-key'] = 'your-api-key' req_options = { use_ssl: uri.scheme == 'https' } res = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http| http.request(req) end ``` ```go package main import ( "fmt" "io" "log" "net/http" ) func main() { client := &http.Client{} req, err := http.NewRequest("GET", "https://api.jigsawstack.com/v1/web/search/suggest?query=What+is+the+capital", nil) if err != nil { log.Fatal(err) } req.Header.Set("Content-Type", "application/json") req.Header.Set("x-api-key", "your-api-key") resp, err := client.Do(req) if err != nil { log.Fatal(err) } defer resp.Body.Close() bodyText, err := io.ReadAll(resp.Body) if err != nil { log.Fatal(err) } fmt.Printf("%s\n", bodyText) } ``` ```java import java.io.IOException; import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://api.jigsawstack.com/v1/web/search/suggest?query=What+is+the+capital")) .GET() .setHeader("Content-Type", "application/json") .setHeader("x-api-key", "your-api-key") .build(); HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); ``` ```swift import Foundation let url = URL(string: "https://api.jigsawstack.com/v1/web/search/suggest?query=What+is+the+capital")! let headers = [ "Content-Type": "application/json", "x-api-key": "your-api-key" ] var request = URLRequest(url: url) request.allHTTPHeaderFields = headers let task = URLSession.shared.dataTask(with: request) { (data, response, error) in if let error = error { print(error) } else if let data = data { let str = String(data: data, encoding: .utf8) print(str ?? "") } } task.resume() ``` ```dart import 'package:http/http.dart' as http; void main() async { final headers = { 'Content-Type': 'application/json', 'x-api-key': 'your-api-key', }; final params = { 'query': 'What is the capital', }; final url = Uri.parse('https://api.jigsawstack.com/v1/web/search/suggest') .replace(queryParameters: params); final res = await http.get(url, headers: headers); final status = res.statusCode; if (status != 200) throw Exception('http.get error: statusCode= $status'); print(res.body); } ``` ```kotlin import java.io.IOException import okhttp3.OkHttpClient import okhttp3.Request val client = OkHttpClient() val request = Request.Builder() .url("https://api.jigsawstack.com/v1/web/search/suggest?query=What+is+the+capital") .header("Content-Type", "application/json") .header("x-api-key", "your-api-key") .build() client.newCall(request).execute().use { response -> if (!response.isSuccessful) throw IOException("Unexpected code $response") response.body!!.string() } ``` ```csharp using System.Net.Http; using System.Net.Http.Headers; HttpClient client = new HttpClient(); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "https://api.jigsawstack.com/v1/web/search/suggest?query=What+is+the+capital"); request.Headers.Add("x-api-key", "your-api-key"); request.Content = new StringContent(""); request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); HttpResponseMessage response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); ``` -------------------------------- ### List Prompt Engines from JigsawStack API Source: https://github.com/jigsawstack/docs/blob/main/snippets/code-req-examples/prompt-engine-list.mdx This snippet demonstrates how to retrieve a list of prompt engines from the JigsawStack API using various programming languages. It requires an API key for authentication and limits the results to 10 entries. ```Javascript import { JigsawStack } from "jigsawstack"; const jigsaw = JigsawStack({ apiKey: "your-api-key" }); const response = await jigsaw.prompt_engine.list({ "limit": "10" }) ``` ```Python from jigsawstack import JigsawStack jigsaw = JigsawStack(api_key="your-api-key") response = jigsaw.prompt_engine.list({ "limit": "10" }) ``` ```Curl curl https://api.jigsawstack.com/v1/prompt_engine?limit=10 \ -X GET \ -H 'Content-Type: application/json' \ -H 'x-api-key: your-api-key' ``` ```PHP '10', } uri.query = URI.encode_www_form(params) req = Net::HTTP::Get.new(uri) req.content_type = 'application/json' req['x-api-key'] = 'your-api-key' req_options = { use_ssl: uri.scheme == 'https' } res = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http| http.request(req) end ``` ```Go package main import ( "fmt" "io" "log" "net/http" ) func main() { client := &http.Client{} req, err := http.NewRequest("GET", "https://api.jigsawstack.com/v1/prompt_engine?limit=10", nil) if err != nil { log.Fatal(err) } req.Header.Set("Content-Type", "application/json") req.Header.Set("x-api-key", "your-api-key") resp, err := client.Do(req) if err != nil { log.Fatal(err) } defer resp.Body.Close() bodyText, err := io.ReadAll(resp.Body) if err != nil { log.Fatal(err) } fmt.Printf("%s\n", bodyText) } ``` ```Java import java.io.IOException; import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://api.jigsawstack.com/v1/prompt_engine?limit=10")) .GET() .setHeader("Content-Type", "application/json") .setHeader("x-api-key", "your-api-key") .build(); HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); ``` ```Swift import Foundation let url = URL(string: "https://api.jigsawstack.com/v1/prompt_engine?limit=10")! let headers = [ "Content-Type": "application/json", "x-api-key": "your-api-key" ] var request = URLRequest(url: url) request.allHTTPHeaderFields = headers let task = URLSession.shared.dataTask(with: request) { (data, response, error) in if let error = error { print(error) } else if let data = data { let str = String(data: data, encoding: .utf8) print(str ?? "") } } task.resume() ``` ```Dart import 'package:http/http.dart' as http; void main() async { final headers = { 'Content-Type': 'application/json', 'x-api-key': 'your-api-key', }; final params = { 'limit': '10', }; final url = Uri.parse('https://api.jigsawstack.com/v1/prompt_engine') .replace(queryParameters: params); final res = await http.get(url, headers: headers); final status = res.statusCode; if (status != 200) throw Exception('http.get error: statusCode= $status'); print(res.body); } ``` ```Kotlin import java.io.IOException import okhttp3.OkHttpClient import okhttp3.Request val client = OkHttpClient() val request = Request.Builder() .url("https://api.jigsawstack.com/v1/prompt_engine?limit=10") .header("Content-Type", "application/json") .header("x-api-key", "your-api-key") .build() client.newCall(request).execute().use { response -> if (!response.isSuccessful) throw IOException("Unexpected code $response") response.body!!.string() } ``` ```C# using System.Net.Http; using System.Net.Http.Headers; HttpClient client = new HttpClient(); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "https://api.jigsawstack.com/v1/prompt_engine?limit=10"); request.Headers.Add("x-api-key", "your-api-key"); request.Content = new StringContent(""); request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); HttpResponseMessage response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); ``` -------------------------------- ### Jigsawstack Text Embedding API Response Example Source: https://github.com/jigsawstack/docs/blob/main/snippets/code-req-examples/embedding.mdx This JSON snippet illustrates a successful response from the Jigsawstack v1 embedding API. It includes a success status and an array of numerical embeddings generated from the input text. ```JSON { "success": true, "embeddings": [ [ -0.06269700080156326, 0.0896194726228714, -0.04227621480822563, -0.046519096940755844, -0.02535046637058258, -0.05726366862654686, 0.022328557446599007, 0.08247677236795425, -0.01738361269235611, -0.07240374386310577, -0.004616806749254465, -0.025930428877472878, -0.07008389383554459, -0.007711212150752544, -0.09261085838079453, 0.03952902555465698, 0.046824339777231216, 0.035591382533311844, 0.049785204231739044, 0.10872770845890045, 0.04273407906293869, 0.023885298520326614, 0.01059957779943943, -0.016315260902047157, -0.03888801112771034, 0.1354059875011444, 0.027029305696487427, 0.01054615993052721, -0.02821975387632847, -0.003025725483894348, -0.08235467970371246, -0.09102358669042587, -0.009630430489778519, -0.0015147705562412739, 0.07698239386081696, -0.007325842045247555, -0.07918014377355576, -0.005986586678773165, 0.004719826392829418, -0.028372377157211304, -0.06593257933855057, 0.06052977219223976, 0.0133009823039 ``` -------------------------------- ### Perform Object Detection API Request Source: https://github.com/jigsawstack/docs/blob/main/snippets/code-req-examples/object-detection.mdx This code snippet demonstrates how to make a POST request to the Jigsawstack AI Object Detection API. It shows how to set the API key, content type, and include the image URL in the request body. Examples are provided for Kotlin and C#. ```Kotlin import java.io.IOException import okhttp3.MediaType.Companion.toMediaType import okhttp3.OkHttpClient import okhttp3.Request import okhttp3.RequestBody.Companion.toRequestBody val client = OkHttpClient() val MEDIA_TYPE = "application/json".toMediaType() val requestBody = "{\"url\":\"https://rogilvkqloanxtvjfrkm.supabase.co/storage/v1/object/public/demo/Collabo%201080x842.jpg?t=2024-03-22T09%3A22%3A48.442Z\"}" val request = Request.Builder() .url("https://api.jigsawstack.com/v1/ai/object_detection") .post(requestBody.toRequestBody(MEDIA_TYPE)) .header("Content-Type", "application/json") .header("x-api-key", "your-api-key") .build() client.newCall(request).execute().use { response -> if (!response.isSuccessful) throw IOException("Unexpected code $response") response.body!!.string() } ``` ```C# using System.Net.Http; using System.Net.Http.Headers; HttpClient client = new HttpClient(); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "https://api.jigsawstack.com/v1/ai/object_detection"); request.Headers.Add("x-api-key", "your-api-key"); request.Content = new StringContent("{\"url\":\"https://rogilvkqloanxtvjfrkm.supabase.co/storage/v1/object/public/demo/Collabo%201080x842.jpg?t=2024-03-22T09%3A22%3A48.442Z\"}"); request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); HttpResponseMessage response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); ``` -------------------------------- ### Example SQL Schema for Transactions Table Source: https://github.com/jigsawstack/docs/blob/main/docs/examples/data/text-to-sql.mdx This SQL DDL statement defines a `transactions` table with columns for ID, creation timestamp, amount, and user ID. It serves as an example of a valid schema to be passed to the `sql_schema` parameter for the Text to SQL API. ```SQL CREATE TABLE transactions ( id TEXT UNIQUE NOT NULL DEFAULT ( lower(hex(randomblob(4))) || '-' || lower(hex(randomblob(2))) || '-4' || substr(lower(hex(randomblob(2))), 2) || '-' || substr('89ab', abs(random()) % 4 + 1, 1) || substr(lower(hex(randomblob(2))), 2) || '-' || lower(hex(randomblob(6))) ), created_at DATETIME NOT NULL DEFAULT (datetime('now', 'subsec')), amount NUMERIC NOT NULL, user_id TEXT NOT NULL, PRIMARY KEY (id)); ``` -------------------------------- ### Generate Images with window.ai Source: https://github.com/jigsawstack/docs/blob/main/docs/quick-start/node/window-ai.mdx Explains how to use the `window.ai.image_generation` method to create an image from a text prompt, returning a URL to the generated image. ```javascript // Generate an image from a text prompt const image = await window.ai.image_generation({ prompt: "A serene mountain landscape with a lake" }); document.getElementById('generatedImage').src = image.url; ``` -------------------------------- ### Example Response from Spam Check API Source: https://github.com/jigsawstack/docs/blob/main/snippets/code-req-examples/spam-check.mdx Illustrates the expected JSON response structure from the Jigsawstack Spam Check API, including the spam check results (score, is_spam) and API usage metrics such as token counts and inference time. ```JSON { "success": true, "check": { "score": 0.95, "is_spam": true }, "_usage": { "input_tokens": 20, "output_tokens": 14, "inference_time_tokens": 820, "total_tokens": 854 } } ``` -------------------------------- ### Example AI Prediction API Response Source: https://github.com/jigsawstack/docs/blob/main/snippets/code-req-examples/prediction.mdx This JSON snippet shows a successful response from the Jigsawstack AI prediction API. It includes the predicted values with dates, the number of steps predicted, and usage statistics like input/output tokens and inference time. ```JSON { "success": true, "prediction": [ { "date": "2023-01-08 00:00:00", "value": 315214.5625 }, { "date": "2023-01-07 00:00:00", "value": 320094.71875 }, { "date": "2023-01-06 00:00:00", "value": 316329.9375 } ], "steps": 3, "_usage": { "input_tokens": 53, "output_tokens": 49, "inference_time_tokens": 792, "total_tokens": 894 } } ``` -------------------------------- ### Make a Prediction using JigsawStack API Source: https://github.com/jigsawstack/docs/blob/main/snippets/code-req-examples/prediction.mdx These examples demonstrate how to make a prediction request to the JigsawStack AI API. You need to provide a dataset of historical date-value pairs and specify the number of future steps to predict. An API key is required for authentication. ```Javascript import { JigsawStack } from "jigsawstack"; const jigsaw = JigsawStack({ apiKey: "your-api-key" }); const response = await jigsaw.prediction({ "dataset": [ { "date": "2023-01-01", "value": 353459 }, { "date": "2023-01-02", "value": 313734 }, { "date": "2023-01-03", "value": 333774 }, { "date": "2023-01-04", "value": 348636 }, { "date": "2023-01-05", "value": 278903 } ], "steps": 3 }) ``` ```Python from jigsawstack import JigsawStack jigsaw = JigsawStack(api_key="your-api-key") response = jigsaw.prediction({ "dataset": [ { "date": "2023-01-01", "value": 353459 }, { "date": "2023-01-02", "value": 313734 }, { "date": "2023-01-03", "value": 333774 }, { "date": "2023-01-04", "value": 348636 }, { "date": "2023-01-05", "value": 278903 } ], "steps": 3 }) ``` ```Curl curl https://api.jigsawstack.com/v1/ai/prediction \ -X POST \ -H 'Content-Type: application/json' \ -H 'x-api-key: your-api-key' \ -d '{"dataset":[{"date":"2023-01-01","value":353459},{"date":"2023-01-02","value":313734},{"date":"2023-01-03","value":333774},{"date":"2023-01-04","value":348636},{"date":"2023-01-05","value":278903}],"steps":3}' ``` ```PHP [ { 'date' => '2023-01-01', 'value' => 353459 }, { 'date' => '2023-01-02', 'value' => 313734 }, { 'date' => '2023-01-03', 'value' => 333774 }, { 'date' => '2023-01-04', 'value' => 348636 }, { 'date' => '2023-01-05', 'value' => 278903 } ], 'steps' => 3 }.to_json req_options = { use_ssl: uri.scheme == 'https' } res = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http| http.request(req) end ``` ```Go package main import ( "fmt" "io" "log" "net/http" "strings" ) func main() { client := &http.Client{} var data = strings.NewReader(`{"dataset":[{"date":"2023-01-01","value":353459},{"date":"2023-01-02","value":313734},{"date":"2023-01-03","value":333774},{"date":"2023-01-04","value":348636},{"date":"2023-01-05","value":278903}],"steps":3}`) req, err := http.NewRequest("POST", "https://api.jigsawstack.com/v1/ai/prediction", data) if err != nil { log.Fatal(err) } req.Header.Set("Content-Type", "application/json") req.Header.Set("x-api-key", "your-api-key") resp, err := client.Do(req) if err != nil { log.Fatal(err) } defer resp.Body.Close() bodyText, err := io.ReadAll(resp.Body) if err != nil { log.Fatal(err) } fmt.Printf("%s\n", bodyText) } ``` ```Java import java.io.IOException; import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpRequest.BodyPublishers; import java.net.http.HttpResponse; HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://api.jigsawstack.com/v1/ai/prediction")) .POST(BodyPublishers.ofString("{\"dataset\":[{\"date\":\"2023-01-01\",\"value\":353459},{\"date\":\"2023-01-02\",\"value\":313734},{\"date\":\"2023-01-03\",\"value\":333774},{\"date\":\"2023-01-04\",\"value\":348636},{\"date\":\"2023-01-05\",\"value\":278903}],\"steps\":3}")) .setHeader("Content-Type", "application/json") .setHeader("x-api-key", "your-api-key") .build(); HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); ``` ```Swift import Foundation let jsonData = [ "dataset": [ [ ```