Generate SEO Metadata from Any URL with One API Call (Title, OG, JSON-LD Schema)

javascript dev.to

Every time I publish a blog post, I spend 15–30 minutes crafting the perfect SEO meta tags: title, description, OpenGraph, Twitter card, JSON-LD schema. It's boring, repetitive, and I'm never sure I'm picking the most clickable wording.

So I built an API that does all of it in ~2 seconds, from any URL.

Try it: SEO Meta Generator API — free demo key, no signup.


What It Does

Send a URL (or raw HTML). Get back:

  • ✅ Optimized <title> (60 chars)
  • ✅ Meta description (160 chars, CTR-optimized)
  • ✅ Keywords array
  • ✅ OpenGraph tags (og:title, og:description, og:type, og:site_name)
  • ✅ Twitter card tags
  • ✅ JSON-LD Article schema
  • Pre-built html_tags string — ready to paste into <head>

All powered by Gemini 2.5 Flash via OpenRouter.


Quick Start

curl -X POST https://hubaiasia.com/seo-meta-api/meta \
  -H "X-Api-Key: demo-key-seo-meta" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/blog/post"}'
Enter fullscreen mode Exit fullscreen mode

Response:

{"ok":true,"meta":{"title":"The Ultimate AI Tools Guide 2026 — Top 10 Picks","description":"Compare the best AI tools for developers in 2026. Real pricing, real use cases.","keywords":["ai tools","gemini","claude","cursor"],"og":{"title":"The Ultimate AI Tools Guide 2026","description":"Top 10 AI tools every developer should know in 2026.","type":"article"},"twitter":{"card":"summary_large_image","title":"The Ultimate AI Tools Guide 2026"},"schema":{"@context":"https://schema.org","@type":"Article","headline":"..."}},"html_tags":"<title>The Ultimate AI Tools Guide 2026 — Top 10 Picks</title>\n<meta name=\"description\"...>"}
Enter fullscreen mode Exit fullscreen mode

That html_tags field is the killer feature — paste it directly into your <head> and you're done.


Real Use Case: Auto-Generate SEO on Publish (Node.js)

Here's a 20-line function that updates a WordPress post's meta as soon as it's published:

async function enhanceSEO(postUrl) {
  const r = await fetch('https://hubaiasia.com/seo-meta-api/meta', {
    method: 'POST',
    headers: {
      'X-Api-Key': process.env.SEO_META_KEY,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      url: postUrl,
      language: 'en',
      tone: 'professional',
      maxTitleChars: 60,
      maxDescChars: 160,
    }),
  });
  const data = await r.json();
  if (!data.ok) throw new Error('SEO generation failed');

  return {
    title: data.meta.title,
    description: data.meta.description,
    keywords: data.meta.keywords.join(', '),
    ogImage: data.meta.og?.image,
    htmlTags: data.html_tags,
  };
}

// Usage in your CMS publish hook:
const seo = await enhanceSEO('https://myblog.com/new-post');
await wordpress.updatePostMeta(postId, seo);
Enter fullscreen mode Exit fullscreen mode

Working with Raw HTML or Content

Don't want to expose a URL? Send HTML directly:

await fetch('https://hubaiasia.com/seo-meta-api/meta', {
  method: 'POST',
  headers: { 'X-Api-Key': 'demo-key-seo-meta', 'Content-Type': 'application/json' },
  body: JSON.stringify({
    html: '<article>' + articleBody + '</article>',
    language: 'auto',
    siteName: 'My Blog',
  }),
});
Enter fullscreen mode Exit fullscreen mode

The API auto-scopes to <main> or <article> if present, so headers and sidebars don't pollute the analysis.


Multilingual (Thai, Japanese, Spanish, etc.)

Set language: 'auto' and the model detects the content language. Or force it:

{"url":"https://my-thai-blog.com/post","language":"th","tone":"casual"}
Enter fullscreen mode Exit fullscreen mode

Gemini 2.5 Flash handles Thai, Japanese, Chinese, Spanish, and ~100 other languages.


Pricing

  • Free: 100 calls/day — use demo-key-seo-meta
  • Basic: $9/mo — 5,000 calls/day
  • Pro: $29/mo — 50,000 calls/day
  • Ultra: $99/mo — 200,000 calls/day

Tips for Best Results

  1. Use url over html when possible — the API fetches fresh content and avoids stale cache.
  2. Set siteName explicitly — it ends up in og:site_name for better brand attribution in social shares.
  3. Tune toneprofessional for corporate content, casual for personal blogs, marketing for sales pages.
  4. Check html_tags before blindly pasting — AI is good, but always verify the output matches your brand voice.

Under the Hood

  • Fastify + Node.js
  • OpenRouter with Gemini 2.5 Flash (response_format: json_object for reliable structured output)
  • Rate limiting in-memory, per API key
  • Docker-deployed on a single VPS, ~2s average response time
  • No tracking, no data retention — content is processed in-memory, never stored

Try It Now

👉 SEO Meta Generator API docs — interactive demo, free tier, no signup.

Questions? Drop them in the comments 👇


Built by HubAI Asia — I build small APIs to save myself from boring work.

Source: dev.to

arrow_back Back to Tutorials