# Product Hunt Integration via LowCodeAPI

## Overview

Product Hunt is a platform for discovering and sharing new products. The Product Hunt API provides GraphQL-based functionality for:

- **Posts** - Query featured and trending product posts
- **Collections** - Browse curated product collections
- **Topics** - Explore product categories and topics
- **Users** - Get user profiles and activity
- **Comments** - Retrieve and manage comments
- **Votes** - Track product votes
- **Makers** - Get maker information
- **Mutations** - Perform write operations

## Base Endpoint

```
https://api.lowcodeapi.com/producthunt/
```

## Authentication

LowCodeAPI handles authentication automatically using OAuth2.0. You only need to:

1. **Create an app** at [Product Hunt](https://www.producthunt.com/developers) to get your Client ID and Secret
2. **Connect your account** in the LowCodeAPI dashboard
3. **Use your `api_token`** in all requests

The `api_token` is your LowCodeAPI authentication token. LowCodeAPI will automatically:
- Fetch your Product Hunt access token
- Apply it to each request as a Bearer token

**Auth Type**: OAuth2.0 (Bearer Token)
**Scopes**: public, private, write

## API Categories

- **Social Media** - Product discovery and community platform

## Common Endpoints

### Category: Posts

#### Query Posts

**Method**: `POST` | **LowCodeAPI Path**: `/v2/api/graphql/posts`

**Full URL**:
```
https://api.lowcodeapi.com/producthunt/v2/api/graphql/posts?api_token={api_token}
```

**Description**: Query posts from Product Hunt using GraphQL.

**Request Body**:
```json
{
  "query": "query { posts(order: POPULAR, first: 20) { edges { node { id, name, tagline, url, votesCount } } } }",
  "variables": {}
}
```

**Request Body Fields**:

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `query` | string | Yes | GraphQL query string |
| `variables` | object | No | GraphQL variables for the query |

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/producthunt/v2/api/graphql/posts?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "query { posts(order: POPULAR, first: 20) { edges { node { id, name, tagline, url, votesCount, createdAt } } } }"
  }'
```

**Official Documentation**: [Query Posts](https://api.producthunt.com/v2/docs)

---

#### Query Single Post

**Method**: `POST` | **LowCodeAPI Path**: `/v2/api/graphql/post`

**Full URL**:
```
https://api.lowcodeapi.com/producthunt/v2/api/graphql/post?api_token={api_token}
```

**Description**: Query a single post by ID or slug.

**Request Body**:
```json
{
  "query": "query { post(slug: \"product-name\") { id, name, tagline, description, url } }",
  "variables": {}
}
```

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/producthunt/v2/api/graphql/post?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "query { post(slug: \"product-name\") { id, name, tagline, description, url, votesCount } }"
  }'
```

**Official Documentation**: [Get Post](https://api.producthunt.com/v2/docs)

---

### Category: Collections

#### Query Collections

**Method**: `POST` | **LowCodeAPI Path**: `/v2/api/graphql/collections`

**Full URL**:
```
https://api.lowcodeapi.com/producthunt/v2/api/graphql/collections?api_token={api_token}
```

**Description**: Query collections from Product Hunt.

**Request Body**:
```json
{
  "query": "query { collections(first: 20) { edges { node { id, name, description, image } } } }",
  "variables": {}
}
```

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/producthunt/v2/api/graphql/collections?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "query { collections(first: 20) { edges { node { id, name, description, featuredAt } } } }"
  }'
```

**Official Documentation**: [Collections](https://api.producthunt.com/v2/docs)

---

#### Query Single Collection

**Method**: `POST` | **LowCodeAPI Path**: `/v2/api/graphql/collection`

**Full URL**:
```
https://api.lowcodeapi.com/producthunt/v2/api/graphql/collection?api_token={api_token}
```

**Description**: Query a single collection by ID or slug.

**Request Body**:
```json
{
  "query": "query { collection(slug: \"productivity\") { id, name, description, posts { edges { node { id, name } } } } }",
  "variables": {}
}
```

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/producthunt/v2/api/graphql/collection?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "query { collection(slug: \"productivity\") { id, name, description, posts { edges { node { id, name, tagline } } } }"
  }'
```

