Hashnode api

From rawveg/skillsforge-marketplace · View interactive version

Hashnode api is an AI agent skill from the GitHub repository rawveg/skillsforge-marketplace. Hashnode GraphQL API documentation for creating, managing, and querying blogs, posts, publications, and user data on the Hashnode platform

How to use this skill

Skill file

Hashnode API Skill

Comprehensive assistance with the Hashnode GraphQL API for blog management, content creation, and user interaction on the Hashnode platform.

When to Use This Skill

This skill should be triggered when:

Key Concepts

API Endpoint

All Hashnode API requests go through a single GraphQL endpoint:

Authentication

Rate Limits

Caching

Error Codes

Common GraphQL error codes:

Quick Reference

1. Fetch Publication Details

query Publication {
  publication(host: "blog.developerdao.com") {
    id
    isTeam
    title
    about {
      markdown
    }
  }
}

Get basic information about a publication by its hostname.

2. Fetch Recent Blog Posts

query Publication {
  publication(host: "blog.developerdao.com") {
    id
    isTeam
    title
    posts(first: 10) {
      edges {
        node {
          id
          title
          brief
          url
        }
      }
      pageInfo {
        endCursor
        hasNextPage
      }
    }
  }
}

Retrieve the latest 10 posts from a publication with cursor-based pagination support.

3. Fetch a Single Article by Slug

query Publication {
  publication(host: "blog.developerdao.com") {
    id
    post(slug: "the-developers-guide-to-chainlink-vrf-foundry-edition") {
      id
      title
      content {
        markdown
        html
      }
    }
  }
}

Get full content of a specific article using its slug and publication hostname.

4. Cursor-Based Pagination (Infinite Scroll)

query Publication {
  publication(host: "blog.developerdao.com") {
    id
    posts(
      first: 10
      after: "NjQxZTc4NGY0M2NiMzc2YjAyNzNkMzU4XzIwMjMtMDMtMjVUMDQ6Mjc6NTkuNjQxWg=="
    ) {
      edges {
        node {
          id
          title
          brief
          url
        }
      }
      pageInfo {
        endCursor
        hasNextPage
      }
    }
  }
}

Use endCursor from previous response as after parameter to fetch next page.

5. Offset-Based Pagination (Traditional Pages)

query Followers {
  user(username: "SandroVolpicella") {
    id
    followers(pageSize: 10, page: 1) {
      nodes {
        id
        username
      }
      pageInfo {
        hasNextPage
        hasPreviousPage
        previousPage
        nextPage
      }
    }
  }
}

Navigate between pages using explicit page numbers.

6. Get Entity Count (Series Count Example)

query SeriesCount {
  publication(host: "engineering.hashnode.com") {
    id
    seriesList(first: 0) {
      totalDocuments
    }
  }
}

Result:

{
  "data": {
    "publication": {
      "seriesList": {
        "totalDocuments": 3
      }
    }
  }
}

Use totalDocuments field to get counts without fetching all data.

7. Fetch Posts from a Series

query Publication {
  publication(host: "lo-victoria.com") {
    id
    series(slug: "graphql") {
      id
      name
      posts(first: 10) {
        edges {
          node {
            id
            title
          }
        }
      }
    }
  }
}

Get all posts belonging to a specific series.

8. Fetch Static Pages

query Publication {
  publication(host: "lo-victoria.com") {
    id
    staticPages(first: 10) {
      edges {
        node {
          id
          title
          slug
        }
      }
    }
  }
}

Retrieve custom static pages like "About", "Contact", etc.

9. Fetch Single Static Page

query Publication {
  publication(host: "lo-victoria.com") {
    id
    staticPage(slug: "about") {
      id
      title
      content {
        markdown
      }
    }
  }
}

Get content of a specific static page by slug.

10. Authentication Example - Get Drafts (Requires Auth)

query Publication($first: Int!, $host: String) {
  publication(host: $host) {
    id
    drafts(first: $first) {
      edges {
        node {
          id
          title
        }
      }
    }
  }
}

Headers:

{
  "Authorization": "your-personal-access-token-here"
}

Variables:

{
  "first": 10,
  "host": "your-blog-host.hashnode.dev"
}

Drafts can only be queried by the publication owner with valid authentication.

Reference Files

This skill includes comprehensive documentation in references/:

Use the reference files for detailed information about specific API features, error handling patterns, and advanced query techniques.

Working with This Skill

For Beginners

Start by understanding the core concepts above, then explore:

  1. API Endpoint: Test queries in the playground at https://gql.hashnode.com
  2. Authentication: Generate your PAT at https://hashnode.com/settings/developer
  3. Basic Queries: Try fetching publication details and blog posts first
  4. Pagination: Start with cursor-based pagination for simple infinite scroll

For Intermediate Users

Focus on:

  1. Authentication flows: Implement PAT-based auth in your application
  2. Error handling: Handle GraphQL error codes properly
  3. Pagination strategies: Choose between cursor-based and offset-based based on your UI needs
  4. Caching considerations: Always request id fields to avoid stale data
  5. Content extraction: Work with both markdown and HTML content formats

For Advanced Users

Explore:

  1. Mutations: Publishing posts, managing drafts, updating content
  2. Complex queries: Nested queries with multiple levels (publication → series → posts)
  3. Batch operations: Optimize API calls with GraphQL field selection
  4. Webhook integration: Handle Hashnode webhook events
  5. Rate limit optimization: Implement efficient request batching

Navigation Tips

Common Use Cases

Building a Blog Frontend

  1. Fetch publication metadata
  2. Get post list with pagination
  3. Display individual posts by slug
  4. Implement series/category navigation
  5. Show static pages (about, contact)

Content Management Dashboard

  1. Authenticate with PAT
  2. List and manage drafts
  3. Publish/update posts
  4. Schedule content
  5. Monitor analytics

Newsletter Integration

  1. Subscribe/unsubscribe users
  2. Fetch subscriber counts
  3. Manage email preferences
  4. Track engagement metrics

Migration from Legacy API

  1. Update endpoint from api.hashnode.com to gql.hashnode.com
  2. Convert REST calls to GraphQL queries
  3. Update authentication mechanism (check docs)
  4. Adjust pagination from old format to cursor/offset-based
  5. Update error handling for new error codes

Resources

Official Documentation

references/

The api.md reference file contains:

Important Notes

Troubleshooting

Getting UNAUTHENTICATED errors?

Not seeing latest data?

Query validation failed?

Rate limit reached?

Updating

This skill was automatically generated from official Hashnode documentation. To refresh with updated documentation, regenerate the skill using the latest docs from https://apidocs.hashnode.com.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.