🚀 langchain-stackoverflow
LangChain retrievers for Stack Overflow — search questions and fetch full answers across the Stack Exchange network as LangChain Document objects. No API keys required (optional for higher rate limits).
Perfect for building coding assistants, RAG applications, and troubleshooting agents.
✨ Features
| Retriever | What it does | API Key Required? |
|---|---|---|
StackOverflowSearchRetriever |
Search questions by keyword or tags | ❌ No! |
StackOverflowAnswerRetriever |
Fetch all answers for a question | ❌ No! |
📦 Installation
pip install langchain-stackoverflow
🚀 Quick Start
Search Questions
from langchain_stackoverflow import StackOverflowSearchRetriever
retriever = StackOverflowSearchRetriever(
max_results=3,
sort="votes", # "relevance", "votes", "creation", "activity"
site="stackoverflow", # any Stack Exchange site (e.g. "serverfault")
tagged="python;pandas", # Optional: filter by tags
accepted_only=True, # Optional: only show questions with accepted answers
)
docs = retriever.invoke("how to merge dataframes")
for doc in docs:
print(f"❓ {doc.page_content.splitlines()[0]}") # Print question title
print(f" 👍 {doc.metadata['score']} votes | 💬 {doc.metadata['answer_count']} answers")
print(f" 🔗 {doc.metadata['url']}")
Fetch Answers
from langchain_stackoverflow import StackOverflowAnswerRetriever
retriever = StackOverflowAnswerRetriever(sort="votes")
# Pass the Stack Overflow URL or just the question ID
docs = retriever.invoke("https://stackoverflow.com/questions/53645882/pandas-merge-two-dataframes-with-different-columns")
for doc in docs:
if doc.metadata['is_accepted']:
print("✅ ACCEPTED ANSWER:")
else:
print("💡 ANSWER:")
print(f"Score: {doc.metadata['score']}")
print(f"{doc.page_content[:150]}...\n")
🔑 Rate Limits & API Keys
By default, the Stack Exchange API allows 300 requests per day per IP address without an API key.
If you need more, you can register a free app at Stack Apps to get an API key, which increases your quota to 10,000 requests per day.
Pass your key to the retriever:
retriever = StackOverflowSearchRetriever(api_key="your_key_here")
📄 License
MIT — see LICENSE for details.
Metadata
Release files for langchain-stackoverflow 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| langchain_stackoverflow-0.1.0.tar.gz | 6.2 kB | Without provenance | Details for langchain_stackoverflow-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| langchain_stackoverflow-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for langchain_stackoverflow-0.1.0-py3-none-any.whl |
Total release size: 13.6 kB
Release files / langchain_stackoverflow-0.1.0.tar.gz
| Download URL | langchain_stackoverflow-0.1.0.tar.gz |
|---|---|
| Size | 6.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
edc7a1145419f296a3dc7de75b70da40a8d28fc4aca45fb4c226d9ed1806eea6
|
|
BLAKE2b-256 checksum How to use checksums |
bf40f169e48e03a7e1508005352cbc43c6f49b50e75604f99f6f369f2a1d4c73
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.3
|
Release files / langchain_stackoverflow-0.1.0-py3-none-any.whl
| Download URL | langchain_stackoverflow-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
098f22c8afce513b11415e74c9945922b4d42995eb5be280493366fe8cf9a4fe
|
|
BLAKE2b-256 checksum How to use checksums |
1ad5819de86921ff9151b0abe2e894a5a63c061604c9c833b5d6262996589daa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.3
|
Security for langchain-stackoverflow 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.