**Official Documentation**: [Get Collection](https://api.producthunt.com/v2/docs)

---

### Category: Topics

#### Query Topics

**Method**: `POST` | **LowCodeAPI Path**: `/v2/api/graphql/topics`

**Full URL**:
```
https://api.lowcodeapi.com/producthunt/v2/api/graphql/topics?api_token={api_token}
```

**Description**: Query topics from Product Hunt.

**Request Body**:
```json
{
  "query": "query { topics(first: 20) { edges { node { id, name, slug, description } } } }",
  "variables": {}
}
```

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/producthunt/v2/api/graphql/topics?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "query { topics(first: 20) { edges { node { id, name, slug, description, followersCount } } } }"
  }'
```

**Official Documentation**: [Topics](https://api.producthunt.com/v2/docs)

---

### Category: Users

#### Query Users

**Method**: `POST` | **LowCodeAPI Path**: `/v2/api/graphql/users`

**Full URL**:
```
https://api.lowcodeapi.com/producthunt/v2/api/graphql/users?api_token={api_token}
```

**Description**: Query users from Product Hunt. Requires appropriate authentication scopes.

**Request Body**:
```json
{
  "query": "query { users(first: 20) { edges { node { id, name, username, headline } } } }",
  "variables": {}
}
```

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/producthunt/v2/api/graphql/users?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "query { users(first: 20) { edges { node { id, name, username, headline, profileUrl } } } }"
  }'
```

**Official Documentation**: [Users](https://api.producthunt.com/v2/docs)

---

#### Query Single User

**Method**: `POST` | **LowCodeAPI Path**: `/v2/api/graphql/user`

**Full URL**:
```
https://api.lowcodeapi.com/producthunt/v2/api/graphql/user?api_token={api_token}
```

**Description**: Query a single user by ID or username.

**Request Body**:
```json
{
  "query": "query { user(username: \"username\") { id, name, username, headline, profileUrl } }",
  "variables": {}
}
```

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/producthunt/v2/api/graphql/user?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "query { user(username: \"pjiglavi\") { id, name, username, headline, profileUrl } }"
  }'
```

**Official Documentation**: [Get User](https://api.producthunt.com/v2/docs)

---

### Category: Comments

#### Query Comments

**Method**: `POST` | **LowCodeAPI Path**: `/v2/api/graphql/comments`

**Full URL**:
```
https://api.lowcodeapi.com/producthunt/v2/api/graphql/comments?api_token={api_token}
```

**Description**: Query comments from Product Hunt posts.

**Request Body**:
```json
{
  "query": "query { comments(post: \"post-slug\") { edges { node { id, body, createdAt, user { username } } } } }",
  "variables": {}
}
```

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/producthunt/v2/api/graphql/comments?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "query { comments(post: \"product-slug\") { edges { node { id, body, createdAt, user { username, name } } } } }"
  }'
```

**Official Documentation**: [Comments](https://api.producthunt.com/v2/docs)

---

### Category: Votes

#### Query Votes

**Method**: `POST` | **LowCodeAPI Path**: `/v2/api/graphql/votes`

**Full URL**:
```
https://api.lowcodeapi.com/producthunt/v2/api/graphql/votes?api_token={api_token}
```

**Description**: Query votes from Product Hunt posts.

**Request Body**:
```json
{
  "query": "query { post(slug: \"product-slug\") { id, votesCount, votedAt } }",
  "variables": {}
}
```

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/producthunt/v2/api/graphql/votes?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "query { post(slug: \"product-slug\") { id, name, votesCount } }"
  }'
```

**Official Documentation**: [Votes](https://api.producthunt.com/v2/docs)

---

### Category: Makers

#### Query Makers

**Method**: `POST` | **LowCodeAPI Path**: `/v2/api/graphql/makers`

**Full URL**:
```
https://api.lowcodeapi.com/producthunt/v2/api/graphql/makers?api_token={api_token}
```

**Description**: Query makers (product creators) from Product Hunt.

**Request Body**:
```json
{
  "query": "query { makers(first: 20) { edges { node { id, name, username, headline } } } }",
  "variables": {}
}
```

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/producthunt/v2/api/graphql/makers?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "query { makers(first: 20) { edges { node { id, name, username, headline, followersCount } } } }"
  }'
```

