moonito


Namemoonito JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://github.com/moonito-net/moonito-python
SummaryVisitor Traffic Filtering for Python web applications
upload_time2025-10-25 07:24:43
maintainerNone
docs_urlNone
authorMoonito
requires_python>=3.7
licenseNone
keywords traffic filtering visitor filtering bot detection security web protection
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # moonito-python

Official Python SDK for [Moonito](https://moonito.net) โ€” a smart analytics and visitor filtering platform designed to protect your website from unwanted traffic, bots, and malicious activity while providing deep visitor insights.

**moonito-python** is a lightweight Python SDK for integrating your web application with the Moonito Visitor Analytics API.

It allows you to:

- Analyze and monitor web traffic intelligently
- Filter out bots, crawlers, and unwanted visitors
- Get real-time visitor behavior insights
- Protect APIs, landing pages, and web apps automatically

Compatible with Flask, Django, FastAPI, and other Python web frameworks.

## ๐Ÿ“ฆ Installation

```bash
pip install moonito
```

## ๐Ÿš€ Quick Start

### Flask Example

```python
from flask import Flask, request, Response
from moonito import VisitorTrafficFiltering, Config

app = Flask(__name__)

# Initialize Moonito
client = VisitorTrafficFiltering(Config(
    is_protected=True,
    api_public_key="YOUR_PUBLIC_KEY",
    api_secret_key="YOUR_SECRET_KEY",
    unwanted_visitor_to="https://example.com/blocked",  # URL or HTTP status code
    unwanted_visitor_action=1  # 1 = Redirect, 2 = Iframe, 3 = Load content
))

@app.before_request
def check_visitor():
    """Middleware to check visitors before processing requests"""
    result = client.evaluate_visitor(request)
    
    if result and result['need_to_block']:
        content = result['content']
        
        if isinstance(content, int):
            return Response(status=content)
        
        return Response(content, mimetype='text/html')

@app.route('/')
def home():
    return 'Hello, World!'

if __name__ == '__main__':
    app.run(port=8080)
```

### Django Example

```python
# middleware.py
from moonito import VisitorTrafficFiltering, Config
from django.http import HttpResponse

class MoonitoMiddleware:
    def __init__(self, get_response):
        self.get_response = get_response
        
        # Initialize Moonito
        self.client = VisitorTrafficFiltering(Config(
            is_protected=True,
            api_public_key="YOUR_PUBLIC_KEY",
            api_secret_key="YOUR_SECRET_KEY",
            unwanted_visitor_to="https://example.com/blocked",
            unwanted_visitor_action=1
        ))

    def __call__(self, request):
        # Check visitor
        result = self.client.evaluate_visitor(request)
        
        if result and result['need_to_block']:
            content = result['content']
            
            if isinstance(content, int):
                return HttpResponse(status=content)
            
            return HttpResponse(content)
        
        response = self.get_response(request)
        return response
```

Add to `settings.py`:
```python
MIDDLEWARE = [
    'your_app.middleware.MoonitoMiddleware',
    # ... other middleware
]
```

### FastAPI Example

```python
from fastapi import FastAPI, Request, Response
from moonito import VisitorTrafficFiltering, Config

app = FastAPI()

# Initialize Moonito
client = VisitorTrafficFiltering(Config(
    is_protected=True,
    api_public_key="YOUR_PUBLIC_KEY",
    api_secret_key="YOUR_SECRET_KEY",
    unwanted_visitor_to="https://example.com/blocked",
    unwanted_visitor_action=1
))

@app.middleware("http")
async def moonito_middleware(request: Request, call_next):
    """Middleware to check visitors"""
    result = client.evaluate_visitor(request)
    
    if result and result['need_to_block']:
        content = result['content']
        
        if isinstance(content, int):
            return Response(status_code=content)
        
        return Response(content=content, media_type="text/html")
    
    response = await call_next(request)
    return response

@app.get("/")
def read_root():
    return {"message": "Hello World"}
```

## โš™๏ธ Configuration

| Field | Type | Description |
|-------|------|-------------|
| `is_protected` | `bool` | Enable (`True`) or disable (`False`) protection |
| `api_public_key` | `str` | Your Moonito API public key (required) |
| `api_secret_key` | `str` | Your Moonito API secret key (required) |
| `unwanted_visitor_to` | `str` | URL to redirect unwanted visitors or HTTP error code |
| `unwanted_visitor_action` | `int` | Action for unwanted visitors: 1 = Redirect, 2 = Iframe, 3 = Load content |

## ๐Ÿ”ง Manual Evaluation

For custom implementations or manual checking:

```python
from moonito import VisitorTrafficFiltering, Config

client = VisitorTrafficFiltering(Config(
    is_protected=True,
    api_public_key="YOUR_PUBLIC_KEY",
    api_secret_key="YOUR_SECRET_KEY"
))

# Manually evaluate a visitor
result = client.evaluate_visitor_manually(
    ip="8.8.8.8",
    user_agent="Mozilla/5.0",
    event="/home",
    domain="example.com"
)

if result['need_to_block']:
    print("Blocked visitor detected.")
```

## ๐Ÿ’ก Use Cases

- Prevent fake signups and bot traffic
- Protect landing pages from ad click fraud
- Collect accurate visitor analytics
- Detect suspicious activity in real time

## ๐Ÿ“‹ Requirements

- Python 3.7 or higher
- No external dependencies (uses Python standard library)
- Moonito API keys from [https://moonito.net](https://moonito.net)

## ๐Ÿงช Development

```bash
# Clone the repository
git clone https://github.com/moonito-net/moonito-python.git
cd moonito-python

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -e .
pip install pytest

# Run tests
pytest tests/
```

## ๐Ÿ“„ License

MIT License ยฉ 2025 [Moonito](https://moonito.net)

## ๐Ÿท๏ธ Keywords

python analytics sdk, moonito sdk, visitor filtering python, python bot protection, python traffic analytics, moonito python sdk, moonito api, website protection sdk python, moonito visitor analytics, python security sdk

## ๐ŸŒ Learn More

Visit [https://moonito.net](https://moonito.net) to learn more about:

- Visitor analytics
- Website traffic protection
- API-based bot and fraud filtering

**Moonito โ€” Stop Bad Bots. Start Accurate Web Analytics.**

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/moonito-net/moonito-python",
    "name": "moonito",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "traffic filtering, visitor filtering, bot detection, security, web protection",
    "author": "Moonito",
    "author_email": "Moonito <support@moonito.net>",
    "download_url": "https://files.pythonhosted.org/packages/86/86/726fff427efc9301e85bcd2a4c22ded0296d6b5ba8d0d4a2f4a6f4984332/moonito-1.0.0.tar.gz",
    "platform": null,
    "description": "# moonito-python\n\nOfficial Python SDK for [Moonito](https://moonito.net) \u2014 a smart analytics and visitor filtering platform designed to protect your website from unwanted traffic, bots, and malicious activity while providing deep visitor insights.\n\n**moonito-python** is a lightweight Python SDK for integrating your web application with the Moonito Visitor Analytics API.\n\nIt allows you to:\n\n- Analyze and monitor web traffic intelligently\n- Filter out bots, crawlers, and unwanted visitors\n- Get real-time visitor behavior insights\n- Protect APIs, landing pages, and web apps automatically\n\nCompatible with Flask, Django, FastAPI, and other Python web frameworks.\n\n## \ud83d\udce6 Installation\n\n```bash\npip install moonito\n```\n\n## \ud83d\ude80 Quick Start\n\n### Flask Example\n\n```python\nfrom flask import Flask, request, Response\nfrom moonito import VisitorTrafficFiltering, Config\n\napp = Flask(__name__)\n\n# Initialize Moonito\nclient = VisitorTrafficFiltering(Config(\n    is_protected=True,\n    api_public_key=\"YOUR_PUBLIC_KEY\",\n    api_secret_key=\"YOUR_SECRET_KEY\",\n    unwanted_visitor_to=\"https://example.com/blocked\",  # URL or HTTP status code\n    unwanted_visitor_action=1  # 1 = Redirect, 2 = Iframe, 3 = Load content\n))\n\n@app.before_request\ndef check_visitor():\n    \"\"\"Middleware to check visitors before processing requests\"\"\"\n    result = client.evaluate_visitor(request)\n    \n    if result and result['need_to_block']:\n        content = result['content']\n        \n        if isinstance(content, int):\n            return Response(status=content)\n        \n        return Response(content, mimetype='text/html')\n\n@app.route('/')\ndef home():\n    return 'Hello, World!'\n\nif __name__ == '__main__':\n    app.run(port=8080)\n```\n\n### Django Example\n\n```python\n# middleware.py\nfrom moonito import VisitorTrafficFiltering, Config\nfrom django.http import HttpResponse\n\nclass MoonitoMiddleware:\n    def __init__(self, get_response):\n        self.get_response = get_response\n        \n        # Initialize Moonito\n        self.client = VisitorTrafficFiltering(Config(\n            is_protected=True,\n            api_public_key=\"YOUR_PUBLIC_KEY\",\n            api_secret_key=\"YOUR_SECRET_KEY\",\n            unwanted_visitor_to=\"https://example.com/blocked\",\n            unwanted_visitor_action=1\n        ))\n\n    def __call__(self, request):\n        # Check visitor\n        result = self.client.evaluate_visitor(request)\n        \n        if result and result['need_to_block']:\n            content = result['content']\n            \n            if isinstance(content, int):\n                return HttpResponse(status=content)\n            \n            return HttpResponse(content)\n        \n        response = self.get_response(request)\n        return response\n```\n\nAdd to `settings.py`:\n```python\nMIDDLEWARE = [\n    'your_app.middleware.MoonitoMiddleware',\n    # ... other middleware\n]\n```\n\n### FastAPI Example\n\n```python\nfrom fastapi import FastAPI, Request, Response\nfrom moonito import VisitorTrafficFiltering, Config\n\napp = FastAPI()\n\n# Initialize Moonito\nclient = VisitorTrafficFiltering(Config(\n    is_protected=True,\n    api_public_key=\"YOUR_PUBLIC_KEY\",\n    api_secret_key=\"YOUR_SECRET_KEY\",\n    unwanted_visitor_to=\"https://example.com/blocked\",\n    unwanted_visitor_action=1\n))\n\n@app.middleware(\"http\")\nasync def moonito_middleware(request: Request, call_next):\n    \"\"\"Middleware to check visitors\"\"\"\n    result = client.evaluate_visitor(request)\n    \n    if result and result['need_to_block']:\n        content = result['content']\n        \n        if isinstance(content, int):\n            return Response(status_code=content)\n        \n        return Response(content=content, media_type=\"text/html\")\n    \n    response = await call_next(request)\n    return response\n\n@app.get(\"/\")\ndef read_root():\n    return {\"message\": \"Hello World\"}\n```\n\n## \u2699\ufe0f Configuration\n\n| Field | Type | Description |\n|-------|------|-------------|\n| `is_protected` | `bool` | Enable (`True`) or disable (`False`) protection |\n| `api_public_key` | `str` | Your Moonito API public key (required) |\n| `api_secret_key` | `str` | Your Moonito API secret key (required) |\n| `unwanted_visitor_to` | `str` | URL to redirect unwanted visitors or HTTP error code |\n| `unwanted_visitor_action` | `int` | Action for unwanted visitors: 1 = Redirect, 2 = Iframe, 3 = Load content |\n\n## \ud83d\udd27 Manual Evaluation\n\nFor custom implementations or manual checking:\n\n```python\nfrom moonito import VisitorTrafficFiltering, Config\n\nclient = VisitorTrafficFiltering(Config(\n    is_protected=True,\n    api_public_key=\"YOUR_PUBLIC_KEY\",\n    api_secret_key=\"YOUR_SECRET_KEY\"\n))\n\n# Manually evaluate a visitor\nresult = client.evaluate_visitor_manually(\n    ip=\"8.8.8.8\",\n    user_agent=\"Mozilla/5.0\",\n    event=\"/home\",\n    domain=\"example.com\"\n)\n\nif result['need_to_block']:\n    print(\"Blocked visitor detected.\")\n```\n\n## \ud83d\udca1 Use Cases\n\n- Prevent fake signups and bot traffic\n- Protect landing pages from ad click fraud\n- Collect accurate visitor analytics\n- Detect suspicious activity in real time\n\n## \ud83d\udccb Requirements\n\n- Python 3.7 or higher\n- No external dependencies (uses Python standard library)\n- Moonito API keys from [https://moonito.net](https://moonito.net)\n\n## \ud83e\uddea Development\n\n```bash\n# Clone the repository\ngit clone https://github.com/moonito-net/moonito-python.git\ncd moonito-python\n\n# Create virtual environment\npython -m venv venv\nsource venv/bin/activate  # On Windows: venv\\Scripts\\activate\n\n# Install dependencies\npip install -e .\npip install pytest\n\n# Run tests\npytest tests/\n```\n\n## \ud83d\udcc4 License\n\nMIT License \u00a9 2025 [Moonito](https://moonito.net)\n\n## \ud83c\udff7\ufe0f Keywords\n\npython analytics sdk, moonito sdk, visitor filtering python, python bot protection, python traffic analytics, moonito python sdk, moonito api, website protection sdk python, moonito visitor analytics, python security sdk\n\n## \ud83c\udf10 Learn More\n\nVisit [https://moonito.net](https://moonito.net) to learn more about:\n\n- Visitor analytics\n- Website traffic protection\n- API-based bot and fraud filtering\n\n**Moonito \u2014 Stop Bad Bots. Start Accurate Web Analytics.**\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Visitor Traffic Filtering for Python web applications",
    "version": "1.0.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/moonito-net/moonito-python/issues",
        "Documentation": "https://moonito.net/docs",
        "Homepage": "https://moonito.net",
        "Repository": "https://github.com/moonito-net/moonito-python"
    },
    "split_keywords": [
        "traffic filtering",
        " visitor filtering",
        " bot detection",
        " security",
        " web protection"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "a8548501e059b12ab0930da1788ae5281f76930940556426a2eadcb70ed8f76c",
                "md5": "9ff18b3a39b9feebd5c19d537a440f18",
                "sha256": "2cfca6558bdcc419508cbe56478ab64107829b83e655729c5d6be03c79241f92"
            },
            "downloads": -1,
            "filename": "moonito-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9ff18b3a39b9feebd5c19d537a440f18",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 7952,
            "upload_time": "2025-10-25T07:24:41",
            "upload_time_iso_8601": "2025-10-25T07:24:41.459686Z",
            "url": "https://files.pythonhosted.org/packages/a8/54/8501e059b12ab0930da1788ae5281f76930940556426a2eadcb70ed8f76c/moonito-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "8686726fff427efc9301e85bcd2a4c22ded0296d6b5ba8d0d4a2f4a6f4984332",
                "md5": "c5fc16013d853090509bbb7c7d7722a1",
                "sha256": "218fb066f5eb2203fa33194a28bcacba610c7f95d8d0ad3ab07102e88955b551"
            },
            "downloads": -1,
            "filename": "moonito-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "c5fc16013d853090509bbb7c7d7722a1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 11250,
            "upload_time": "2025-10-25T07:24:43",
            "upload_time_iso_8601": "2025-10-25T07:24:43.279898Z",
            "url": "https://files.pythonhosted.org/packages/86/86/726fff427efc9301e85bcd2a4c22ded0296d6b5ba8d0d4a2f4a6f4984332/moonito-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-25 07:24:43",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "moonito-net",
    "github_project": "moonito-python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "moonito"
}
        
Elapsed time: 0.84379s