Metadata-Version: 2.5
Name: ai-traffic-insights
Version: 0.1.0
Summary: See how ChatGPT, Claude, Perplexity, Gemini and Google use your site, from your own access logs: verified AI crawlers (official IP lists and reverse DNS), fake bots, visits sent by AI assistants, blocked bots, AI 404s and sitemap coverage. nginx, Apache, Cloudflare, Vercel, CloudFront, IIS and JSON logs. No dependencies, nothing leaves your machine.
Project-URL: Homepage, https://www.ahmadzia.com/tools/ai-traffic-insights
Project-URL: Documentation, https://www.ahmadzia.com/tools/ai-traffic-insights
Project-URL: Source, https://github.com/MuhammadAhmadZia/ai-traffic-insights
Project-URL: Issues, https://github.com/MuhammadAhmadZia/ai-traffic-insights/issues
Project-URL: Changelog, https://github.com/MuhammadAhmadZia/ai-traffic-insights/blob/main/python/CHANGELOG.md
Project-URL: Author, https://www.ahmadzia.com
Project-URL: Research, https://www.ahmadzia.com/research
Author-email: Muhammad Ahmad Zia <muhammad.zia@cs.uol.edu.pk>
License-Expression: MIT
License-File: LICENSE
Keywords: access-log,ai-crawlers,ai-search,bot-detection,chatgpt,claudebot,cloudflare,ecommerce,geo,gptbot,log-analysis,nginx,perplexity,seo
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Internet :: Log Analysis
Classifier: Topic :: Internet :: WWW/HTTP :: Site Management
Requires-Python: >=3.9
Provides-Extra: test
Requires-Dist: pytest>=7; extra == 'test'
Description-Content-Type: text/markdown

# ai-traffic-insights (Python)

See how AI actually uses your site, from your own server logs. Python version of the [npm package](https://www.npmjs.com/package/ai-traffic-insights): same bot list, same checks, same report.

Analytics tools cannot see AI crawlers (they never run your analytics script), fake bots that borrow a trusted name, your own firewall blocking ChatGPT's search crawler, AI answers that link to pages that do not exist, or which products people ask AI assistants about. This tool reads your access logs and shows all of that. It runs on your machine, your logs are never uploaded, and the report contains no visitor IP addresses.

```bash
pip install ai-traffic-insights
ai-traffic-insights /var/log/nginx/access.log --site your-store.com
```

Several files, rotated and gzipped ones too, and your sitemap for coverage:

```bash
ai-traffic-insights access.log access.log.1 access.log.2.gz --site your-store.com --sitemap https://your-store.com/sitemap.xml
```

Reads nginx and Apache (combined and vhost_combined), Cloudflare Logpush, Vercel log drains, AWS CloudFront and IIS (W3C), and JSON access logs. No dependencies.

## Use it from Python

```python
from ai_traffic_insights import analyze_logs, format_text

result = analyze_logs(["access.log"], site="your-store.com", sitemap="https://your-store.com/sitemap.xml")
print(format_text(result))
for f in result["findings"]:
    print(f["severity"], f["title"])
```

The result is a plain dictionary with the same keys as the npm package's JSON output (`bots`, `referrals`, `crawlRefer`, `askedAbout`, `coverage`, `findings`, `notes`), so you can load it into pandas or a dashboard.

## How bots are verified

A user agent can be faked. Each bot's requests are checked against the operator's official IP lists (OpenAI, Anthropic, Perplexity, Google, Microsoft, Apple, DuckDuckGo, Common Crawl), downloaded and cached for a day. `--dns` adds forward-confirmed reverse DNS for Googlebot, Bingbot, Applebot and CCBot. For a server without internet, run `ai-traffic-insights --download-ranges ./ranges` elsewhere and pass `--ranges-dir ./ranges`.

All options (`--since`, `--until`, `--format`, `--top`, `--offline`, `--no-verify`, `--show-ips`, `--md`, `--json`, `--fail-on`) and what every finding means are documented in the [npm package README](https://www.npmjs.com/package/ai-traffic-insights).

## Same results as the JavaScript version

The bot list, AI referrer list and patterns are exported from the JavaScript source, and the test suite runs both versions on the same eight log fixtures (nginx, vhost, gzip, Cloudflare, Vercel, CloudFront, IIS, JSON) and checks that the full JSON result, the text report and the Markdown report are identical.

## Sustainable Development Goals

This tool supports **SDG target 8.3** (growth of micro, small and medium enterprises): AI assistants are becoming a route to market, and this gives a small store, from logs it already has, the view that large retailers buy from bot-management platforms. It also supports **target 9.1** (reliable infrastructure): telling real crawlers from impostors lets a store block scrapers without cutting itself off from AI search, and cuts bandwidth and server energy wasted on fake traffic.

## About

Built by [Ahmad Zia](https://www.ahmadzia.com), an AI and e-commerce consultant. MIT licensed.

<!-- ahmadzia-links -->
## Guide, help and author

- **Full guide with examples and FAQs:** [www.ahmadzia.com/tools/ai-traffic-insights](https://www.ahmadzia.com/tools/ai-traffic-insights)
- **Background reading:** [AI visibility for online stores: what gets you cited](https://www.ahmadzia.com/blog/ai-visibility-llms-txt-ai-crawlers)
- **All 30 free tools and agent skills:** [ahmadzia.com/tools](https://www.ahmadzia.com/tools) · [ahmadzia.com/skills](https://www.ahmadzia.com/skills)
- **Want it set up, fixed or tuned for your store?** [Book a free call](https://www.ahmadzia.com/contact)

Built by **[Ahmad Zia](https://www.ahmadzia.com)** (Muhammad Ahmad Zia), an AI consultant for ecommerce since 2020 and green AI researcher at the University of Lahore. [Research](https://www.ahmadzia.com/research) · [Google Scholar](https://scholar.google.com/citations?user=sqjdX2EAAAAJ&hl=en) · [ORCID](https://orcid.org/0000-0002-3208-6246) · [LinkedIn](https://www.linkedin.com/in/muhammad-ahmadzia/) · [GitHub](https://github.com/MuhammadAhmadZia)
<!-- /ahmadzia-links -->
