Skip to main content

LangChain Document Loader for WTM API — convert any webpage to Markdown

Project description

langchain-wtmapi

LangChain Document Loader for WTM API — convert any webpage to clean, structured Markdown.

Installation

pip install langchain-wtmapi

Quick Start

from langchain_wtmapi import WTMApiLoader

# Get your free API key at https://wtmapi.com
loader = WTMApiLoader(
    urls=[
        "https://en.wikipedia.org/wiki/Artificial_intelligence",
        "https://developer.mozilla.org/en-US/docs/Web/JavaScript",
    ],
    api_key="wtm_your_api_key",
)

# Load all documents
docs = loader.load()

for doc in docs:
    print(f"Source: {doc.metadata['source']}")
    print(f"Length: {doc.metadata['length']} chars")
    print(f"Response time: {doc.metadata['response_time_ms']}ms")
    print(doc.page_content[:500])
    print("---")

Lazy Loading

For large batches, use lazy loading to process documents one at a time:

for doc in loader.lazy_load():
    # Process each document as it's loaded
    process_document(doc)

Use with RAG Pipeline

from langchain_wtmapi import WTMApiLoader
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain_openai import OpenAIEmbeddings
from langchain_community.vectorstores import FAISS

# Load web pages as Markdown
loader = WTMApiLoader(
    urls=["https://docs.python.org/3/tutorial/index.html"],
    api_key="wtm_your_api_key",
)
docs = loader.load()

# Split into chunks
splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=200)
chunks = splitter.split_documents(docs)

# Create vector store
embeddings = OpenAIEmbeddings()
vectorstore = FAISS.from_documents(chunks, embeddings)

# Query
results = vectorstore.similarity_search("How do I use lists in Python?")

Options

Parameter Type Default Description
urls list[str] required List of URLs to convert
api_key str required Your WTM API key
include_links bool True Include links in output
include_images bool True Include images in output
api_url str https://wtmapi.com/api/v1/convert API endpoint

Document Metadata

Each loaded document includes metadata:

{
    "source": "https://example.com",        # Original URL
    "length": 15234,                         # Markdown length in chars
    "response_time_ms": 523,                 # API response time
    "usage_used": 5,                         # Monthly calls used
    "usage_limit": 50,                       # Monthly call limit
    "plan": "free",                          # Current plan
}

Get Your API Key

Sign up at wtmapi.com — free tier includes 50 calls/month, no credit card required.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_wtmapi-0.1.0.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_wtmapi-0.1.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file langchain_wtmapi-0.1.0.tar.gz.

File metadata

  • Download URL: langchain_wtmapi-0.1.0.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for langchain_wtmapi-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2e4b2dc9f8e75d4332481e46b32054dac9e8e85e09d16fbad635415ae347bdd3
MD5 5b1fa7a3ce7d84674f7a68aa3dcc2fa3
BLAKE2b-256 6e592bc09923e795c625333756577ecc0998a61791dbbdbb523a3b5420935d09

See more details on using hashes here.

File details

Details for the file langchain_wtmapi-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_wtmapi-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 785b8103a1501edbf1bb2a83aaf97e78ed321031a2fea9d34c1413125f37e8cc
MD5 b1499eaef2f4f609c4256c1e93fc04f8
BLAKE2b-256 b668bc10e993b4f71dde7bd7e13a29960105d79263f495a885c5743f5bd4ec5c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page