**Official Documentation**: [Makers](https://api.producthunt.com/v2/docs)

---

### Category: Custom

#### Execute Custom GraphQL

**Method**: `POST` | **LowCodeAPI Path**: `/v2/api/graphql/custom`

**Full URL**:
```
https://api.lowcodeapi.com/producthunt/v2/api/graphql/custom?api_token={api_token}
```

**Description**: Execute custom GraphQL queries or mutations.

**Request Body**:
```json
{
  "query": "query { posts(order: LATEST, first: 50) { edges { node { id, name, tagline } } } }",
  "variables": {},
  "operationName": "GetLatestPosts"
}
```

**Request Body Fields**:

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `query` | string | Yes | Custom GraphQL query or mutation |
| `variables` | object | No | GraphQL variables |
| `operationName` | string | No | Operation name for the query |

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/producthunt/v2/api/graphql/custom?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "query { posts(order: LATEST, first: 30) { edges { node { id, name, tagline, url, createdAt } } } }",
    "operationName": "GetLatestPosts"
  }'
```

**Official Documentation**: [Custom GraphQL](https://api.producthunt.com/v2/docs)

---

## Usage Examples

### Example 1: Browse Trending Products

Get today's top products:

```bash
# No ID needed - queries GraphQL endpoint
curl -X POST "https://api.lowcodeapi.com/producthunt/v2/api/graphql/posts?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "query { posts(order: POPULAR, first: 30) { edges { node { id, name, tagline, url, votesCount, featuredAt } } } }"
  }'
```

### Example 2: Search Products by Topic

Find products in a specific category:

```bash
# No ID needed - uses GraphQL to filter by topic
curl -X POST "https://api.lowcodeapi.com/producthunt/v2/api/graphql/topics?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "query { topics(first: 30) { edges { node { id, name, slug, } } } }"
  }'
```

### Example 3: Get Product Details

Retrieve detailed information about a product:

```bash
# No ID needed - uses product slug
curl -X POST "https://api.lowcodeapi.com/producthunt/v2/api/graphql/post?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "query { post(slug: \"notion\") { id, name, tagline, description, url, votesCount, createdAt, makers { edges { node { id, name, username } } } } }"
  }'
```

## Complete Endpoint Reference

For a complete list of all 15 endpoints and their parameters, refer to:

- **OpenAPI Definition**: https://backend.lowcodeapi.com/producthunt/definition
- **Official Product Hunt Documentation**: https://api.producthunt.com/v2/docs

## GraphQL Query Examples

Common GraphQL queries:

**Get latest posts**:
```graphql
query {
  posts(order: LATEST, first: 20) {
    edges {
      node {
        id
        name
        tagline
        url
        createdAt
      }
    }
  }
}
```

**Get posts with pagination**:
```graphql
query {
  posts(order: POPULAR, first: 20, after: "cursor") {
    pageInfo {
      hasNextPage
      endCursor
    }
    edges {
      node {
        id
        name
        tagline
      }
    }
  }
}
```

**Get user profile**:
```graphql
query {
  user(username: "username") {
    id
    name
    username
    headline
    profileUrl
  }
}
```

## Rate Limits & Best Practices

- **Rate Limit**: Refer to your Product Hunt plan
- **Best Practices**:
  - Use appropriate GraphQL queries to fetch only needed fields
  - Implement pagination with cursors for large result sets
  - Use the custom GraphQL endpoint for any query not covered by specific endpoints
  - Require appropriate scopes (public, private, write) for different operations
  - Cache frequently accessed data like popular posts and topics

## Error Handling

All responses are wrapped in a `data` key:
```json
{
  "data": {
    // Actual response from Product Hunt
  }
}
```

Common GraphQL errors:
- **400**: Invalid GraphQL query
- **401**: Invalid or expired token
- **403**: Insufficient permissions for requested scope
- **429**: Rate limit exceeded