Back

Product Hunt API Essential Guide

Aug 7, 20246 minute read

What type of API does Product Hunt provide?

Product Hunt uses a GraphQL API. Here are the key points:

API Type

Product Hunt has a GraphQL API.

Key Details

  • The API is accessible at https://api.producthunt.com/v2/api/graphql
  • It requires an access token for authentication
  • The API is currently version 2.0
  • The previous v1 REST API has been deprecated

Advantages of GraphQL

Some advantages of GraphQL APIs like Product Hunt's include:

  • Allows clients to request exactly the data they need in a single query
  • Can be more efficient than REST APIs in some cases by reducing over-fetching and under-fetching of data
  • Provides a flexible way to request and receive complex data

Usage Example

Here's a simple example of how you might query the Product Hunt GraphQL API using Apollo Client in JavaScript:

import { useQuery } from "@apollo/client"; import gql from "graphql-tag"; const GET_PRODUCTS = gql` query getProducts { products { id name description } } `; function ProductList() { const { loading, error, data } = useQuery(GET_PRODUCTS); if (loading) return <p>Loading...</p>; if (error) return <p>Error :(</p>; return ( <ul> {data.products.map((product) => ( <li key={product.id}> {product.name} - {product.description} </li> ))} </ul> ); }

This code defines a GraphQL query to fetch product data and uses Apollo Client's useQuery hook to execute the query and render the results.

In summary, Product Hunt offers a modern GraphQL API that provides developers with a flexible and efficient way to access Product Hunt data programmatically.

Does the Product Hunt API have webhooks?

Does the official Product Hunt API have webhooks?

No, the official Product Hunt API 2.0 does not appear to have built-in webhook functionality. The API documentation primarily focuses on GraphQL queries and mutations for accessing and manipulating Product Hunt data.

Key points to consider:

  1. The official Product Hunt API is a GraphQL-based API that provides access to Product Hunt data.

  2. While the official API doesn't offer webhooks, there are third-party APIs and integrations that provide additional functionality, including webhooks.

  3. The API documentation mentions "There is quite a bunch of third party APIs. Blazin' fast fulltext search, SDKs with callbacks for real-time like interaction, web-hooks, etc etc."

Alternative options:

If you need webhook functionality for Product Hunt, you may want to explore the following options:

  1. Third-party APIs: Look into the full list of third-party APIs mentioned in the documentation, as some of these may offer webhook functionality.

  2. Open-source solutions: The documentation suggests that there are open-source software options available that you might be able to reuse or adapt for your needs.

  3. Custom implementation: You could potentially build your own webhook system on top of the official API, periodically querying for changes and triggering events as needed.

Best practices:

  1. Always check the API documentation for the most up-to-date information, as features may change over time.

  2. If you decide to use third-party solutions or build your own webhook system, ensure that you comply with Product Hunt's API usage terms and fair use policy.

  3. For any commercial use of the Product Hunt API, you should contact Product Hunt directly at [email protected] to discuss your requirements and obtain necessary permissions.

In conclusion, while the official Product Hunt API doesn't offer built-in webhook functionality, there are alternative options you can explore to achieve similar real-time or near-real-time event-based interactions with Product Hunt data.

Rate Limits and other limitations

Here are the key points about the API rate limits for the Product Hunt API:

Rate Limit Types

The Product Hunt API has two types of rate limits:

  1. Complexity-based limit (for /v2/api/graphql endpoint):

    • 6250 complexity points every 15 minutes [1]
  2. Request-based limit (for all other /v2/* endpoints):

    • 450 requests every 15 minutes [1]

Rate Limit Headers

Each API response includes 3 rate limit headers:

  • X-Rate-Limit-Limit: Your application's limit for the 15 minute period
  • X-Rate-Limit-Remaining: Remaining quota for the reset period
  • X-Rate-Limit-Reset: Seconds until the rate limit is reset [1]

Key Considerations

  • Rate limiting is applied per application [1]
  • The API owners may adjust the rate limit depending on API traffic [1]
  • If you require a higher rate limit, you need to contact Product Hunt [1]
  • For academic/research projects, you can request an increased rate limit by emailing [email protected] [3]

Best Practices

  • Monitor the rate limit headers in API responses to track your usage [4]
  • Add delays between requests to avoid hitting limits too quickly [4]
  • If the remaining limit reaches 0, wait for the reset time before making more requests [4]
  • Consider using the V1 API for bulk data retrieval, as it allows more data per request than V2 [4]

By following these guidelines and respecting the rate limits, you can query the Product Hunt API responsibly and avoid disruptions in your data retrieval process.

Latest API Version

Based on the search results, here are the key points about the most recent version of the Product Hunt API:

Current Version

The most recent version of the Product Hunt API is Version 2.0 (V2) [2][3].

Key Features of V2 API

  • It uses a GraphQL interface to provide access to Product Hunt data [2].
  • It is accessible at https://api.producthunt.com/v2/api/graphql [2].
  • Authentication is required using an access token [2].

Important Changes

  • The V1 API is deprecated and seems to be fully shut down later this year (as of February 2023) [4].
  • There have been significant changes to the API, including the removal of several key fields such as usernames and Twitter handles [4].

Access and Usage

  • By default, the API is read-only with 'public' scope [2].
  • For commercial use, developers need to contact Product Hunt directly [2].
  • There are three types of scopes an application can request: Public, Private, and Write [2].

Documentation and Resources

  • Official documentation is available at https://api.producthunt.com/v2/docs [2].
  • There's a GraphQL reference available [3].
  • An API Explorer is provided for testing queries [2][3].

Best Practices

  • Developers are encouraged to include attribution in their projects, linking back to Product Hunt [2].
  • It's recommended to stay adaptable and be prepared for unexpected changes in third-party APIs [4].

In conclusion, developers should use the V2 API with GraphQL queries for accessing Product Hunt data, as the V1 API is deprecated. It's important to be aware of the recent changes and limitations, especially regarding access to certain user data.

How to get a Product Hunt developer account and API Keys?

Here are the steps to get a developer account for Product Hunt to create an API integration:

  1. Sign up for a Product Hunt account if you don't already have one.

  2. Go to the Product Hunt API dashboard (https://api.producthunt.com/v2/oauth/applications).

  3. Click on "Add an Application" to create a new API application.

  4. You'll be prompted to enter an app name and redirect URI. For the redirect URI, you can use something like https://localhost:3000/ if you're just testing.

  5. This will generate an API key and API secret for your application.

  6. To get an access token, you have two options:

    a) Use the API key and secret to request an OAuth token via a cURL command:

    curl --header "Content-Type: application/json" \
      --request POST \
      --data '{"client_id":"YOUR_API_KEY","client_secret":"YOUR_API_SECRET", "grant_type": "client_credentials"}' \
      https://api.producthunt.com/v2/oauth/token
    

    b) Generate a Developer Token by clicking the button at the bottom of your app's page in the API dashboard. This token does not expire and is linked to your account.

  7. You can now use the access token or Developer Token to authenticate API requests.

What can you do with the Product Hunt API?

Here are the key data models you can interact with using the Product Hunt API, along with what is possible for each:

Products

  • Retrieve details about products listed on Product Hunt
  • Get information like name, tagline, description, launch date, votes, comments, etc.
  • Search for products
  • Get trending products
  • Get products by category/topic

Users

  • Retrieve user profile information
  • Get a user's posted products
  • Get a user's upvoted products
  • Get a user's comments
  • Get a user's followers/following

Comments

  • Retrieve comments on products
  • Post new comments on products (with write access)
  • Get comments by a specific user

Topics/Categories

  • Get list of topics/categories
  • Get products under a specific topic

Collections

  • Get collections created by users
  • Get products within a collection

Makers

  • Get maker profiles
  • Get products made by a specific maker

Votes

  • Get vote counts for products
  • Get users who voted for a product
  • Vote on a product (with write access)
  • Search across products, users, topics, etc.

Analytics

  • Get view/click analytics for products (with appropriate access)

Webhooks

  • Set up webhooks for real-time notifications on events

The key things to note are:

  • Most endpoints provide read access by default
  • Write operations like posting comments or voting require special write access privileges
  • The API uses GraphQL, allowing flexible querying of the data models
  • There are rate limits and fair use policies to be aware of

Let me know if you need any clarification or have additional questions about the Product Hunt API data models!