MH MediaHarvester Web Context API

AI Query

AI Query API

Ask a website for structured datapoints with evidence URLs.

POST /v1/brand/ai/query

What you get

Developer-ready output for AI Query API

01 Custom datapoints
02 Specific page hints
03 Schema-shaped output
04 Source evidence

How it works

Four steps from request to usable JSON

1

Define fields to extract

2

Select domain or pages

3

Scrape relevant content

4

Return structured answers

API response

Fields developers usually wire first

Ask a website for custom datapoints and receive structured JSON with source evidence.

data_extracted[] sources[] confidence urls_analyzed[]
curl.exe -H "X-API-Key: mh-localhost-dev-key" "http://127.0.0.1:8013/v1/brand/ai/query"

Developer FAQ

Common questions about AI Query API

12 answers
What can I ask AI Query to extract?

Pricing, target customers, integrations, product categories, positioning, policy details, contact rules or any structured field your workflow defines.

Does it include evidence?

Yes. Responses should include source URLs so developers and users can review where a value came from.

Should I use AI Query or Product Extraction?

Use Product Extraction for product-specific fields. Use AI Query for custom questions that vary by workflow.

What endpoint should I call for AI Query API?

Use POST /v1/brand/ai/query. Local development accepts the X-API-Key header with mh-localhost-dev-key, and production clients can use the same shape with their own key.

Can I call it from CLI, SDK, MCP and no-code tools?

Yes. The same endpoint can be called with curl, the TypeScript SDK, Python SDK, MCP server, Zapier, Make, n8n, Google Sheets or Excel workflows where appropriate.

How does caching with maxAgeMs work?

When maxAgeMs is supported, a cached response can be reused if it is younger than the requested freshness window. Set maxAgeMs to 0 when you need a fresh scrape or extraction.

What happens when a page is blocked or requires login?

The API returns clear states such as blocked, verification_required, login_required, robots_disallowed or permission_required. It does not promise to bypass access controls.

Which response fields should I store?

Most integrations store data_extracted[], sources[], confidence, urls_analyzed[], plus source URL, status, confidence and timestamp fields when present. Keep source metadata so users can audit values later.

Can I batch this endpoint?

For local or small workflows, loop over a list of URLs or domains. For larger jobs, use crawl, batch workflow endpoints or a queue so failures and retries are tracked cleanly.

How should I handle errors in production?

Check success, HTTP status, error.type and retryable flags. Retry timeouts and temporary network failures, but do not retry robots, login or permission errors without changing input or authorization.

Does the API work with JavaScript-heavy sites?

The engine router starts with fast fetching and escalates when content quality is low. Browser-style rendering is used where available, while access-control barriers are reported explicitly.

Is this safe to use with customer data?

Send only domains, URLs or fields your workflow needs. Use retention controls for generated artifacts and avoid storing unnecessary raw HTML, screenshots or extracted personal data.

Related data APIs

Build the next step in the workflow