Meta Tag Generator API: The Complete Guide

Need to generate proper meta tags for SEO? This guide covers everything you need to know about creating meta tags via API, including essential tags, character limits, and implementation examples in multiple languages.

What are Meta Tags?

Meta tags are HTML elements that provide metadata about a web page. They appear in the <head> section of HTML and provide information to search engines and browsers about your page's content, character encoding, viewport settings, and more.

Meta tags look like: <meta name="description" content="Your page description">

Essential Meta Tags

The most important meta tags for SEO and functionality:

Tag Purpose Required
titlePage title shown in search resultsYes
descriptionSummary shown in search resultsYes
viewportControls page zoom on mobile devicesYes
charsetCharacter encoding (UTF-8)Yes
robotsInstructions for search crawlersSometimes
canonicalPreferred URL for duplicate contentRecommended
Pro Tip: The meta description doesn't directly affect rankings but significantly impacts click-through rates from search results.

Using the Meta Tag API

TinyFn provides an endpoint to generate comprehensive meta tags:

API Request
POST https://api.tinyfn.io/v1/generate/metatags
Headers: X-API-Key: your-api-key
Content-Type: application/json

{
  "title": "My Amazing Page - Brand Name",
  "description": "Discover the best content about amazing topics. Learn more about our services.",
  "url": "https://example.com/page",
  "robots": "index, follow",
  "author": "Brand Name",
  "keywords": ["topic1", "topic2", "topic3"]
}
Response
{
  "html": "<meta charset=\"UTF-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n<title>My Amazing Page - Brand Name</title>\n<meta name=\"description\" content=\"Discover the best content...\">\n<meta name=\"robots\" content=\"index, follow\">\n<link rel=\"canonical\" href=\"https://example.com/page\">",
  "tags": {
    "title": "My Amazing Page - Brand Name",
    "description": "Discover the best content about amazing topics. Learn more about our services.",
    "robots": "index, follow"
  },
  "character_counts": {
    "title": 29,
    "description": 80
  }
}

Parameters

Parameter Type Description
title string Page title (required)
description string Meta description (required)
url string Canonical URL
robots string Robots directive (default: index, follow)
include_og boolean Include Open Graph tags (default: true)

Code Examples

JavaScript / Node.js

const response = await fetch('https://api.tinyfn.io/v1/generate/metatags', {
  method: 'POST',
  headers: {
    'X-API-Key': 'your-api-key',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    title: 'Product Name - Best Online Store',
    description: 'Buy Product Name at the best price. Free shipping available.',
    url: 'https://store.com/product/123',
    robots: 'index, follow'
  })
});
const { html } = await response.json();
// Insert into page head

Python

import requests

response = requests.post(
    'https://api.tinyfn.io/v1/generate/metatags',
    json={
        'title': 'Blog Post Title - My Blog',
        'description': 'An interesting article about technology and innovation.',
        'url': 'https://myblog.com/posts/article',
        'author': 'John Doe'
    },
    headers={'X-API-Key': 'your-api-key'}
)
data = response.json()
print(data['html'])

Character Limits

  • Title: 50-60 characters (Google displays ~60)
  • Description: 150-160 characters (Google may show up to 320)
  • Keywords: Not used by Google, but can include 5-10 terms
  • URL: Keep under 75 characters for display

Best Practices

  1. Unique titles and descriptions: Every page should have unique meta tags
  2. Include keywords naturally: Put important keywords early in title and description
  3. Write for users: Meta tags should entice clicks, not just rank
  4. Always set canonical: Prevent duplicate content issues

Use via MCP

Your AI agent can call this tool directly via Model Context Protocol — no HTTP code needed. Add TinyFn to Claude Desktop, Cursor, or any MCP client:

{
  "mcpServers": {
    "tinyfn-generate": {
      "url": "https://api.tinyfn.io/mcp/generate/",
      "headers": {
        "X-API-Key": "your-api-key"
      }
    }
  }
}

See all generator tools available via MCP in our Generator MCP Tools for AI Agents guide.

Try the Meta Tag Generator API

Get your free API key and start creating SEO-optimized meta tags.

Get Free API Key

Ready to try TinyFn?

Get your free API key and start building in minutes.

Get Free API Key