# Hashnode's GraphQL API for RSS feeds

All this while, parsing my blog's RSS feed from [https://anjanesh.dev/rss.xml](https://anjanesh.dev/rss.xml) on my server was possible to extract the contents of title, description, link, image and date to be inserted at my NextJS powered template at [https://anjanesh.com/blogs](https://anjanesh.com/blogs).

But Hashnode recently made some changes to their blogging system where the front-end seem to sit on a Vercel.

```bash
php blog.rss.php
PHP Warning:  file_get_contents(https://anjanesh.dev/rss.xml): failed to open stream: HTTP request failed! HTTP/1.0 429 Too Many Requests
```

It looks we've hit a Vercel rate limit, as per [https://docs.vercel.com/docs/rest-api/reference/welcome#rate-limits](https://docs.vercel.com/docs/rest-api/reference/welcome#rate-limits). But I got it working using their GraphQL API though - [https://docs.hashnode.com/quickstart/introduction](https://docs.hashnode.com/quickstart/introduction)

```php
function fetch_hashnode_posts($domain)
{
    $url = "https://gql.hashnode.com";
    
    $query = '
    query {
      publication(host: "' . $domain . '") {
        posts(first: 10) {
          edges {
            node {
              title
              brief
              url
              publishedAt
              coverImage {
                url
              }
            }
          }
        }
      }
    }';

    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(['query' => $query]));
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
        'Content-Type: application/json',
        'User-Agent: My-Hashnode/2.5'
    ]);

    $response = curl_exec($ch);
    $result = json_decode($response, true);
    curl_close($ch);

    return $result;
}
```

This has got me interested in knowing more about GraphQL which seem to be the way forward from REST API, esp RSS feeds.
