Licence
MIT
Version
0.2.0
Deps
3
Size
125 kB
Vulns
0
Weekly
0
LangChain Stripe Loader
A LangChain document loader for Stripe documentation and website content. This package provides tools to extract and process content from Stripe's documentation and website for use with LangChain applications.
Installation
npm install langchain-stripe-loader
Features
- Extract content from Stripe's official documentation (docs.stripe.com)
- Extract content from Stripe's main website (stripe.com)
- Support for different locales
- Convert HTML content to Markdown for better compatibility with LLMs
- Metadata extraction (title, description, source URL)
Usage
Loading Content from Stripe Documentation
import { StripeDocsDocumentLoader } from 'langchain-stripe-loader';
// Create a loader instance
const loader = new StripeDocsDocumentLoader();
// Load documents with default locale (en-US)
const documents = await loader.load();
// Or specify a different locale
const jaDocuments = await loader.load({
locale: 'ja-JP',
});
// Load documents with specific options
const customDocuments = await loader.load({
resource: 'connect', // Filter by resource path
excludeResources: ['connect/account-balances'],
});
// Fetch the Markdown version that docs.stripe.com serves at `<page>.md`
// (no HTML extraction; titles come without the " | Stripe Documentation" suffix)
const markdownDocuments = await loader.load({
locale: 'ja-JP',
resource: 'payments',
format: 'markdown',
});
// Use the documents with your LangChain application
console.log(`Loaded ${documents.length} documents`);
Options: rate limiting, logging, and format
Requests are sent one at a time with a delay between them, and HTTP 429 / 5xx responses are
retried with exponential backoff (honouring Retry-After). A full sitemap contains thousands of
pages, so narrow it down with resource or urls where you can.
const loader = new StripeDocsDocumentLoader({
format: 'markdown', // default format for load(); 'html' when omitted
debug: true, // print log / warn messages with the default console logger
logger: myLogger, // any object with log / warn / error; defaults to console
rateLimit: {
requestDelayMs: 1000, // delay between requests (default 1000)
requestJitterMs: 500, // random variation, ±half of this value (default 500)
maxRetries: 3, // retries for 429 / 5xx and network errors (default 3)
backoffBaseMs: 1000, // exponential backoff base (default 1000)
backoffMaxMs: 30000, // upper bound for a single wait (default 30000)
},
});
new StripeDocsDocumentLoader(true) (debug only) is still supported.
Loading Content from Stripe.com Website
import { StripeComDocumentLoader } from 'langchain-stripe-loader';
// Create a loader instance
const loader = new StripeComDocumentLoader();
// Load all documents
const documents = await loader.load();
// Load documents with specific options
const customDocuments = await loader.load({
resource: '/jobs', // Filter by resource path
locale: 'en-US', // Specify locale
});
// Load specific URLs
const specificDocuments = await loader.load({
urls: ['https://stripe.com/docs/payments', 'https://stripe.com/docs/billing'],
});
API Reference
StripeDocsDocumentLoader
Document loader for Stripe's official documentation (docs.stripe.com).
Constructor
constructor(options?: boolean | StripeDocsLoaderOptions)
options.format:'html'(default) or'markdown'options.debug,options.logger,options.rateLimit,options.fetch,options.sleep: see "Options" above- Passing a boolean sets
debug(legacy signature)
Methods
load(options?: { locale?: string; urls?: string[]; resource?: string; excludeResources?: string[]; format?: 'html' | 'markdown' }): Promise<Document[]>- Load documents from Stripe Docs.localedefaults toen-US
StripeComDocumentLoader
Document loader for Stripe's main website (stripe.com).
Constructor
constructor(options?: boolean | StripeLoaderOptions)
options.debug,options.logger,options.rateLimit,options.fetch,options.sleep: see "Options" above- Passing a boolean sets
debug(legacy signature)
Methods
load(options?: { resource?: string; locale?: string; urls?: string[] }): Promise<Document[]>- Load documents from Stripe.com with optional filtering. Pages that return HTTP 400 or higher are skipped
How It Works
- The loaders fetch URLs from Stripe's sitemaps
- Each page is downloaded one at a time, with a delay between requests and retries on 429 / 5xx
- With
format: 'html', relevant content is extracted using regex patterns and converted to Markdown using node-html-markdown - With
format: 'markdown'(docs.stripe.com only), the<page>.mdMarkdown is used as-is - Content is wrapped in LangChain Document objects with metadata
Dependencies
@langchain/core: LangChain core functionalitystripe-loaders-core: Core utilities for Stripe loadersturndown: HTML to Markdown conversion
License
MIT