Skip to main content

Library to identify trending AI products on Product Hunt (API + scraping fallback).

Project description

ph_ai_tracker

A small Python library that finds trending AI products on Product Hunt.

  • Primary: Product Hunt GraphQL API v2
  • Secondary: Web scraping fallback (BeautifulSoup) for when the API is unavailable / rate-limited

Install (dev)

poetry install

Install (PyPI)

pip install ph-ai-tracker

Optional (faster HTML parsing with lxml):

pip install "ph-ai-tracker[lxml]"

Quickstart

from ph_ai_tracker import AIProductTracker

tracker = AIProductTracker(
    api_token="YOUR_PRODUCTHUNT_TOKEN",  # optional
    strategy="auto",                    # api | scraper | auto
)

result = tracker.get_products(search_term="AI", limit=20)
print(result.to_pretty_json())

Or from the terminal (prints pretty JSON):

poetry run python -m ph_ai_tracker --strategy scraper --search AI --limit 10

By default, each run is also persisted to SQLite at ./data/ph_ai_tracker.db.

poetry run python -m ph_ai_tracker --strategy scraper --db-path ./data/ph_ai_tracker.db

Use --no-persist to skip DB writes for one-off runs.

Scheduler (Sprint 2)

Run one scheduled cycle (scrape + persist) via the scheduler command:

poetry run ph-ai-tracker-runner --strategy scraper --search AI --limit 20 --db-path ./data/ph_ai_tracker.db

Environment variables supported by scheduler runtime:

  • CRON_SCHEDULE (default: 0 */6 * * *)
  • TZ (default: UTC)
  • PH_AI_TRACKER_STRATEGY (default: scraper)
  • PH_AI_TRACKER_SEARCH (default: AI)
  • PH_AI_TRACKER_LIMIT (default: 20)
  • PH_AI_DB_PATH (default: ./data/ph_ai_tracker.db)
  • PRODUCTHUNT_TOKEN (required for API strategy)
  • PH_AI_RETRY_ATTEMPTS (default: 2)
  • PH_AI_RETRY_BACKOFF_SECONDS (default: 2)

Cron helper files are available in scripts/cron/.

Docker + Persistent Volume (Sprint 3)

Build and start the scheduler container:

docker compose up -d --build

Watch scheduler logs:

docker compose logs -f scheduler

The SQLite database is stored on the named Docker volume ph_ai_tracker_data at /data/ph_ai_tracker.db in the container.

Stop without deleting data:

docker compose down

If you remove containers and start again, data persists because the named volume is reused.

After installing from PyPI, you can also run:

ph-ai-tracker --strategy scraper --search AI --limit 10

Trending behavior

  • --strategy api defaults to Product Hunt's RANKING order.
  • The API client first attempts the artificial-intelligence topic; if the schema/topic query fails, it falls back to global posts and applies a client-side filter.

Product Hunt API token

Do not hardcode tokens in code or commit them to git.

Set your token as an environment variable:

export PRODUCTHUNT_TOKEN="<your_token>"
poetry run python -m ph_ai_tracker --strategy api --search AI --limit 10

Notes

  • This project is intended to run well on PyPy 3.
  • All tests are offline and use mocks/fixtures (no real network).
  • Supported Python versions: 3.10–3.14
  • Operational guide: see RUNBOOK.md
  • Convenience commands: make test, make runner, make docker-up, make docker-logs
  • Demo script: scripts/demo_pipeline.sh
  • Requirements mapping: REQUIREMENTS_TRACEABILITY.md
  • Final handoff checklist: SUBMISSION_CHECKLIST.md

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ph_ai_tracker-0.1.3.tar.gz (14.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ph_ai_tracker-0.1.3-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file ph_ai_tracker-0.1.3.tar.gz.

File metadata

  • Download URL: ph_ai_tracker-0.1.3.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ph_ai_tracker-0.1.3.tar.gz
Algorithm Hash digest
SHA256 29ca8208846e2f7113b5d8126296770511590f272df6e03b17fb73c34771e460
MD5 85fb341ed0cb7a6110a46b06950ef027
BLAKE2b-256 9c3d7c448ea41ab8964c4ba139133b9a61db4611d657be2a50abc4fe49ed1c25

See more details on using hashes here.

File details

Details for the file ph_ai_tracker-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: ph_ai_tracker-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 17.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ph_ai_tracker-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4a2cb67ed8bb0c5494f8f643bea3ce3ce1b6ef6b6e1b6bc1e127f8f277c0824b
MD5 cd680519dec0eb27ce3ad9bce879f7e3
BLAKE2b-256 1eacf9d224218523c4d048ce10568dd6395caae36abd11e305486f73a4314139

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page