Anyhunt
API Reference

Search API

Web search with optional result content scraping

Search API

The Search API provides web search capabilities. Optionally scrape the content of search results for deeper analysis.

Endpoints

MethodPathDescription
POST/api/v1/searchExecute search
GET/api/v1/search/autocompleteGet search suggestions
POST /api/v1/search

Request Body

ParameterTypeDefaultDescription
querystringrequiredSearch query (max 500 chars)
limitnumber10Number of results (1-100)
categoriesstring[]-Search categories
enginesstring[]-Specific search engines
languagestring-Language code (e.g., "en", "zh")
timeRangestring-Time filter: day, week, month, year
safeSearchnumber-Safe search: 0 (off), 1 (moderate), 2 (strict)
scrapeResultsbooleanfalseScrape content from result pages
scrapeOptionsobject-Options for result scraping

Search Categories

CategoryDescription
generalWeb pages (default)
imagesImage search
newsNews articles
videosVideo content
musicMusic and audio
filesDownloadable files
itIT and programming
scienceScientific content
social mediaSocial media posts

Example Request

curl -X POST https://server.anyhunt.app/api/v1/search \
  -H "Authorization: Bearer ah_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "web scraping best practices",
    "limit": 10,
    "categories": ["general"],
    "timeRange": "month",
    "safeSearch": 1
  }'

Response

{
  "query": "web scraping best practices",
  "numberOfResults": 10,
  "results": [
    {
      "title": "Web Scraping Best Practices Guide",
      "url": "https://example.com/guide",
      "description": "Learn the best practices for ethical web scraping...",
      "engine": "google",
      "score": 0.95,
      "publishedDate": "2024-01-10"
    },
    {
      "title": "How to Scrape Websites Responsibly",
      "url": "https://example.org/scraping",
      "description": "A comprehensive guide to responsible web scraping...",
      "engine": "bing",
      "score": 0.92
    }
  ],
  "suggestions": [
    "web scraping python",
    "web scraping tools",
    "web scraping legal"
  ]
}

Search with Content Scraping

Enable scrapeResults to fetch and include the content of each result page:

curl -X POST https://server.anyhunt.app/api/v1/search \
  -H "Authorization: Bearer ah_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "web scraping tutorial",
    "limit": 5,
    "scrapeResults": true,
    "scrapeOptions": {
      "formats": ["markdown"],
      "onlyMainContent": true
    }
  }'

Response with Content

{
  "query": "web scraping tutorial",
  "numberOfResults": 5,
  "results": [
    {
      "title": "Web Scraping Tutorial",
      "url": "https://example.com/tutorial",
      "description": "Step-by-step web scraping guide...",
      "engine": "google",
      "content": "# Web Scraping Tutorial\n\nIn this tutorial, you'll learn..."
    }
  ]
}

Autocomplete

GET /api/v1/search/autocomplete?q=web+scrap

Response

{
  "suggestions": [
    "web scraping",
    "web scraping python",
    "web scraping tools",
    "web scraper"
  ]
}

Code Examples

Node.js

// Basic search
const response = await fetch('https://server.anyhunt.app/api/v1/search', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer ah_your_api_key',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    query: 'machine learning tutorials',
    limit: 10,
    timeRange: 'month',
  }),
});

const data = await response.json();
console.log(`Found ${data.numberOfResults} results`);
data.results.forEach(r => console.log(r.title, r.url));

Python

import requests

# Search with content scraping
response = requests.post(
    'https://server.anyhunt.app/api/v1/search',
    headers={
        'Authorization': 'Bearer ah_your_api_key',
        'Content-Type': 'application/json',
    },
    json={
        'query': 'machine learning tutorials',
        'limit': 5,
        'scrapeResults': True,
        'scrapeOptions': {
            'formats': ['markdown'],
        },
    },
)

results = response.json()['results']
for r in results:
    print(f"Title: {r['title']}")
    print(f"Content preview: {r.get('content', '')[:200]}...")
    print()

Use Cases

News Aggregation

{
  "query": "AI technology news",
  "categories": ["news"],
  "timeRange": "day",
  "limit": 20
}

Research

{
  "query": "climate change research papers",
  "categories": ["science"],
  "scrapeResults": true,
  "scrapeOptions": {
    "formats": ["markdown"],
    "onlyMainContent": true
  }
}

Competitive Analysis

{
  "query": "site:competitor.com product features",
  "scrapeResults": true
}

Notes

  • scrapeResults: true increases response time and quota usage
  • Use specific categories to improve result relevance
  • Time range filters help find recent content