producthunt-api


Nameproducthunt-api JSON
Version 0.2.0 PyPI version JSON
download
home_pagehttps://github.com/markolofsen/producthunt-api
SummaryEasily scrape and export detailed product data from Product Hunt categories into JSON files using a Python library. Automate data collection for analysis and reporting.
upload_time2025-01-22 05:10:19
maintainerNone
docs_urlNone
authorUnrealos
requires_python>=3.8
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ProductHunt API

**ProductHunt API** is a Python-based library developed by **Unrealos** ([unrealos.com](https://unrealos.com)) to automate the process of fetching, processing, and saving Product Hunt data into structured JSON format. It’s designed for developers and businesses to streamline data collection from Product Hunt categories.

---

## Key Features
- **Automated Data Retrieval**: Fetch products from any Product Hunt category using GraphQL.
- **Data Parsing**: Process product details and save them as structured JSON files.
- **Developer-Friendly**: Easy-to-use pipeline designed for automation.
- **JSON Output**: Save extracted product data in a standardized JSON file for analysis and reporting.

---

## Installation

### Install from PyPI
You can install the library directly from PyPI:
```bash
pip install producthunt-api
```

### Verify Installation
To confirm the installation was successful, run:
```bash
python -m producthunt_api --help
```

---

## Setting Up

Before running the pipeline, you need to extract some data from Product Hunt.

### 1. Parsing Category Data
To fetch data from a specific category, follow these steps:

1. Open the Product Hunt category page you want to scrape (e.g., [AI Software](https://www.producthunt.com/categories/ai-software)).
2. Open your browser's developer tools (usually accessible via `F12` or right-click > `Inspect`).
3. Go to the **Network** tab.
4. Locate the request to `https://www.producthunt.com/frontend/graphql`. This request contains:
   - **OperationName**: `"CategoryPageQuery"`
5. Extract the following from the request:
   - **Cookie**: Copy the `Cookie` string from the request headers.
   - **SHA256 Hash**: Copy the `sha256Hash` value from the request payload.

---

## Usage

### Pipeline Workflow
The pipeline automates the following steps:
1. **Data Fetching**: Fetch products from a specified Product Hunt category.
2. **Product Processing**: Parse and save product details as individual JSON files.
3. **Data Consolidation**: Combine all individual JSON files into a single structured JSON file.

### Running the Pipeline
Create a Python script and use the following example to run the pipeline:

```python
import os
from producthunt_api import ProductHuntPipeline

# Define necessary variables
directory = os.path.join(os.getcwd(), "downloads")
cookie_value = "<YOUR_COOKIE>"
sha256_hash_value = "<YOUR_SHA256_HASH>"
slug_value = "ai-software"  # Replace with your desired category slug

# Initialize and run the pipeline
pipeline = ProductHuntPipeline(
    directory=directory,
    cookie=cookie_value,
    sha256_hash=sha256_hash_value,
    slug=slug_value
)
pipeline.run(limit=50, max_threads=10)
```

1. Replace `<YOUR_COOKIE>` and `<YOUR_SHA256_HASH>` with the values you extracted earlier.
2. Save the script and run it:
   ```bash
   python your_script_name.py
   ```

### Output
- **Individual JSON Files**: Each product is saved as a separate JSON file in the `downloads/products` directory.
- **Consolidated JSON File**: All product data is combined into a single `products.json` file in the `downloads` directory.

---

## Testing the Library

To ensure everything is working as expected, you can run the test suite.

1. Install testing dependencies:
   ```bash
   pip install pytest pytest-cov
   ```

2. Run the tests:
   ```bash
   pytest -v
   ```

---

## Contributing

We welcome contributions to enhance this library. If you’d like to contribute:
1. Fork the repository on GitHub.
2. Create a feature branch.
3. Submit a pull request with your changes.

---

## About Unrealos

**Unrealos** ([unrealos.com](https://unrealos.com)) is a software development company specializing in AI, SaaS, and PaaS solutions for businesses. With expertise in integrating artificial intelligence into scalable business processes, Unrealos delivers cutting-edge software tailored to your needs.

---

## Additional Resources

- **Source Code**: [GitHub Repository](https://github.com/markolofsen/producthunt-api)
- **Issue Tracker**: [Submit Issues Here](https://github.com/markolofsen/producthunt-api/issues)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/markolofsen/producthunt-api",
    "name": "producthunt-api",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "Unrealos",
    "author_email": "m@unrealos.com",
    "download_url": "https://files.pythonhosted.org/packages/c4/88/fa441f1426b8fc4e7fdf33a8a63b8e0f6829fe66f041ffca4d7a175f30d2/producthunt_api-0.2.0.tar.gz",
    "platform": null,
    "description": "# ProductHunt API\n\n**ProductHunt API** is a Python-based library developed by **Unrealos** ([unrealos.com](https://unrealos.com)) to automate the process of fetching, processing, and saving Product Hunt data into structured JSON format. It\u2019s designed for developers and businesses to streamline data collection from Product Hunt categories.\n\n---\n\n## Key Features\n- **Automated Data Retrieval**: Fetch products from any Product Hunt category using GraphQL.\n- **Data Parsing**: Process product details and save them as structured JSON files.\n- **Developer-Friendly**: Easy-to-use pipeline designed for automation.\n- **JSON Output**: Save extracted product data in a standardized JSON file for analysis and reporting.\n\n---\n\n## Installation\n\n### Install from PyPI\nYou can install the library directly from PyPI:\n```bash\npip install producthunt-api\n```\n\n### Verify Installation\nTo confirm the installation was successful, run:\n```bash\npython -m producthunt_api --help\n```\n\n---\n\n## Setting Up\n\nBefore running the pipeline, you need to extract some data from Product Hunt.\n\n### 1. Parsing Category Data\nTo fetch data from a specific category, follow these steps:\n\n1. Open the Product Hunt category page you want to scrape (e.g., [AI Software](https://www.producthunt.com/categories/ai-software)).\n2. Open your browser's developer tools (usually accessible via `F12` or right-click > `Inspect`).\n3. Go to the **Network** tab.\n4. Locate the request to `https://www.producthunt.com/frontend/graphql`. This request contains:\n   - **OperationName**: `\"CategoryPageQuery\"`\n5. Extract the following from the request:\n   - **Cookie**: Copy the `Cookie` string from the request headers.\n   - **SHA256 Hash**: Copy the `sha256Hash` value from the request payload.\n\n---\n\n## Usage\n\n### Pipeline Workflow\nThe pipeline automates the following steps:\n1. **Data Fetching**: Fetch products from a specified Product Hunt category.\n2. **Product Processing**: Parse and save product details as individual JSON files.\n3. **Data Consolidation**: Combine all individual JSON files into a single structured JSON file.\n\n### Running the Pipeline\nCreate a Python script and use the following example to run the pipeline:\n\n```python\nimport os\nfrom producthunt_api import ProductHuntPipeline\n\n# Define necessary variables\ndirectory = os.path.join(os.getcwd(), \"downloads\")\ncookie_value = \"<YOUR_COOKIE>\"\nsha256_hash_value = \"<YOUR_SHA256_HASH>\"\nslug_value = \"ai-software\"  # Replace with your desired category slug\n\n# Initialize and run the pipeline\npipeline = ProductHuntPipeline(\n    directory=directory,\n    cookie=cookie_value,\n    sha256_hash=sha256_hash_value,\n    slug=slug_value\n)\npipeline.run(limit=50, max_threads=10)\n```\n\n1. Replace `<YOUR_COOKIE>` and `<YOUR_SHA256_HASH>` with the values you extracted earlier.\n2. Save the script and run it:\n   ```bash\n   python your_script_name.py\n   ```\n\n### Output\n- **Individual JSON Files**: Each product is saved as a separate JSON file in the `downloads/products` directory.\n- **Consolidated JSON File**: All product data is combined into a single `products.json` file in the `downloads` directory.\n\n---\n\n## Testing the Library\n\nTo ensure everything is working as expected, you can run the test suite.\n\n1. Install testing dependencies:\n   ```bash\n   pip install pytest pytest-cov\n   ```\n\n2. Run the tests:\n   ```bash\n   pytest -v\n   ```\n\n---\n\n## Contributing\n\nWe welcome contributions to enhance this library. If you\u2019d like to contribute:\n1. Fork the repository on GitHub.\n2. Create a feature branch.\n3. Submit a pull request with your changes.\n\n---\n\n## About Unrealos\n\n**Unrealos** ([unrealos.com](https://unrealos.com)) is a software development company specializing in AI, SaaS, and PaaS solutions for businesses. With expertise in integrating artificial intelligence into scalable business processes, Unrealos delivers cutting-edge software tailored to your needs.\n\n---\n\n## Additional Resources\n\n- **Source Code**: [GitHub Repository](https://github.com/markolofsen/producthunt-api)\n- **Issue Tracker**: [Submit Issues Here](https://github.com/markolofsen/producthunt-api/issues)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Easily scrape and export detailed product data from Product Hunt categories into JSON files using a Python library. Automate data collection for analysis and reporting.",
    "version": "0.2.0",
    "project_urls": {
        "Homepage": "https://github.com/markolofsen/producthunt-api",
        "Source": "https://github.com/markolofsen/producthunt-api",
        "Tracker": "https://github.com/markolofsen/producthunt-api/issues"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4d789c2f01351217dc41f22e8473ea5c28dd887e5356d66d2f8ff40e6363376e",
                "md5": "819448b3ab65df040f2c7aefd6c45ca9",
                "sha256": "3528deb1f70bda7ee364fdb5ce9736806cd219a6d0c0acbae4295e6b7f8dae70"
            },
            "downloads": -1,
            "filename": "producthunt_api-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "819448b3ab65df040f2c7aefd6c45ca9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 4071,
            "upload_time": "2025-01-22T05:10:18",
            "upload_time_iso_8601": "2025-01-22T05:10:18.171872Z",
            "url": "https://files.pythonhosted.org/packages/4d/78/9c2f01351217dc41f22e8473ea5c28dd887e5356d66d2f8ff40e6363376e/producthunt_api-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c488fa441f1426b8fc4e7fdf33a8a63b8e0f6829fe66f041ffca4d7a175f30d2",
                "md5": "347352218dba9d0c5f045c0bc9ae5464",
                "sha256": "6498f990c156196c36b82f91b2182e7ec1a11ed011284f506059a0e647409a1c"
            },
            "downloads": -1,
            "filename": "producthunt_api-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "347352218dba9d0c5f045c0bc9ae5464",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 5221,
            "upload_time": "2025-01-22T05:10:19",
            "upload_time_iso_8601": "2025-01-22T05:10:19.337405Z",
            "url": "https://files.pythonhosted.org/packages/c4/88/fa441f1426b8fc4e7fdf33a8a63b8e0f6829fe66f041ffca4d7a175f30d2/producthunt_api-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-22 05:10:19",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "markolofsen",
    "github_project": "producthunt-api",
    "github_not_found": true,
    "lcname": "producthunt-api"
}
        
Elapsed time: 0.49831s