v0.1 · Web Intelligence Layer

HANAI API
Reference

Transform raw search results into structured @entities, hierarchical folder paths, and trust scores. Every request runs through a 6-step pipeline — fully hosted, no setup required.

Base URL hanai-api.onrender.com
Format JSON
Auth X-API-Key
Free Tier 50 req / day
01

Get an API Key

HANAI is a hosted API — no installation, no servers to manage. Get your key in under a minute:

1

List your application

Head to the Developer Portal and sign in with Google.

2

Generate your key

Click Generate API Key. Your key looks like hnai_abc123... — copy it immediately.

3

Attach to every request

Pass the key via the X-API-Key header on all protected endpoints.

Free tier: 50 requests per day. No credit card required. Limits reset daily at midnight UTC.
02

Quick Start

Make your first structured search in under a minute.

cURL
curl -X POST https://hanai-api.onrender.com/search \
  -H "X-API-Key: hnai_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{"query": "buy running shoes", "region": "auto"}'
JavaScript
const res = await fetch('https://hanai-api.onrender.com/search', {
  method:  'POST',
  headers: {
    'X-API-Key':    'hnai_your_key_here',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({ query: 'buy running shoes', region: 'auto' })
});
const data = await res.json();
Python
import requests

data = requests.post(
  'https://hanai-api.onrender.com/search',
  headers = { 'X-API-Key': 'hnai_your_key_here' },
  json    = { 'query': 'buy running shoes', 'region': 'auto' }
).json()
03

Authorization

Protected endpoints require your API key in the X-API-Key request header.

Header X-API-Key: hnai_your_key_here
Keep your key secret. Never expose it in client-side code or public repos. Regenerate it anytime from the Developer Portal.
04

@Entities Core Concept

Every domain maps to a canonical @entity. Multiple regional or subdomain variants collapse into one stable identity — so your code never needs to handle duplicates.

Entity Resolution
# Regional variants → single entity
amazon.com    ─┐
amazon.in     ─┤  →  @amazon
amazon.co.uk  ─┘

# Subdomains → entity + service attribute
maps.google.com  →  @google   (service: maps)
youtube.com      →  @youtube  (service: video)
05

Folder System Core Concept

Each entity gets a structured hierarchical path following the pattern @entity / region / service / category, making results navigable like a filesystem.

Path Examples
@amazon    / india  / fashion
@google    / global / maps
@youtube   / global / video
@wikipedia / global / education
@myntra    / india  / fashion
06

Trust Engine Core Concept

Six signals combine into a trust score. Results are ranked trust-first — dangerous entries never surface above verified ones.

LabelScoreMeaning
Verified ≥ 0.88Known, established entity with consistent history
Safe ≥ 0.70Appears legitimate, no suspicious signals
Unverified ≥ 0.50Unknown origin but nothing flagged
Suspicious ≥ 0.30Unusual domain patterns or signals detected
Dangerous < 0.30Fake or malicious entity detected
07

Intent Engine Core Concept

Every query is classified before fetching. Intent type affects ranking weights and minimum trust thresholds applied to results.

Intent Types
transactional"buy shoes", "order pizza"
navigational"amazon login", "youtube"
informational"how does X work"
local"restaurants near me"
API Reference
09

GET /entity

GET
/entity
List all known @entities in the registry
No Auth
Endpoints
GET /entity           # list all known entities
GET /entity/:id      # e.g. GET /entity/amazon
10

GET /trust

GET
/trust/:entity
Retrieve trust details for a specific @entity
No Auth
Example
GET /trust/amazon
11

Response Schema

Every POST /search response returns the same structured envelope:

Response JSON
{
  "intent": { "type": "transactional", "confidence": 0.92 },
  "tab": "web",
  "results": [
    {
      "entity":   "@amazon",
      "path":     "@amazon/india/fashion",
      "display":  "@amazon / india / fashion",
      "folders": [
        { "type": "region",   "value": "india"   },
        { "type": "category", "value": "fashion" }
      ],
      "trust": {
        "score":      0.91,
        "label":      "Verified",
        "confidence": 0.95
      },
      "source_count": 4,
      "rank":         1
    }
  ],
  "meta": {
    "query":            "buy running shoes",
    "region":           "in",
    "duration_ms":      312,
    "result_count":     3,
    "raw_result_count": 18
  }
}
12

Rate Limits

Limits are per API key and reset daily at midnight UTC.

Endpoint
Per Day
Per Minute
Search
POST /search
50
Free tier
20
Lookups
GET /entity, /trust
Unlimited
60
Current usage and key management are available in the Developer Portal.
13

Error Codes

StatusCodeDescription
401MISSING_KEYNo X-API-Key header provided
403INVALID_KEYKey not found or has been revoked
429DAILY_LIMIT50 request daily limit reached
429RATE_LIMITToo many requests per minute
400EMPTY_QUERYQuery field missing or empty
500SERVER_ERRORInternal pipeline error
SDKs
14

JavaScript SDK

JavaScript / ESM
import HANAI from 'https://cdn.jsdelivr.net/npm/hanai-sdk/hanai.min.js';

const client = new HANAI({
  baseURL: 'https://hanai-api.onrender.com',
  apiKey:  'hnai_your_key_here'
});

const results = await client.search('buy shoes', { region: 'india' });
const trust   = await client.trust('amazon');
const entity  = await client.entity('google');
15

Python SDK

Python
from hanai import HANAI

client = HANAI(
  base_url = 'https://hanai-api.onrender.com',
  api_key  = 'hnai_your_key_here'
)

results  = client.search('buy shoes', region='india')
trust    = client.trust('amazon')
entities = client.entities()