ScavioScavio
Pricing
Tools
Sign InsGet Startedg
  1. Home
  2. Tutorials
  3. How to Enrich Leads with a Search API in n8n
Tutorial

How to Enrich Leads with a Search API in n8n

Build an n8n workflow that takes a company name, runs a search API call to extract website, description, and key info, and outputs an enriched lead record.

Get Free API KeyAPI Docs

You can enrich leads in n8n by adding an HTTP Request node that calls the Scavio search API with the company name, then parsing the results to extract the website, description, and employee count into your lead record.

Prerequisites

  • n8n installed (self-hosted or cloud)
  • Scavio API key
  • Input list of company names

Walkthrough

Step 1: Create the HTTP Request node for search

Add an HTTP Request node in n8n with POST method and the Scavio search endpoint.

JSON
// n8n HTTP Request Node Configuration
// Method: POST
// URL: https://api.scavio.dev/api/v2/google
// Authentication: Header Auth
//   Name: Authorization
//   Value: Bearer {{ $env.SCAVIO_API_KEY }}
// Body (JSON):
{
  "query": "{{ $json.company_name }} company website about"
}

Step 2: Parse the search results with a Code node

Add a Code node after the HTTP Request to extract structured fields from the SERP results.

JavaScript
// n8n Code Node (JavaScript)
const results = $input.item.json.organic_results || [];
const companyName = $('Input').item.json.company_name;

// Find the most relevant result (usually the first)
const main = results[0] || {};

// Try to find official website (avoid Wikipedia, LinkedIn)
const officialSite = results.find(r => 
  !r.link.includes('wikipedia') && 
  !r.link.includes('linkedin') && 
  !r.link.includes('crunchbase')
);

return {
  company_name: companyName,
  website: officialSite?.link || null,
  description: main.snippet || null,
  search_title: main.title || null,
  enriched_at: new Date().toISOString()
};

Step 3: Extract the company from the organic results

Get funding, employee count, or industry by parsing the knowledge panel if present.

JavaScript
// Extended Code node to include knowledge panel data
const data = $input.item.json;
const kp = data.knowledge_panel || {};
const results = data.organic_results || [];

const officialSite = results.find(r =>
  !r.link.includes('wikipedia') &&
  !r.link.includes('linkedin') &&
  !r.link.includes('crunchbase')
);

return {
  company_name: $('Input').item.json.company_name,
  website: officialSite?.link || kp.website || null,
  description: kp.description || results[0]?.snippet || null,
  industry: kp.industry || null,
  founded: kp.founded || null,
  headquarters: kp.headquarters || null,
  enriched_at: new Date().toISOString()
};

Step 4: Verify with the Python equivalent

Use this Python script to test your enrichment logic before wiring up n8n.

Python
import requests

API_KEY = "your-scavio-api-key"

def enrich_company(company_name: str) -> dict:
    r = requests.post(
        "https://api.scavio.dev/api/v2/google",
        json={"query": f"{company_name} company website about"},
        headers={
            "Authorization": f"Bearer {API_KEY}",
            "Content-Type": "application/json",
        },
        timeout=15
    )
    r.raise_for_status()
    # Google v2 is a raw passthrough: organic_results sits at the top level,
    # not under "data".
    data = r.json()
    results = data.get("organic_results", [])
    # knowledge_graph is present only for entities Google recognises, and its
    # fields vary by entity type -- treat every key as optional.
    kg = data.get("knowledge_graph") or {}
    official = next(
        (res for res in results
         if not any(x in res.get("link", "") for x in ["wikipedia", "linkedin", "crunchbase"])),
        results[0] if results else {}
    )
    return {
        "company": company_name,
        "website": official.get("link") or kg.get("website"),
        "description": kg.get("description") or official.get("snippet"),
        "industry": kg.get("industry"),
        "founded": kg.get("founded")
    }

print(enrich_company("Notion"))

Python Example

Python
import requests

API_KEY = "your-scavio-api-key"

EXCLUDE_DOMAINS = ["wikipedia.org", "linkedin.com", "crunchbase.com", "facebook.com", "twitter.com"]

def enrich_company(company_name: str) -> dict:
    r = requests.post(
        "https://api.scavio.dev/api/v2/google",
        json={"query": f"{company_name} company official website"},
        headers={
            "Authorization": f"Bearer {API_KEY}",
            "Content-Type": "application/json",
        },
        timeout=15
    )
    r.raise_for_status()
    # Google v2 is a raw passthrough: organic_results is top level.
    data = r.json()
    results = data.get("organic_results", [])
    # Optional and entity-dependent -- never assume a given key is present.
    kg = data.get("knowledge_graph") or {}

    official = next(
        (res for res in results if not any(exc in res.get("link", "") for exc in EXCLUDE_DOMAINS)),
        results[0] if results else {}
    )

    return {
        "company": company_name,
        "website": official.get("link") or kg.get("website"),
        "description": kg.get("description") or official.get("snippet"),
        "industry": kg.get("industry"),
        "founded": kg.get("founded"),
        "headquarters": kg.get("headquarters"),
        "source": official.get("link")
    }

