How to show blog posts from your Hashnode blog on your personal site?

Subscribe to my newsletter and never miss my upcoming articles

Ever wanted to fetch your recent articles from your Hashnode powered blog and display on your portfolio site? You can now do that using Hashnode's GraphQL APIs. 🥳

To play around with our APIs, please visit api.hashnode.com

Listing your recent posts

Here is the GraphQL query you need to run:

query{
  user(username:"sandeep") {
    publication {
      posts(page:0) {
        title
        brief
        slug
        cuid
      }
    }
  }
}

Endpoint: https://api.hashnode.com

Simply replace username with your Hashnode username. Here is a simple CodeSandBox demo with code examples:

Showing a particular blog post

To get a single blog post, run the following query:

query {
  post(slug:"how-to-achieve-truly-zero-downtime-deployment-using-pm2", hostname:"sandeep.dev") {
    title,
    slug,
    cuid,
    coverImage,
    content,
    contentMarkdown
  }
}

Endpoint: https://api.hashnode.com

Just tweak slug and hostname params to personalize the above query. Here is another CodeSandBox example to help you get started.


We are in the process of documenting our APIs properly, until then please use our GraphQL Playground to explore more.

Alyssa Holland's photo

This article has been posted at the right time as I was just about to start researching how to do this. Thanks for sharing this useful information!

Skay's photo

I was about to comment the same thing! 😃

Alyssa Holland's photo

Skay Great minds think alike 😁

indiemaker55's photo

Hi. I like hashnode API and recently I played around it. I'm wondering how to identify the URL of each feeds using API. I could get 'slug' via storiesFeed query, but couldn't find the way to identify 'hostname' which is needed to use 'post' query. Is there any way to get 'hostname' or full URL of each feeds?

Thanks!

Omotola Shogunle's photo

Wow I was just thinking about how I can do this on my portfolio. Thanks

Victoria Lo's photo

Thanks for this article! I was just playing around with the Hashnode API the other day. This article is very insightful!

Mridul Ganga's photo

Great feature!

Chris Bongers's photo

Damn this is amazing! Nice work guys 🥰

Hrithwik Bharadwaj's photo

I was waiting for this one