LangChain Hreflang Tools
A comprehensive set of LangChain tools for analyzing hreflang implementation using the hreflang.org API. Perfect for international SEO analysis with AI agents.
🚀 Features
- Three powerful LangChain tools for hreflang analysis
- Compatible with CrewAI and any LangChain-based framework
- Comprehensive hreflang auditing for international websites
- Sitemap analysis for large-scale SEO audits
- Account management and usage tracking
- Detailed error reporting and recommendations
📦 Installation
pip install langchain-hreflang
For development with all extras:
pip install langchain-hreflang[all]
For CrewAI integration:
pip install langchain-hreflang[crewai]
🔑 Setup
- Get API Key: Visit hreflang.org, sign up (free), and generate an API key
- Set Environment Variable:
export HREFLANG_API_KEY="your_api_key_here"
Or add to your.envfile:HREFLANG_API_KEY=your_api_key_here
🛠️ Available Tools
1. test_hreflang_urls
Test specific URLs for hreflang implementation.
2. test_hreflang_sitemap
Analyze entire sitemaps for international SEO compliance.
3. check_hreflang_account_status
Monitor your API usage limits and test history.
📚 Usage Examples
Basic LangChain Usage
from langchain_hreflang import test_hreflang_urls, test_hreflang_sitemap
# Test specific URLs
result = test_hreflang_urls.run("https://example.com/en/, https://example.com/es/")
print(result)
# Test entire sitemap
result = test_hreflang_sitemap.run("https://example.com/sitemap.xml")
print(result)
CrewAI Integration
from crewai import Agent, Task, Crew
from langchain_hreflang import hreflang_tools
# Create SEO specialist agent
seo_agent = Agent(
role="International SEO Specialist",
goal="Analyze and optimize hreflang implementation for international websites",
backstory="Expert in international SEO with deep knowledge of hreflang best practices.",
tools=hreflang_tools, # All three tools included
verbose=True
)
# Create analysis task
task = Task(
description="""
Analyze the hreflang implementation for https://example.com:
1. Test the main language versions
2. Check the sitemap for comprehensive coverage
3. Identify any implementation issues
4. Provide specific recommendations
""",
agent=seo_agent
)
# Run the analysis
crew = Crew(agents=[seo_agent], tasks=[task])
result = crew.kickoff()
LangChain Agents
from langchain.agents import initialize_agent, AgentType
from langchain.llms import OpenAI
from langchain_hreflang import hreflang_tools
llm = OpenAI(temperature=0)
agent = initialize_agent(
hreflang_tools,
llm,
agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
verbose=True
)
result = agent.run("""
Analyze the hreflang implementation for airbnb.com.
Check their main international pages and provide a summary
including any issues found.
""")
🔍 What Gets Analyzed
- Hreflang tag implementation across language versions
- Self-declared language detection (
<html lang="en">) - Bidirectional linking between language versions
- Return tag errors and missing connections
- Site-wide statistics for entire domains
- Broken URLs and loading issues
- Language coverage analysis
📊 Example Output
Hreflang Test Results (Test ID: abc123...)
Total URLs tested: 3
URL: https://example.com/en/
Self-declared language: en
Hreflang links found: 3
en: https://example.com/en/
es: https://example.com/es/
fr: https://example.com/fr/
URL: https://example.com/es/
Self-declared language: es
Hreflang links found: 3
en: https://example.com/en/
es: https://example.com/es/
fr: https://example.com/fr/
Issues Found:
⚠️ Missing return link from FR to EN version
❌ https://example.com/de/ returns 404 error
🎯 Rate Limits
- Free Tier: 50 URLs per test, 10 tests per day
- Premium Tier: 1,000 URLs per test, 500 tests per day
Check your limits with check_hreflang_account_status().
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
📝 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
- hreflang.org for providing the excellent hreflang testing API
- LangChain for the powerful AI agent framework
- CrewAI for the collaborative AI agent platform
📞 Support
- Issues: GitHub Issues
- Documentation: README
- API Documentation: hreflang.org API docs
Made with ❤️ for the international SEO and AI community
Metadata
Release files for langchain-hreflang 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 | |
|---|---|---|---|---|
| langchain_hreflang-0.1.0.tar.gz | 21.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| langchain_hreflang-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 34.3 kB
Release files / langchain_hreflang-0.1.0.tar.gz
| Download URL | langchain_hreflang-0.1.0.tar.gz |
|---|---|
| Size | 21.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0290de66950361e85edf3a38aeeb05de674dbfac4a6cb66ae52840e593ebce1c
|
|
BLAKE2b-256 checksum How to use checksums |
15d8d2fcf9309e5b10db5c49de9bcec9a8b9476e8c3b683dc586521d730e0682
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / langchain_hreflang-0.1.0-py3-none-any.whl
| Download URL | langchain_hreflang-0.1.0-py3-none-any.whl |
|---|---|
| Size | 12.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0880253c1e51424f8173d0817d507a5382e09ace7746b6608c5047c8d694983c
|
|
BLAKE2b-256 checksum How to use checksums |
16a706573374ca7d9726a01eae9f23acf22f26d11e9065674c7928dc4321f8da
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Security for langchain-hreflang 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.