def enrich_batch(companies: list[str]) -> list[dict]:
    results = []
    for company in companies:
        try:
            record = enrich_company(company)
            results.append(record)
            print(f"Enriched: {company} -> {record.get('website')}")
        except Exception as e:
            print(f"Failed: {company} -> {e}")
            results.append({"company": company, "error": str(e)})
    return results

if __name__ == "__main__":
    companies = ["Notion", "Linear", "Retool", "Vercel", "PlanetScale"]
    enriched = enrich_batch(companies)
    import json
    print(json.dumps(enriched, indent=2))

JavaScript Example

JavaScript
const API_KEY = 'your-scavio-api-key';
const EXCLUDE = ['wikipedia.org', 'linkedin.com', 'crunchbase.com'];

async function enrichCompany(companyName) {
  const res = await fetch('https://api.scavio.dev/api/v2/google', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      Authorization: `Bearer ${API_KEY}`,
    },
    body: JSON.stringify({ query: `${companyName} company official website` })
  });
  if (!res.ok) throw new Error(`scavio ${res.status}`);
  // Google v2 is a raw passthrough: organic_results is top level.
  const data = await res.json();
  const results = data.organic_results ?? [];
  // Optional and entity-dependent -- never assume a given key is present.
  const kg = data.knowledge_graph ?? {};
  const official = results.find(r => !EXCLUDE.some(e => r.link?.includes(e))) ?? results[0] ?? {};
  return {
    company: companyName,
    website: official.link ?? kg.website ?? null,
    description: kg.description ?? official.snippet ?? null,
    industry: kg.industry ?? null,
    founded: kg.founded ?? null
  };
}

const companies = ['Notion', 'Linear', 'Retool'];
for (const c of companies) {
  const record = await enrichCompany(c);
  console.log(JSON.stringify(record, null, 2));
}

Expected Output

JSON
{
  "company": "Notion",
  "website": "https://www.notion.so",
  "description": "Notion is a productivity and note-taking web application. It offers organizational tools including task management, project tracking, to-do lists, bookmarking, and more.",
  "industry": "Software",
  "founded": "2013",
  "headquarters": "San Francisco, CA"
}

Related Tutorials

    Frequently Asked Questions

    Most developers complete this tutorial in 15 to 30 minutes. You will need a Scavio API key (free tier works) and a working Python or JavaScript environment.

    n8n installed (self-hosted or cloud). Scavio API key. Input list of company names. A Scavio API key gives you 50 free credits on signup.

    Yes. The free tier includes 50 credits on signup, which is more than enough to complete this tutorial and prototype a working solution.

    Scavio has a native LangChain package (langchain-scavio), an MCP server, and a plain REST API that works with any HTTP client. This tutorial uses the raw REST API, but you can adapt to your framework of choice.

    Related Resources

    Best Of

    Best Search API for n8n Workflows in 2026

    Read more
    Comparison

    Web Scraping in n8n (HTTP Request + HTML Extract) vs Search API in n8n (HTTP Request to search API)

    Read more
    Best Of

    Best Search APIs Under $5 per 1K Queries in 2026

    Read more
    Glossary

    n8n Search Node

    Read more
    Comparison

    Apollo vs Scavio

    Read more
    Use Case

    Gemini vs API Search Reliability

    Read more

    Start Building

    Build an n8n workflow that takes a company name, runs a search API call to extract website, description, and key info, and outputs an enriched lead record.

    Get Free API KeyRead the Docs
    ScavioScavio

    One scraper API for every social, search, e-commerce and real estate platform. Built for AI agents.

    Product

    • Features
    • Pricing
    • Dashboard
    • Affiliates

    Developers

    • Documentation
    • API Reference
    • Quickstart
    • MCP Integration
    • Python SDK

    Alternatives

    • Tavily Alternative
    • SerpAPI Alternative
    • Firecrawl Alternative
    • Exa Alternative
    • Serper Alternative
    • Tavily vs Scavio
    • SerpAPI vs Scavio
    • All alternatives
    • Compare Scavio vs alternatives

    Search APIs

    • Google Search API
    • Amazon Product API
    • YouTube API
    • Reddit API
    • Walmart Product API
    • TikTok API
    • Instagram API

    Tools

    • All Tools

    © 2026 Scavio. All rights reserved.

    Featured on TAAFT
    Terms of ServicePrivacy Policy