Docs📄 DocumentsText Summarizer
POST/api/summarize$0.005

📄 Text Summarizer

Summarize long text using extractive summarization. Identifies and returns the most important sentences that capture the core meaning of the document. Optionally specify a target length.

Request Body

ParameterTypeRequiredDescriptionDefault
textstringrequiredText content to summarize
maxLengthnumberoptionalMaximum summary length in words200

Response Fields

FieldTypeDescription
summarystringSummarized text
original_lengthnumberWord count of original text
summary_lengthnumberWord count of summary
compression_rationumberRatio of summary to original length

Code Examples

cURL
bash
curl -X POST https://sparkforge.sh/api/summarize \
  -H "Content-Type: application/json" \
  -H "X-PAYMENT: <x402-payment-token>" \
  -d '{
    "text": "Your long article or document text here...",
    "maxLength": 150
  }'
Python
python
import requests

long_text = "Your very long article or document goes here..."

response = requests.post(
    "https://sparkforge.sh/api/summarize",
    headers={"Content-Type": "application/json", "X-PAYMENT": "<token>"},
    json={"text": long_text, "maxLength": 150}
)

data = response.json()
print(data["summary"])
print(f"Compression: {data['compression_ratio']:.1%}")
TypeScript / Node.js
typescript
const res = await fetch402("https://sparkforge.sh/api/summarize", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ text: longArticle, maxLength: 150 }),
});

const { summary, compression_ratio } = await res.json();

Example Response

json
{
  "summary": "Bitcoin is a decentralized digital currency that operates without a central authority. Created in 2009 by Satoshi Nakamoto, it uses blockchain technology to enable peer-to-peer transactions.",
  "original_length": 12450,
  "summary_length": 38,
  "compression_ratio": 0.003
}

💳 Payment via x402

This endpoint costs $0.005 per call, paid in USDC on Base, Polygon, or Solana. Use the @x402/fetch library to handle payments automatically, or implement the x402 handshake manually.

bash
# Free demo mode (no payment)
curl https://sparkforge.sh/api/summarize?demo=true

# Or try via MCP (Claude Desktop, Cursor, Windsurf)
# Add to mcp config: { "url": "https://sparkforge.sh/api/mcp" }
Previous
HTML to Markdown
Next
Webpage Screenshot