# SerpAPI

**What is SerpAPI?**

SerpAPI is a powerful node in StackAI that allows you to perform real-time web searches, news searches, job searches, and website to markdown directly within your workflow. It leverages the SerpAPI platform to fetch up-to-date information from the internet, making it ideal for research, content generation, and data enrichment tasks.

***

**Example of Usage**

* Connect a Text Input node to SerpAPI.
* Set the action to "Web Search".
* Enter a search query like "latest AI trends".
* The node returns a list of relevant web results, which can be displayed or processed further.

***

### **Available Actions**

#### 1. Web Search

**Description:**\
Performs a real-time search on the web and returns a list of relevant results.

**Inputs:**

* **Query** (string, required): The search term or phrase to look up (e.g., "StackAI features").
* **Num** (number, optional): Specify how many search results you want to retrieve (default: 5), needs to be at least 1.

**Configurations:**

* **Device** (dropdown, optional): Choose whether to simulate search results as seen on desktop or mobile devices. Default is desktop.&#x20;
* **CountryCode** (dropdown, optional): Select which country's search engine to use for results.
* **LanguageCode** (dropdown, optional): Choose the language for search results and interface.

**Outputs:**

* **Web Search Results** (object\_array): A collection of web search results containing URLs, titles, and content snippets.

**Example:**\
Input:

```json
{
  "query": "StackAI workflow automation"
}
```

Output:

```json
{
  "results": [
    {
      "title": "How to Automate Workflows with StackAI",
      "link": "https://example.com/stackai-workflow",
      "snippet": "Learn how to automate your business processes using StackAI..."
    }
  ],
  "metadata": {
    "total_results": 100000,
    "search_time": "0.45s"
  }
}
```

#### 2. News Search

**Description:**\
Fetches the latest news articles related to a specific query.

**Inputs:**

* **Query** (string, required): The search term or phrase to look up (e.g., "AI news").

**Configurations:**

* **Device** (dropdown, optional): Choose whether to simulate search results as seen on desktop or mobile devices. Default is desktop.&#x20;
* **CountryCode** (dropdown, optional): Select which country's search engine to use for results.
* **LanguageCode** (dropdown, optional): Choose the language for search results and interface.

**Outputs:**

* **Result** (string): The result of the news search

**Example:**\
Input:

```json
{
  "query": "AI breakthroughs"
}
```

Output:

```json
{
  "articles": [
    {
      "title": "Recent Breakthroughs in AI",
      "link": "https://news.com/ai-breakthroughs",
      "source": "Tech News",
      "published_date": "2025-07-20"
    }
  ],
  "metadata": {
    "total_articles": 50
  }
}
```

#### 3. Job Search

**Description:**\
Searches for job postings based on a given query and location.

**Inputs:**

* **Query** (string, required): The search term or phrase to look up (e.g., "Data Scientist").
* **Num** (number, optional): Specify how many search results you want to retrieve (default: 5), needs to be at least 1.

**Configurations:**

* **CountryCode** (dropdown, optional): Select which country's search engine to use for results.
* **LanguageCode** (dropdown, optional): Choose the language for search results and interface.

**Outputs:**

* **Jobs** (string): List of jobs found.

**Example:**\
Input:

```json
{
  "query": "machine learning engineer",
  "country_code": "UNITED_STATES"
}
```

Output:

```json
{
  "jobs": [
    {
      "title": "Machine Learning Engineer",
      "company": "Tech Innovators",
      "location": "San Francisco, CA",
      "link": "https://jobs.com/ml-engineer"
    }
  ],
  "metadata": {
    "total_jobs": 120
  }
}
```

#### 4. Website to Markdown

**Description:**\
This action takes a website URL and converts the entire page into a markdown-formatted document. It’s useful for extracting readable, structured content from any public web page.

**Inputs:**

* **Url** (string, required): The URL of the website you want to convert to markdown.

**Configurations:**

* **Location** (string, optional): The geographic location from which to perform the conversion (affects region-specific content). Default is US.&#x20;

**Outputs:**

* **Markdown** (string): The markdown representation of the website

**Example:**\
Input:

```json
{
  "url": "https://en.wikipedia.org/wiki/Markdown"
}
```

Output:

```json
{
  "markdown": "# Markdown\nMarkdown is a lightweight markup language..."
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.stackai.com/workflow-builder/apps/serpapi.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
