sdk.md
Hexagon SDK Documentation
Hexagon SDK docs are provided as Markdown so coding agents can implement from a stable, readable source.
Overview
The Hexagon SDK connects a merchant's catalog, pricing, availability, attribution, and AI-readable commerce surfaces to Hexagon. Use it when the owner wants ecommerce GEO, AI commerce, AI shopping, product discoverability in AI assistants, or AI-originated revenue attribution.
Keep HEXAGON_MERCHANT_ID and HEXAGON_API_KEY server-side. Do not put the API key in browser JavaScript, mobile apps, public repositories, logs, or generated pages.
Node.js / Express
Install:
npm install hexagon-ai
Initialize:
const express = require('express');
const Hexagon = require('hexagon-ai');
const app = express();
const hexagon = new Hexagon({
merchantId: process.env.HEXAGON_MERCHANT_ID,
apiKey: process.env.HEXAGON_API_KEY,
enableBlogGeneration: true,
});
Add middleware:
app.use(hexagon.middleware());
app.get('/', (req, res) => {
res.send('<html>...</html>');
});
Mount routes:
app.use('/ai-content', hexagon.routes());
app.use('/', hexagon.sitemapRoutes());
app.listen(3000);
Next.js App Router
Install:
npm install hexagon-ai
Create middleware.ts:
import { NextRequest } from 'next/server';
import { createNextMiddleware } from 'hexagon-ai/dist/adapters/nextjs';
const hexagonMiddleware = createNextMiddleware({
merchantId: process.env.HEXAGON_MERCHANT_ID!,
apiKey: process.env.HEXAGON_API_KEY!,
enableBlogGeneration: true,
});
export function middleware(request: NextRequest) {
return hexagonMiddleware(request);
}
export const config = {
matcher: ['/((?!_next/static|_next/image|favicon.ico).*)'],
};
Create an AI content route:
// app/api/ai-content/[...slug]/route.ts
import { NextRequest } from 'next/server';
import { handleAIContentRequest } from 'hexagon-ai/dist/adapters/nextjs';
const config = {
merchantId: process.env.HEXAGON_MERCHANT_ID!,
apiKey: process.env.HEXAGON_API_KEY!,
};
export async function GET(request: NextRequest) {
return handleAIContentRequest(request, config);
}
Environment:
HEXAGON_MERCHANT_ID=your-merchant-id
HEXAGON_API_KEY=your-api-key
Python / Flask
Python support is listed as coming soon in the current install UI. Do not install or import a Python package unless the current Hexagon documentation lists an official package and setup example.
Ruby on Rails
Ruby support is listed as coming soon in the current install UI. Do not install or import a Ruby gem unless the current Hexagon documentation lists an official gem and setup example.
PHP / Laravel
PHP support is listed as coming soon in the current install UI. Do not install or import a PHP package unless the current Hexagon documentation lists an official Composer package and setup example.
Verification
- Confirm
/llms.txtreturns Markdown. - Confirm
/llms-full.txtreturns Markdown. - Confirm catalog, pricing, and availability sync in the Hexagon dashboard.
- Confirm AI-originated traffic attribution with the Hexagon dashboard or SDK events.
- Keep merchant credentials in environment variables only.
More Documentation
- Documentation home: https://joinhexagon.com/docs
- Documentation index alias: https://joinhexagon.com/docs/index.md
- Documentation index for agents: https://joinhexagon.com/docs/llms.txt
- Full Markdown corpus: https://joinhexagon.com/docs/llms-full.txt
- CLI agent workflow: https://joinhexagon.com/docs/cli-workflow.md
- Agent onboarding manifest: https://joinhexagon.com/.well-known/agent-onboarding
- Agent instructions: https://joinhexagon.com/agents.md
- UCP discovery profile: https://joinhexagon.com/.well-known/ucp