EarlySEO LogoEarlySEO Docs

Python SDK

Add an EarlySEO blog to your Django or Flask app with the earlyseo-blog Python package. Overview, installation, CLI scaffold, and standalone client.

Open .mdx

Overview

The earlyseo-blog Python package lets you render EarlySEO articles in Django, Flask, or any Python application. Articles are authored in the EarlySEO dashboard, published to a global CDN, and fetched at runtime by the package.


Quick Start with CLI

The fastest way to get started — the CLI detects your framework and scaffolds everything:

pip install earlyseo-blog
earlyseo-blog

The CLI will:

  1. Detect your framework (Django or Flask)
  2. Ask for your Site ID (from Dashboard → Integrations → SDK)
  3. Generate starter templates, config, and a .env file

Framework Guides

For step-by-step setup instructions, follow the guide for your framework:

FrameworkGuideInstall
DjangoDjango SDK Guidepip install "earlyseo-blog[django]"
FlaskFlask SDK Guidepip install "earlyseo-blog[flask]"

Prerequisites

  • Python ≥ 3.9
  • An EarlySEO account with at least one published article
  • SDK integration enabled (Dashboard → Integrations → SDK)
  • Site ID from the SDK integration card

Installation

# Core package (standalone client only)
pip install earlyseo-blog

# With Django support
pip install "earlyseo-blog[django]"

# With Flask support
pip install "earlyseo-blog[flask]"

# With async HTTP/2 support
pip install "earlyseo-blog[async]"

Standalone Client

Use the client directly in any Python code — scripts, APIs, data pipelines, or microservices:

from earlyseo_blog import EarlySeoClient

client = EarlySeoClient(site_id="your-site-id")

# Paginated article list
page = client.get_list_page(1)
for item in page.articles:
    print(item.title, item.slug)

# Full article with HTML content
article = client.get_article("my-slug")
print(article.content_html)

Async Client

For high-throughput or async frameworks (FastAPI, Starlette, Quart):

from earlyseo_blog import AsyncEarlySeoClient

async with AsyncEarlySeoClient(site_id="your-site-id") as client:
    page = await client.get_list_page(1)
    article = await client.get_article("my-slug")

Install the async extra for HTTP/2 support:

pip install "earlyseo-blog[async]"

Configuration Reference

SettingDescriptionDefault
site_idYour EarlySEO site ID (required)
cdn_base_urlCDN base URLhttps://media.earlyseo.com

Django: Set EARLYSEO_SITE_ID and EARLYSEO_CDN_BASE_URL in settings.py.

Flask: Set app.config["EARLYSEO_SITE_ID"] and app.config["EARLYSEO_CDN_BASE_URL"].


Data Models

All API responses are validated with Pydantic v2:

ModelDescription
ManifestSite manifest — total pages and article count
ArticleListItemArticle summary for list views (title, slug, meta_description, featured_image_url)
ArticleListPagePaginated list of ArticleListItem with page metadata
ArticleFull article including content_html, SEO fields, and metadata
from earlyseo_blog.models import Article, Manifest, ArticleListPage

How Publishing Works

  1. Write and publish an article in the EarlySEO dashboard
  2. EarlySEO writes JSON files to the global CDN (media.earlyseo.com)
  3. Your Python app fetches JSON at request time
  4. Articles include SEO metadata automatically

Need Help?

On this page