langchain-hreflang


Namelangchain-hreflang JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/diffen/langchain-hreflang
SummaryLangChain tools for hreflang SEO analysis using hreflang.org API
upload_time2025-08-25 04:29:42
maintainerNone
docs_urlNone
authorNick Jasuja
requires_python>=3.12
licenseMIT License Copyright (c) 2025 Your Name Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords langchain hreflang seo international ai agents crewai
VCS
bugtrack_url
requirements langchain-core requests pydantic
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # LangChain Hreflang Tools

[![PyPI version](https://badge.fury.io/py/langchain-hreflang.svg)](https://badge.fury.io/py/langchain-hreflang)
[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

A comprehensive set of LangChain tools for analyzing hreflang implementation using the [hreflang.org](https://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

```bash
pip install langchain-hreflang
```

For development with all extras:
```bash
pip install langchain-hreflang[all]
```

For CrewAI integration:
```bash
pip install langchain-hreflang[crewai]
```

## 🔑 Setup

1. **Get API Key**: Visit [hreflang.org](https://app.hreflang.org/), sign up (free), and generate an API key
2. **Set Environment Variable**:
   ```bash
   export HREFLANG_API_KEY="your_api_key_here"
   ```
   Or add to your `.env` file:
   ```
   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

```python
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

```python
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

```python
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.

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

## 📝 License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## 🙏 Acknowledgments

- [hreflang.org](https://hreflang.org) for providing the excellent hreflang testing API
- [LangChain](https://langchain.com) for the powerful AI agent framework
- [CrewAI](https://crewai.com) for the collaborative AI agent platform

## 📞 Support

- **Issues**: [GitHub Issues](https://github.com/yourusername/langchain-hreflang/issues)
- **Documentation**: [README](https://github.com/yourusername/langchain-hreflang#readme)
- **API Documentation**: [hreflang.org API docs](https://app.hreflang.org/api-docs.php)

---

**Made with ❤️ for the international SEO and AI community**

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/diffen/langchain-hreflang",
    "name": "langchain-hreflang",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.12",
    "maintainer_email": null,
    "keywords": "langchain, hreflang, seo, international, ai, agents, crewai",
    "author": "Nick Jasuja",
    "author_email": "Nick Jasuja <nikhilesh@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/15/d8/d2fcf9309e5b10db5c49de9bcec9a8b9476e8c3b683dc586521d730e0682/langchain_hreflang-0.1.0.tar.gz",
    "platform": null,
    "description": "# LangChain Hreflang Tools\n\n[![PyPI version](https://badge.fury.io/py/langchain-hreflang.svg)](https://badge.fury.io/py/langchain-hreflang)\n[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nA comprehensive set of LangChain tools for analyzing hreflang implementation using the [hreflang.org](https://hreflang.org) API. Perfect for international SEO analysis with AI agents.\n\n## \ud83d\ude80 Features\n\n- **Three powerful LangChain tools** for hreflang analysis\n- **Compatible with CrewAI** and any LangChain-based framework\n- **Comprehensive hreflang auditing** for international websites\n- **Sitemap analysis** for large-scale SEO audits\n- **Account management** and usage tracking\n- **Detailed error reporting** and recommendations\n\n## \ud83d\udce6 Installation\n\n```bash\npip install langchain-hreflang\n```\n\nFor development with all extras:\n```bash\npip install langchain-hreflang[all]\n```\n\nFor CrewAI integration:\n```bash\npip install langchain-hreflang[crewai]\n```\n\n## \ud83d\udd11 Setup\n\n1. **Get API Key**: Visit [hreflang.org](https://app.hreflang.org/), sign up (free), and generate an API key\n2. **Set Environment Variable**:\n   ```bash\n   export HREFLANG_API_KEY=\"your_api_key_here\"\n   ```\n   Or add to your `.env` file:\n   ```\n   HREFLANG_API_KEY=your_api_key_here\n   ```\n\n## \ud83d\udee0\ufe0f Available Tools\n\n### 1. `test_hreflang_urls`\nTest specific URLs for hreflang implementation.\n\n### 2. `test_hreflang_sitemap`\nAnalyze entire sitemaps for international SEO compliance.\n\n### 3. `check_hreflang_account_status`\nMonitor your API usage limits and test history.\n\n## \ud83d\udcda Usage Examples\n\n### Basic LangChain Usage\n\n```python\nfrom langchain_hreflang import test_hreflang_urls, test_hreflang_sitemap\n\n# Test specific URLs\nresult = test_hreflang_urls.run(\"https://example.com/en/, https://example.com/es/\")\nprint(result)\n\n# Test entire sitemap\nresult = test_hreflang_sitemap.run(\"https://example.com/sitemap.xml\")\nprint(result)\n```\n\n### CrewAI Integration\n\n```python\nfrom crewai import Agent, Task, Crew\nfrom langchain_hreflang import hreflang_tools\n\n# Create SEO specialist agent\nseo_agent = Agent(\n    role=\"International SEO Specialist\",\n    goal=\"Analyze and optimize hreflang implementation for international websites\",\n    backstory=\"Expert in international SEO with deep knowledge of hreflang best practices.\",\n    tools=hreflang_tools,  # All three tools included\n    verbose=True\n)\n\n# Create analysis task\ntask = Task(\n    description=\"\"\"\n    Analyze the hreflang implementation for https://example.com:\n    1. Test the main language versions\n    2. Check the sitemap for comprehensive coverage\n    3. Identify any implementation issues\n    4. Provide specific recommendations\n    \"\"\",\n    agent=seo_agent\n)\n\n# Run the analysis\ncrew = Crew(agents=[seo_agent], tasks=[task])\nresult = crew.kickoff()\n```\n\n### LangChain Agents\n\n```python\nfrom langchain.agents import initialize_agent, AgentType\nfrom langchain.llms import OpenAI\nfrom langchain_hreflang import hreflang_tools\n\nllm = OpenAI(temperature=0)\nagent = initialize_agent(\n    hreflang_tools,\n    llm,\n    agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,\n    verbose=True\n)\n\nresult = agent.run(\"\"\"\nAnalyze the hreflang implementation for airbnb.com.\nCheck their main international pages and provide a summary\nincluding any issues found.\n\"\"\")\n```\n\n## \ud83d\udd0d What Gets Analyzed\n\n- **Hreflang tag implementation** across language versions\n- **Self-declared language detection** (`<html lang=\"en\">`)\n- **Bidirectional linking** between language versions  \n- **Return tag errors** and missing connections\n- **Site-wide statistics** for entire domains\n- **Broken URLs** and loading issues\n- **Language coverage analysis**\n\n## \ud83d\udcca Example Output\n\n```\nHreflang Test Results (Test ID: abc123...)\nTotal URLs tested: 3\n\nURL: https://example.com/en/\n  Self-declared language: en\n  Hreflang links found: 3\n    en: https://example.com/en/\n    es: https://example.com/es/\n    fr: https://example.com/fr/\n\nURL: https://example.com/es/\n  Self-declared language: es\n  Hreflang links found: 3\n    en: https://example.com/en/\n    es: https://example.com/es/\n    fr: https://example.com/fr/\n\nIssues Found:\n  \u26a0\ufe0f  Missing return link from FR to EN version\n  \u274c  https://example.com/de/ returns 404 error\n```\n\n## \ud83c\udfaf Rate Limits\n\n- **Free Tier**: 50 URLs per test, 10 tests per day\n- **Premium Tier**: 1,000 URLs per test, 500 tests per day\n\nCheck your limits with `check_hreflang_account_status()`.\n\n## \ud83e\udd1d Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\n## \ud83d\udcdd License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## \ud83d\ude4f Acknowledgments\n\n- [hreflang.org](https://hreflang.org) for providing the excellent hreflang testing API\n- [LangChain](https://langchain.com) for the powerful AI agent framework\n- [CrewAI](https://crewai.com) for the collaborative AI agent platform\n\n## \ud83d\udcde Support\n\n- **Issues**: [GitHub Issues](https://github.com/yourusername/langchain-hreflang/issues)\n- **Documentation**: [README](https://github.com/yourusername/langchain-hreflang#readme)\n- **API Documentation**: [hreflang.org API docs](https://app.hreflang.org/api-docs.php)\n\n---\n\n**Made with \u2764\ufe0f for the international SEO and AI community**\n",
    "bugtrack_url": null,
    "license": "MIT License\n        \n        Copyright (c) 2025 Your Name\n        \n        Permission is hereby granted, free of charge, to any person obtaining a copy\n        of this software and associated documentation files (the \"Software\"), to deal\n        in the Software without restriction, including without limitation the rights\n        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n        copies of the Software, and to permit persons to whom the Software is\n        furnished to do so, subject to the following conditions:\n        \n        The above copyright notice and this permission notice shall be included in all\n        copies or substantial portions of the Software.\n        \n        THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n        SOFTWARE.",
    "summary": "LangChain tools for hreflang SEO analysis using hreflang.org API",
    "version": "0.1.0",
    "project_urls": {
        "Bug Reports": "https://github.com/diffen/langchain-hreflang/issues",
        "Changelog": "https://github.com/diffen/langchain-hreflang/blob/main/CHANGELOG.md",
        "Documentation": "https://github.com/diffen/langchain-hreflang#readme",
        "Homepage": "https://github.com/diffen/langchain-hreflang",
        "Repository": "https://github.com/diffen/langchain-hreflang.git"
    },
    "split_keywords": [
        "langchain",
        " hreflang",
        " seo",
        " international",
        " ai",
        " agents",
        " crewai"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "16a706573374ca7d9726a01eae9f23acf22f26d11e9065674c7928dc4321f8da",
                "md5": "f9acb68f1940c8967067f311fc20b2ca",
                "sha256": "0880253c1e51424f8173d0817d507a5382e09ace7746b6608c5047c8d694983c"
            },
            "downloads": -1,
            "filename": "langchain_hreflang-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f9acb68f1940c8967067f311fc20b2ca",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.12",
            "size": 12896,
            "upload_time": "2025-08-25T04:29:41",
            "upload_time_iso_8601": "2025-08-25T04:29:41.256868Z",
            "url": "https://files.pythonhosted.org/packages/16/a7/06573374ca7d9726a01eae9f23acf22f26d11e9065674c7928dc4321f8da/langchain_hreflang-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "15d8d2fcf9309e5b10db5c49de9bcec9a8b9476e8c3b683dc586521d730e0682",
                "md5": "243afc1d654f409f69a84fd1685b6266",
                "sha256": "0290de66950361e85edf3a38aeeb05de674dbfac4a6cb66ae52840e593ebce1c"
            },
            "downloads": -1,
            "filename": "langchain_hreflang-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "243afc1d654f409f69a84fd1685b6266",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.12",
            "size": 21421,
            "upload_time": "2025-08-25T04:29:42",
            "upload_time_iso_8601": "2025-08-25T04:29:42.663753Z",
            "url": "https://files.pythonhosted.org/packages/15/d8/d2fcf9309e5b10db5c49de9bcec9a8b9476e8c3b683dc586521d730e0682/langchain_hreflang-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-25 04:29:42",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "diffen",
    "github_project": "langchain-hreflang",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "langchain-core",
            "specs": [
                [
                    ">=",
                    "0.1.0"
                ]
            ]
        },
        {
            "name": "requests",
            "specs": [
                [
                    ">=",
                    "2.25.0"
                ]
            ]
        },
        {
            "name": "pydantic",
            "specs": [
                [
                    ">=",
                    "1.8.0"
                ]
            ]
        }
    ],
    "lcname": "langchain-hreflang"
}
        
Elapsed time: 0.64139s