<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[API Hero blog]]></title><description><![CDATA[API Hero blog]]></description><link>https://blog.apihero.run</link><generator>RSS for Node</generator><lastBuildDate>Sun, 08 Nov 2026 20:51:17 GMT</lastBuildDate><atom:link href="https://blog.apihero.run/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Introducing API Hero: an open-source proxy that makes every API you use faster and more reliable]]></title><description><![CDATA[Easily debug API problems with monitoring and logging of request and responses. Add caching to all of your APIs that will give you under 20ms response…]]></description><link>https://blog.apihero.run/api-hero-an-open-source-proxy-that-makes-every-api-you-use-faster-and-more-reliable</link><guid isPermaLink="true">https://blog.apihero.run/api-hero-an-open-source-proxy-that-makes-every-api-you-use-faster-and-more-reliable</guid><category><![CDATA[APIs]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[TypeScript]]></category><category><![CDATA[Node.js]]></category><category><![CDATA[Open Source]]></category><dc:creator><![CDATA[Matt Aitken]]></dc:creator><pubDate>Tue, 22 Nov 2022 15:00:05 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1669128949247/u5DB94fy9.jpg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>We’ve tackled two major headaches we’ve had when using APIs:</p>
<ol>
<li>Figuring out what’s going wrong when using an API is painful</li>
<li>Slow endpoints can dramatically reduce the speed of your site</li>
</ol>
<p>You only need to <a target="_blank" href="https://apihero.run">add a couple of lines of code</a> in your JavaScript/Typescript frontend or backend to start seeing <a target="_blank" href="https://apihero.run">the benefits</a>.</p>
<h3 id="heading-debugging-requests-and-responses-the-easy-way">🦸‍♀️ Debugging requests and responses, the easy way</h3>
<p>You need full visibility of API requests and responses to figure out what’s going wrong. But please don’t litter your code with <code>console.log()</code> 🙈.</p>
<p>You can quickly filter to find issues, then dig into the details of each request and response to diagnose the problem.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1669126908837/hF5Pks3xJ.png" alt="Get to the bottom of bugs quickly" /></p>
<p>It’s really useful during development when trying to figure out how an API works, but also during production when something unexpected happens.</p>
<h3 id="heading-speed-up-the-apis-you-use">🐆 Speed up the APIs you use</h3>
<p>A slow API can destroy your otherwise fast site. It’s hard to fix this, especially when you don’t control the API.</p>
<p>The best thing you can do is to add a caching layer so repeated requests don’t always hit the API. We provide an edge-located API cache that can consistently give you under 20ms response times.</p>
<h3 id="heading-how-does-this-work">🥸 How does this work?</h3>
<p>API Hero is an open source proxy that’s distributed on top of Cloudflare’s 275 data centers that are located all around the world.</p>
<p>When you add API Hero to your product, it pushes API traffic you select to that proxy. From there we can return really fast cached responses where relevant or connect to the original API destination. Every request and response is logged so you can easily find issues and debug them.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1669126977494/-3gkpe3cq.png" alt="How it works" /></p>
<h3 id="heading-100-open-source">📖 100% open source</h3>
<p>If you’d like to contribute or run API Hero yourself, feel free to join us on our <a target="_blank" href="https://github.com/apihero-run/apihero">GitHub</a>. We also offer a <a target="_blank" href="https://apihero.run">hosted version</a> that you can try out for free.</p>
<p>API Hero is a combination of three services. The web app is a React app built using the Remix framework and runs on fly.io. The logs service is a Fastify API hosted on fly.io. The proxy is hosted on Cloudflare using Workers.</p>
<p>Please give us <a target="_blank" href="https://github.com/apihero-run/apihero">a star on GitHub</a> to get the latest updates 💫.</p>
<h3 id="heading-dog-food-anyone">🐕 Dog food anyone?</h3>
<blockquote>
<p>Eating your own dog food or "<em>dogfooding</em>" is the practice of using one's own products or services</p>
</blockquote>
<p>We’re using API Hero to develop API Hero 🤯. This has helped us to quickly uncover some problems when integrating third party services .</p>
<h3 id="heading-whats-next">🔮 What’s next?</h3>
<p>What would you like us to work on next? We’d love to hear from you. Arrange <a target="_blank" href="https://cal.com/team/apihero/request-a-demo">a call with us</a> or <a target="_blank" href="mailto:hello@apihero.run">drop us a message</a>.</p>
]]></content:encoded></item><item><title><![CDATA[How to programmatically create a commit on GitHub using the GitHub API and API Hero]]></title><description><![CDATA[The GitHub REST API is a useful behemoth, currently sitting at 878 endpoints (by our count) and growing. It contains all sorts of useful functionality…]]></description><link>https://blog.apihero.run/how-to-programmatically-create-a-commit-on-github</link><guid isPermaLink="true">https://blog.apihero.run/how-to-programmatically-create-a-commit-on-github</guid><category><![CDATA[GitHub]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[TypeScript]]></category><category><![CDATA[Node.js]]></category><category><![CDATA[APIs]]></category><dc:creator><![CDATA[Eric Allam]]></dc:creator><pubDate>Thu, 29 Sep 2022 13:30:45 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1664200184273/9QPnp67FN.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>The GitHub REST API is a useful behemoth, currently sitting at 878 endpoints (by our count) and growing. It contains all sorts of useful functionality, from <a target="_blank" href="https://docs.github.com/en/rest/search#search-code">searching for code</a> to <a target="_blank" href="https://docs.github.com/en/rest/markdown#render-a-markdown-document">rendering markdown</a>, and then some.</p>
<p>You can also use it to interact with the raw git repository to read and modify the actual underlying data. One very useful thing you can do is create a new commit, but it's not exactly a straightforward <code>POST /commit</code> call. It helps if you understand a bit about how the <a target="_blank" href="https://git-scm.com/book/en/v2/Git-Internals-Git-Objects">git internals</a> work, but for the following post we're going break it down step-by-step.</p>
<p>We're also going to show how using <a target="_blank" href="https://apihero.run">API Hero</a> can save us time by using the <a target="_blank" href="https://github.com/apihero-run/apihero-github">GitHub</a> integration, and getting nicely typed requests and responses, as well as the ability to view and debug request data.</p>
<h2 id="heading-what-is-api-hero">What is API Hero?</h2>
<p>Before we get started, if you aren't familiar with API Hero, you can quickly get up to speed with this 60 second explainer:</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://www.youtube.com/watch?v=nek3WHRUwow">https://www.youtube.com/watch?v=nek3WHRUwow</a></div>
<h2 id="heading-setup-your-api-hero-project">Setup your API Hero project</h2>
<p>Before we can create our first commit programmatically, we need to setup the project with API Hero and add the GitHub integration. For this post, we'll use <a target="_blank" href="https://docs.apihero.run/node-quick-start">Node.js</a>, and this <a target="_blank" href="https://github.com/apihero-run/apihero-github-commits">GitHub repo</a> that you can clone to follow along:</p>
<pre><code class="lang-bash">git <span class="hljs-built_in">clone</span> https://github.com/apihero-run/apihero-github-commits.git
<span class="hljs-built_in">cd</span> apihero-github-commits
npm install
</code></pre>
<p>Next we'll run the <code>apihero</code> CLI to add API Hero and the GitHub integration to our project:</p>
<pre><code class="lang-bash">npx apihero@latest add git
</code></pre>
<p>Here is what that would look like (although you may also be asked to authenticate to API Hero, which doesn't happen below):</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1663929337845/bgQdNAYyE.gif" alt="CleanShot 2022-09-23 at 11.34.30.gif" /></p>
<p>Next, copy the "project key" printed after running the previous command and create a <code>.env</code> file in the root of the repository with the following contents:</p>
<pre><code>APIHERO_PROJECT_KEY=<span class="hljs-string">"&lt;your projectKey here&gt;"</span>
</code></pre><h2 id="heading-1-fetch-latest-commit">1. Fetch latest commit</h2>
<p>The first request to the GitHub API that we need to make is to fetch the latest commit for the branch we want to commit to.  We can do that by using the <a target="_blank" href="https://docs.github.com/en/rest/git/refs#get-a-reference">get a reference</a> endpoint, passing in the <code>owner</code>, <code>repo</code>, and <code>ref</code>. For branches, the ref is in the format of <code>heads/{branchName}</code>.</p>
<p>Update the <code>src/index.ts</code> file with the following code:</p>
<pre><code class="lang-ts"><span class="hljs-keyword">import</span> { git } <span class="hljs-keyword">from</span> <span class="hljs-string">"@apihero/github"</span>;
<span class="hljs-keyword">import</span> { fetchEndpoint } <span class="hljs-keyword">from</span> <span class="hljs-string">"@apihero/node"</span>;

<span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">createCommit</span>(<span class="hljs-params">owner: <span class="hljs-built_in">string</span>, repo: <span class="hljs-built_in">string</span>, branch: <span class="hljs-built_in">string</span></span>) </span>{
  <span class="hljs-keyword">const</span> ref = <span class="hljs-keyword">await</span> fetchEndpoint(git.getRef, {
    owner,
    repo,
    ref: <span class="hljs-string">`heads/<span class="hljs-subst">${branch}</span>`</span>,
  });
}

createCommit(<span class="hljs-string">"apihero-run"</span>, <span class="hljs-string">"apihero-github-commits"</span>, <span class="hljs-string">"commit-playground"</span>).catch(<span class="hljs-built_in">console</span>.error);
</code></pre>
<p>As you can see we're defining the <code>createCommit</code> function and then calling it, passing in the <a target="_blank" href="https://github.com/apihero-run/apihero-github-commits">apihero-github-commits repo</a>. It's using the <code>fetchEndpoint</code> function from <code>@apihero/node</code> and the <code>git.getRef</code> endpoint from the <code>@apihero/github</code> client library.</p>
<p>Now run this code in the terminal like so:</p>
<pre><code class="lang-bash">npm run dev
</code></pre>
<p>This runs the <code>src/index.ts</code> file using <a target="_blank" href="https://github.com/esbuild-kit/tsx">tsx</a>. Notice how we aren't logging out the request or response above, or setting up a breakpoint to see what the request or response is.  That's because we're using API Hero, and all that data is saved for us to inspect in your Request History. And our <code>@apihero/node</code> package will print out a link for you to use to jump right there, like so:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1663937571056/6BLnqXsDp.gif" alt="CleanShot 2022-09-23 at 13.51.37.gif" /></p>
<p>Visiting that link brings us to the request, where we can inspect the response body:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1663937681139/SE-aafyP0.png" alt="CleanShot 2022-09-23 at 13.53.53@2x.png" /></p>
<h2 id="heading-2-create-a-commit-tree">2. Create a commit tree</h2>
<p>Next, we'll need to create a tree using the <a target="_blank" href="https://docs.github.com/en/rest/git/trees#create-a-tree">Create a tree</a> endpoint. A git tree is the internal git object that defines the hierarchy between files in a git repository. Think of it as the list of files in a git repo, along with their "sha" hash identifier.</p>
<p>There are a few ways to do this using the "Create a tree", but the easiest is to just give a list of files and their contents for only the files we want to change.</p>
<p>We'll also need to set the "base" of this newly created tree to the <code>sha</code> of the latest commit in the branch, which we now have from our previous request:</p>
<pre><code class="lang-ts"><span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">createCommit</span>(<span class="hljs-params">owner: <span class="hljs-built_in">string</span>, repo: <span class="hljs-built_in">string</span>, branch: <span class="hljs-built_in">string</span></span>) </span>{
  <span class="hljs-keyword">const</span> ref = <span class="hljs-keyword">await</span> fetchEndpoint(git.getRef, {
    owner,
    repo,
    ref: <span class="hljs-string">`heads/<span class="hljs-subst">${branch}</span>`</span>,
  });

  <span class="hljs-keyword">if</span> (ref.status === <span class="hljs-string">"error"</span>) {
    <span class="hljs-keyword">throw</span> ref.error;
  }

  <span class="hljs-keyword">const</span> commitTree = <span class="hljs-keyword">await</span> fetchEndpoint(git.createTree, {
    owner,
    repo,
    tree: {
      tree: [],
      base_tree: ref.body.object.sha,
    },
  });
}
</code></pre>
<p>So far so good, but we still need to add content to the <code>tree</code> array to actually make any changes in this commit. If we hover over the <code>git.createTree</code> endpoint in VS Code, we can see what data is expected in the tree array:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1663938555963/O8l1gUhAp.png" alt="CleanShot 2022-09-23 at 14.07.33@2x.png" /></p>
<p>Writing out an example entry and then hovering over each property presents helpful documentation about each one:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1663938849000/JpVe9pGXZ.png" alt="CleanShot 2022-09-23 at 14.14.00@2x.png" /></p>
<p>Let's update the <code>tree</code> array with a new file based on the current datetime:</p>
<pre><code class="lang-ts"><span class="hljs-keyword">const</span> commitTree = <span class="hljs-keyword">await</span> fetchEndpoint(git.createTree, {
    owner,
    repo,
    tree: {
      tree: [
        {
          path: <span class="hljs-string">`playground/<span class="hljs-subst">${<span class="hljs-built_in">Date</span>.now()}</span>.txt`</span>,
          mode: <span class="hljs-string">"100644"</span>,
          <span class="hljs-keyword">type</span>: <span class="hljs-string">"blob"</span>,
          content: <span class="hljs-string">`The time is <span class="hljs-subst">${(<span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>()).toISOString()}</span>`</span>,
        },
      ],
      base_tree: ref.body.object.sha,
    },
  });
</code></pre>
<p>Now let's run <code>npm run dev</code> again and inspect the request to view the response data:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1663939101723/itRVcJLbe.png" alt="CleanShot 2022-09-23 at 14.17.12@2x.png" /></p>
<p>Oops, looks like something went wrong.  Usually with the GitHub API, receiving a 404 status means either we fat fingered the repo name, or we're trying to perform an authorized request but haven't added any authorization info to the request.</p>
<p>If we navigate to our project dashboard, we can easily add authentication in API Hero, without having to change anything in our code:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1663939257853/-wZkuga17.png" alt="CleanShot 2022-09-23 at 14.20.23@2x.png" /></p>
<p>Let's use the Personal Access Token authentication strategy to make requests as ourself . Follow the directions <a target="_blank" href="https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token">here</a> for creating a PAT in GitHub, and then add your GitHub username as the username and the PAT as the password, like so:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1663939568203/RmoJwBMPK.png" alt="CleanShot 2022-09-23 at 14.25.37@2x.png" /></p>
<p>After hitting save, we can run <code>npm run dev</code> again and head back to the Request History page in API Hero and we should now see a 201 response:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1664052578103/_BNXcxe8a.png" alt="CleanShot 2022-09-24 at 21.48.33@2x.png" /></p>
<h2 id="heading-3-create-a-commit">3. Create a commit</h2>
<p>Okay, now that we've created the tree content of the commit, it's time to actually create the commit itself, with a message, the commit tree, and a reference to the commit's parent:</p>
<pre><code class="lang-ts"><span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">createCommit</span>(<span class="hljs-params">owner: <span class="hljs-built_in">string</span>, repo: <span class="hljs-built_in">string</span>, branch: <span class="hljs-built_in">string</span></span>) </span>{
  <span class="hljs-keyword">const</span> ref = <span class="hljs-keyword">await</span> fetchEndpoint(git.getRef, {
    owner,
    repo,
    ref: <span class="hljs-string">`heads/<span class="hljs-subst">${branch}</span>`</span>,
  });

  <span class="hljs-keyword">if</span> (ref.status === <span class="hljs-string">"error"</span>) {
    <span class="hljs-keyword">throw</span> ref.error;
  }

  <span class="hljs-keyword">const</span> commitTree = <span class="hljs-keyword">await</span> fetchEndpoint(git.createTree, {
    owner,
    repo,
    tree: {
      tree: [
        {
          path: <span class="hljs-string">`playground/<span class="hljs-subst">${<span class="hljs-built_in">Date</span>.now()}</span>.txt`</span>,
          mode: <span class="hljs-string">"100644"</span>,
          <span class="hljs-keyword">type</span>: <span class="hljs-string">"blob"</span>,
          content: <span class="hljs-string">`The time is <span class="hljs-subst">${<span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>().toISOString()}</span>`</span>,
        },
      ],
      base_tree: ref.body.object.sha,
    },
  });

  <span class="hljs-keyword">if</span> (commitTree.status === <span class="hljs-string">"error"</span>) {
    <span class="hljs-keyword">throw</span> commitTree.error;
  }

  <span class="hljs-keyword">const</span> commit = <span class="hljs-keyword">await</span> fetchEndpoint(git.createCommit, {
    owner,
    repo,
    commit: {
      message: <span class="hljs-string">"Create a new file"</span>,
      tree: commitTree.body.sha,
      parents: [ref.body.object.sha],
    },
  });
}
</code></pre>
<p>After running <code>npm run dev</code> again, you can see the request should have succeeded with another 201 created:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1664053429803/NYbdxRHzr.png" alt="CleanShot 2022-09-24 at 22.02.58@2x.png" /></p>
<p>But if we head over to the GitHub repo's <a target="_blank" href="https://github.com/apihero-run/apihero-github-commits/tree/commit-playground">commit-playground branch</a>, we can see that our commit isn't showing up:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1664053510634/4DaQpJBqs.png" alt="CleanShot 2022-09-24 at 22.04.39@2x.png" /></p>
<h2 id="heading-4-update-the-head-ref">4. Update the HEAD ref</h2>
<p>That's because we have to do 1 more step before our commit is finalized: update the HEAD of the <code>commit-playground</code> branch to point to the new commit's <code>sha</code>, using the <a target="_blank" href="https://docs.github.com/en/rest/git/refs#update-a-reference">Update a reference</a> endpoint:</p>
<pre><code class="lang-ts"><span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">createCommit</span>(<span class="hljs-params">owner: <span class="hljs-built_in">string</span>, repo: <span class="hljs-built_in">string</span>, branch: <span class="hljs-built_in">string</span></span>) </span>{
  <span class="hljs-keyword">const</span> ref = <span class="hljs-keyword">await</span> fetchEndpoint(git.getRef, {
    owner,
    repo,
    ref: <span class="hljs-string">`heads/<span class="hljs-subst">${branch}</span>`</span>,
  });

  <span class="hljs-keyword">if</span> (ref.status === <span class="hljs-string">"error"</span>) {
    <span class="hljs-keyword">throw</span> ref.error;
  }

  <span class="hljs-keyword">const</span> commitTree = <span class="hljs-keyword">await</span> fetchEndpoint(git.createTree, {
    owner,
    repo,
    tree: {
      tree: [
        {
          path: <span class="hljs-string">`playground/<span class="hljs-subst">${<span class="hljs-built_in">Date</span>.now()}</span>.txt`</span>,
          mode: <span class="hljs-string">"100644"</span>,
          <span class="hljs-keyword">type</span>: <span class="hljs-string">"blob"</span>,
          content: <span class="hljs-string">`The time is <span class="hljs-subst">${<span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>().toISOString()}</span>`</span>,
        },
      ],
      base_tree: ref.body.object.sha,
    },
  });

  <span class="hljs-keyword">if</span> (commitTree.status === <span class="hljs-string">"error"</span>) {
    <span class="hljs-keyword">throw</span> commitTree.error;
  }

  <span class="hljs-keyword">const</span> commit = <span class="hljs-keyword">await</span> fetchEndpoint(git.createCommit, {
    owner,
    repo,
    commit: {
      message: <span class="hljs-string">"Create a new file"</span>,
      tree: commitTree.body.sha,
      parents: [ref.body.object.sha],
    },
  });

  <span class="hljs-keyword">if</span> (commit.status === <span class="hljs-string">"error"</span>) {
    <span class="hljs-keyword">throw</span> commit.error;
  }

  <span class="hljs-keyword">const</span> updatedRef = <span class="hljs-keyword">await</span> fetchEndpoint(git.updateRef, {
    owner,
    repo,
    ref: <span class="hljs-string">`heads/<span class="hljs-subst">${branch}</span>`</span>,
    payload: {
      sha: commit.body.sha,
    },
  });
}
</code></pre>
<p>After running <code>npm run dev</code> again, we should see the request to update the ref in the Request History:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1664054077687/qJKsT65hH.png" alt="CleanShot 2022-09-24 at 22.12.31@2x.png" /></p>
<p>And then heading back over to the repo on GitHub should show the new commit (as well as the <a target="_blank" href="https://github.com/apihero-run/apihero-github-commits/blob/commit-playground/playground/1664053929256.txt">new file</a>:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1664054102790/87zgN-XOa.png" alt="CleanShot 2022-09-24 at 22.13.20@2x.png" /></p>
<h2 id="heading-wrap-up">Wrap up</h2>
<p>Create a commit in GitHub programmatically can be extremely useful, especially for automating devops tasks or when generating code. In fact, API Hero internally does this exact thing for when we release a new integration package (like the <a target="_blank" href="https://www.npmjs.com/package/@apihero/github">@apihero/github</a> one we just used).</p>
<p>If you have any questions or feedback, please hop in to our <a target="_blank" href="https://discord.gg/4XZ3wsCXnG">discord channel</a> or feel free to email me @ eric@apihero.run.</p>
]]></content:encoded></item><item><title><![CDATA[How to use the GitHub API directly from your Next.js app using API Hero]]></title><description><![CDATA[TLDR: this will take you less time than you think]]></description><link>https://blog.apihero.run/github-api-from-nextjs</link><guid isPermaLink="true">https://blog.apihero.run/github-api-from-nextjs</guid><category><![CDATA[GitHub]]></category><category><![CDATA[APIs]]></category><category><![CDATA[Next.js]]></category><category><![CDATA[React]]></category><category><![CDATA[react-query]]></category><dc:creator><![CDATA[Matt Aitken]]></dc:creator><pubDate>Wed, 28 Sep 2022 14:00:42 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1664301027359/w1gl33CMe.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>We're going to make a simple <a target="_blank" href="https://nextjs.org">Next.js</a> app that displays a GitHub user, or organisation’s, most popular public GitHub repositories. </p>
<p>This is what the final thing will look like:
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1663955692088/bn2qfgYP-.gif" alt="The final thing" /></p>
<p>There is one major issue: GitHub has a very low rate limit of only 60 requests per hour without authentication. I hit this limit whilst playing with the site myself for just a few minutes locally! We can't add authentication on the client as that would involve leaking that information to all of our users. </p>
<p>We could create a proxy by using <a target="_blank" href="https://nextjs.org/docs/api-routes/introduction">Next.js API routes</a>. This means creating our own API route which then queries GitHub and then returns GitHub's response back to React. It's a bit annoying having to do this. A more serious problem is we want to add caching so we can scale the number of requests up a lot, only fetching new data.</p>
<p>Instead of all that hard work we're going to use <a target="_blank" href="https://apihero.run">API Hero</a> to connect to GitHub. We can use it directly from our React components, we can safely add authentication, add caching and we'll get API logging built-in as well.</p>
<h2 id="heading-what-is-api-hero">What is API Hero?</h2>
<p>Before we get started, if you aren't familiar with API Hero, you can quickly get up to speed with this 60 second explainer:</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://www.youtube.com/watch?v=nek3WHRUwow">https://www.youtube.com/watch?v=nek3WHRUwow</a></div>
<h1 id="heading-guide">Guide</h1>
<p>It will take about 10 mins to create this app.</p>
<h2 id="heading-1-setting-up-the-project">1. Setting up the project</h2>
<p>Let's create our Next.js app first:</p>
<pre><code class="lang-sh">npx create-next-app@latest --ts
</code></pre>
<p>It will ask you to name your project. I went with <code>github-user-repos</code>. It's worth noting that the <code>--ts</code> flag creates a TypeScript project.</p>
<h2 id="heading-2-installing-dependencies">2. Installing dependencies</h2>
<p>Open the project in your preferred code editor and get a terminal in the project directory.</p>
<p>I use VSCode with their built-in terminal 💯</p>
<p>Install the packages:</p>
<pre><code class="lang-sh">npm i
</code></pre>
<h2 id="heading-3-add-api-hero-and-the-github-integration">3. Add API Hero and the GitHub integration</h2>
<p>We're going to use the API Hero Command Line Tool (CLI) to add everything we need. This will take 30 seconds.</p>
<h3 id="heading-a-run-the-cli">a) Run the CLI</h3>
<pre><code class="lang-sh">npx apihero@latest add github
</code></pre>
<p>It will probably ask your permission to install the <code>apihero</code> package, type <code>y</code> and hit enter.</p>
<h3 id="heading-b-login">b) Login</h3>
<p>Next you'll need to login to connect the Command Line Tool by clicking the link
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1663933931044/VKnpFGpKz.png" alt="API Hero CLI login" /></p>
<p>Login using GitHub and you should see that you've been successfully authenticated.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1663934324129/HKslVHOvU.png" alt="Successfully authenticated" /></p>
<h3 id="heading-c-select-github-and-name-your-project">c) Select GitHub and name your project</h3>
<p>Go back to your terminal and select the GitHub API and hit return.
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1663934380229/v7DnDY9UP.png" alt="Select GitHub" /></p>
<p>You will be asked to create a new workspace and project by giving them a name. </p>
<h3 id="heading-d-select-the-react-package">d) Select the "React" package</h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1663949531917/bBcGEamwN.png" alt="Choose the &quot;React&quot; package" /></p>
<p>Hopefully you now see the instructions in the CLI. This means we're done.
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1663939810045/4jp-ZCtIz.png" alt="CLI instructions" /></p>
<h2 id="heading-4-run-the-site">4. Run the site</h2>
<pre><code class="lang-sh">npm run dev
</code></pre>
<p>It's not a masterpiece… yet.
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1663933304137/gzFngiC_1.png" alt="The default Next.js site" /></p>
<h2 id="heading-5-adding-the-api-hero-provider">5. Adding the API Hero provider</h2>
<p>We need to wrap the root component with the API Hero provider. Make sure to use your project key, which was in the CLI instructions. You can also find it by opening <a target="_blank" href="https://app.apihero.run">this page</a> and selecting your project from the side-menu.</p>
<p>Your <code>_app.tsx</code> file should be changed to this:</p>
<pre><code class="lang-typescript"><span class="hljs-comment">//_app.tsx</span>
<span class="hljs-keyword">import</span> <span class="hljs-string">"../styles/globals.css"</span>;
<span class="hljs-keyword">import</span> <span class="hljs-keyword">type</span> { AppProps } <span class="hljs-keyword">from</span> <span class="hljs-string">"next/app"</span>;
<span class="hljs-comment">// 1. add this import</span>
<span class="hljs-keyword">import</span> { APIHeroProvider } <span class="hljs-keyword">from</span> <span class="hljs-string">"@apihero/react"</span>;

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">MyApp</span>(<span class="hljs-params">{ Component, pageProps }: AppProps</span>) </span>{
  <span class="hljs-comment">// 2. The &lt;Component /&gt; is now wrapped with the &lt;APIHeroProvider&gt;.</span>
  <span class="hljs-keyword">return</span> (
    &lt;APIHeroProvider projectKey=<span class="hljs-string">"your-project-key-here"</span>&gt;
      &lt;Component {...pageProps} /&gt;
    &lt;/APIHeroProvider&gt;
  );
}

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> MyApp;
</code></pre>
<h2 id="heading-6-add-css">6. Add CSS</h2>
<p>This project uses CSS modules. Change <code>Home.module.css</code> to this:</p>
<pre><code class="lang-css">// <span class="hljs-selector-tag">Home</span><span class="hljs-selector-class">.module</span><span class="hljs-selector-class">.css</span>
<span class="hljs-selector-class">.container</span> {
  <span class="hljs-attribute">padding</span>: <span class="hljs-number">0</span> <span class="hljs-number">2rem</span>;
}

<span class="hljs-selector-class">.main</span> {
  <span class="hljs-attribute">min-height</span>: <span class="hljs-number">100vh</span>;
  <span class="hljs-attribute">padding</span>: <span class="hljs-number">4rem</span> <span class="hljs-number">0</span>;
  <span class="hljs-attribute">flex</span>: <span class="hljs-number">1</span>;
  <span class="hljs-attribute">display</span>: flex;
  <span class="hljs-attribute">flex-direction</span>: column;
  <span class="hljs-attribute">justify-content</span>: start;
  <span class="hljs-attribute">align-items</span>: center;
}

<span class="hljs-selector-class">.header</span> {
  <span class="hljs-attribute">width</span>: <span class="hljs-number">100%</span>;
  <span class="hljs-attribute">display</span>: flex;
  <span class="hljs-attribute">justify-content</span>: center;
}

<span class="hljs-selector-class">.input</span> {
  <span class="hljs-attribute">padding</span>: <span class="hljs-number">16px</span>;
  <span class="hljs-attribute">border-radius</span>: <span class="hljs-number">6px</span>;
  <span class="hljs-attribute">border</span>: <span class="hljs-number">1px</span> solid <span class="hljs-number">#eaeaea</span>;
  <span class="hljs-attribute">background</span>: <span class="hljs-number">#000</span>;
  <span class="hljs-attribute">font-size</span>: <span class="hljs-number">2rem</span>;
  <span class="hljs-attribute">min-width</span>: <span class="hljs-number">70%</span>;
}

<span class="hljs-selector-class">.grid</span> {
  <span class="hljs-attribute">display</span>: grid;
  <span class="hljs-attribute">grid-template-columns</span>: <span class="hljs-built_in">repeat</span>(<span class="hljs-number">2</span>, <span class="hljs-number">1</span>fr);
  <span class="hljs-attribute">gap</span>: <span class="hljs-number">10px</span>;
  <span class="hljs-attribute">max-width</span>: <span class="hljs-number">800px</span>;
  <span class="hljs-attribute">margin</span>: <span class="hljs-number">24px</span>;
  <span class="hljs-attribute">min-height</span>: <span class="hljs-number">0</span>;
  <span class="hljs-attribute">min-width</span>: <span class="hljs-number">0</span>;
}

<span class="hljs-selector-class">.card</span> {
  <span class="hljs-attribute">padding</span>: <span class="hljs-number">1.5rem</span>;
  <span class="hljs-attribute">text-align</span>: left;
  <span class="hljs-attribute">color</span>: inherit;
  <span class="hljs-attribute">text-decoration</span>: none;
  <span class="hljs-attribute">border</span>: <span class="hljs-number">1px</span> solid <span class="hljs-number">#eaeaea</span>;
  <span class="hljs-attribute">border-radius</span>: <span class="hljs-number">10px</span>;
  <span class="hljs-attribute">transition</span>: color <span class="hljs-number">0.15s</span> ease, border-color <span class="hljs-number">0.15s</span> ease;
  <span class="hljs-attribute">overflow</span>: hidden;
  <span class="hljs-attribute">overflow-wrap</span>: break-word;
  <span class="hljs-attribute">min-width</span>: <span class="hljs-number">0</span>;
}

<span class="hljs-selector-class">.card</span><span class="hljs-selector-pseudo">:hover</span>,
<span class="hljs-selector-class">.card</span><span class="hljs-selector-pseudo">:focus</span>,
<span class="hljs-selector-class">.card</span><span class="hljs-selector-pseudo">:active</span> {
  <span class="hljs-attribute">color</span>: <span class="hljs-number">#0070f3</span>;
  <span class="hljs-attribute">border-color</span>: <span class="hljs-number">#0070f3</span>;
}

<span class="hljs-selector-class">.card</span> <span class="hljs-selector-tag">h2</span> {
  <span class="hljs-attribute">margin</span>: <span class="hljs-number">0</span> <span class="hljs-number">0</span> <span class="hljs-number">1rem</span> <span class="hljs-number">0</span>;
  <span class="hljs-attribute">font-size</span>: <span class="hljs-number">1.5rem</span>;
}

<span class="hljs-selector-class">.card</span> <span class="hljs-selector-tag">p</span> {
  <span class="hljs-attribute">margin</span>: <span class="hljs-number">0</span>;
  <span class="hljs-attribute">font-size</span>: <span class="hljs-number">1rem</span>;
  <span class="hljs-attribute">line-height</span>: <span class="hljs-number">1.5</span>;
  <span class="hljs-attribute">color</span>: <span class="hljs-number">#ccc</span>;
}

<span class="hljs-selector-tag">p</span><span class="hljs-selector-class">.star</span> {
  <span class="hljs-attribute">color</span>: <span class="hljs-number">#f0c14b</span>;
}

<span class="hljs-keyword">@media</span> (<span class="hljs-attribute">max-width:</span> <span class="hljs-number">600px</span>) {
  <span class="hljs-selector-class">.grid</span> {
    <span class="hljs-attribute">width</span>: <span class="hljs-number">100%</span>;
    <span class="hljs-attribute">grid-template-columns</span>: <span class="hljs-number">1</span>fr;
  }
}
</code></pre>
<h2 id="heading-7-create-the-search-field">7. Create the search field</h2>
<pre><code class="lang-ts"><span class="hljs-comment">// index.tsx</span>
<span class="hljs-keyword">import</span> <span class="hljs-keyword">type</span> { NextPage } <span class="hljs-keyword">from</span> <span class="hljs-string">"next"</span>;
<span class="hljs-keyword">import</span> Head <span class="hljs-keyword">from</span> <span class="hljs-string">"next/head"</span>;
<span class="hljs-keyword">import</span> { useState } <span class="hljs-keyword">from</span> <span class="hljs-string">"react"</span>;
<span class="hljs-keyword">import</span> styles <span class="hljs-keyword">from</span> <span class="hljs-string">"../styles/Home.module.css"</span>;
<span class="hljs-comment">// 1. We will create this file in the next step</span>
<span class="hljs-keyword">import</span> { RepoList } <span class="hljs-keyword">from</span> <span class="hljs-string">"../components/RepoList"</span>;

<span class="hljs-keyword">const</span> Home: NextPage = <span class="hljs-function">() =&gt;</span> {
  <span class="hljs-comment">// 2. This state will be used for the input field, and to perform the API call</span>
  <span class="hljs-keyword">const</span> [username, setUsername] = useState&lt;<span class="hljs-built_in">string</span> | <span class="hljs-literal">undefined</span>&gt;(<span class="hljs-literal">undefined</span>);

  <span class="hljs-keyword">return</span> (
    &lt;div className={styles.container}&gt;
      &lt;Head&gt;
        &lt;title&gt;User’s repositories&lt;/title&gt;
        &lt;meta name=<span class="hljs-string">"description"</span> content=<span class="hljs-string">"User's most popular repositories"</span> /&gt;
        &lt;link rel=<span class="hljs-string">"icon"</span> href=<span class="hljs-string">"/favicon.ico"</span> /&gt;
      &lt;/Head&gt;

      &lt;main className={styles.main}&gt;
        &lt;header className={styles.header}&gt;
           {<span class="hljs-comment">/* 3. We use the username state in the normal React way */</span>}
          &lt;input
            <span class="hljs-keyword">type</span>=<span class="hljs-string">"text"</span>
            value={username}
            onChange={<span class="hljs-function">(<span class="hljs-params">e</span>) =&gt;</span> setUsername(e.target.value)}
            className={styles.input}
            placeholder=<span class="hljs-string">"Enter a GitHub username"</span>
          /&gt;
        &lt;/header&gt;

        {<span class="hljs-comment">/* 4. The RepoList component is where the magic happens */</span>}
        {username &amp;&amp; &lt;RepoList username={username} /&gt;}
      &lt;/main&gt;
    &lt;/div&gt;
  );
};

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> Home;
</code></pre>
<h2 id="heading-8-create-the-repolist-component">8. Create the RepoList component</h2>
<p>Create a new file: <code>components/RepoList.tsx</code></p>
<pre><code class="lang-ts"><span class="hljs-comment">// components/RepoList.tsx</span>
<span class="hljs-comment">// 1. This function is used to create a React Hook for an API endpoint</span>
<span class="hljs-keyword">import</span> { createEndpoint } <span class="hljs-keyword">from</span> <span class="hljs-string">"@apihero/react"</span>;
<span class="hljs-comment">// 2. "repos" is a group of endpoints. We're going to use "listForUser" from it</span>
<span class="hljs-keyword">import</span> { repos } <span class="hljs-keyword">from</span> <span class="hljs-string">"@apihero/github"</span>;
<span class="hljs-keyword">import</span> styles <span class="hljs-keyword">from</span> <span class="hljs-string">"../styles/Home.module.css"</span>;

<span class="hljs-comment">// 3. We create a React Hook for the "listForUser" endpoint,</span>
<span class="hljs-comment">//    outside of the component so it's only created once</span>
<span class="hljs-keyword">const</span> useRepoList = createEndpoint(repos.listForUser);

<span class="hljs-keyword">export</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">RepoList</span>(<span class="hljs-params">{ username }: { username: <span class="hljs-built_in">string</span> }</span>) </span>{
  <span class="hljs-comment">// 4. The hook has type-safe inputs and outputs</span>
  <span class="hljs-comment">//    "data" is the response on success, with the correct type</span>
  <span class="hljs-comment">//    "status" is the status of the request: "loading", "error" or "success"</span>
  <span class="hljs-comment">//    "error" is the error object if there is an error</span>
  <span class="hljs-comment">//    TypeScript will force you to pass in the correct inputs, username in this case is required</span>
  <span class="hljs-keyword">const</span> { data, status, error } = useRepoList({
    username,
    <span class="hljs-keyword">type</span>: <span class="hljs-string">"owner"</span>,
    perPage: <span class="hljs-number">100</span>,
  });

  <span class="hljs-keyword">return</span> (
    &lt;&gt;
      {<span class="hljs-comment">/* 5. We can use the status to show a loading indicator, an error message, or the data */</span>}
      {status === <span class="hljs-string">"loading"</span> ? (
        &lt;img
          src=<span class="hljs-string">"https://media.giphy.com/media/VseXvvxwowwCc/giphy.gif"</span>
          alt=<span class="hljs-string">"Loading"</span>
          width=<span class="hljs-string">"150px"</span>
          height=<span class="hljs-string">"150px"</span>
        /&gt;
      ) : status === <span class="hljs-string">"error"</span> ? (
        &lt;div&gt;
          &lt;img
            src=<span class="hljs-string">"https://media.giphy.com/media/Nrzs481LzLEdy/giphy.gif"</span>
            alt=<span class="hljs-string">"Error"</span>
          /&gt;
        &lt;/div&gt;
      ) : (
        &lt;div className={styles.grid}&gt;
          {<span class="hljs-comment">/* 6. The data is an array of repositories, we sort them so the most popular ones are first */</span>}
          {data
            .sort(
              <span class="hljs-function">(<span class="hljs-params">a, b</span>) =&gt;</span> (b.stargazers_count ?? <span class="hljs-number">0</span>) - (a.stargazers_count ?? <span class="hljs-number">0</span>)
            )
            .map(<span class="hljs-function">(<span class="hljs-params">item</span>) =&gt;</span> (
              <span class="hljs-comment">// 7. Each repository is a card with a link to the repository and some basic info</span>
              &lt;a
                key={item.id}
                href={item.html_url}
                className={styles.card}
                target=<span class="hljs-string">"_blank"</span>
                rel=<span class="hljs-string">"noreferrer"</span>
              &gt;
                &lt;h2&gt;{item.full_name}&lt;/h2&gt;
                &lt;p className={styles.star}&gt;⭐️ {item.stargazers_count}&lt;/p&gt;
                &lt;p&gt;{item.description}&lt;/p&gt;
              &lt;/a&gt;
            ))}
        &lt;/div&gt;
      )}
    &lt;/&gt;
  );
}
</code></pre>
<p>When hovering over the hook you'll notice what inputs are required and in what format. This makes it really easy to get something working.
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1663951369657/vqsE63CSF.png" alt="Type-safe inputs" /></p>
<h2 id="heading-9-it-works">9. It works!</h2>
<p>When you type in a GitHub username or GitHub organisation name you will see their top public repositories.
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1663951472697/TAwx8sZt9.png" alt="Vercel's top public repositories" /></p>
<h2 id="heading-10-lets-look-at-the-requests-and-responses-in-api-hero">10. Let's look at the requests and responses in API Hero</h2>
<p>Go to <a target="_blank" href="https://app.apihero.run">your dashboard</a> and then select your project.</p>
<p>Notice how GitHub and the <code>List repositories for a user</code> has automatically appeared.
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1663951583726/YRK6UdcOr.png" alt="List repositories for a user endpoint" /></p>
<p>Click into <code>List repositories for a user</code> and you'll see the history of web requests:
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1663951678156/wxsHRIWZc.png" alt="Request history" /></p>
<p>You can select any of them and view the full details of both the request and response.</p>
<h2 id="heading-10-rate-limits">10. Rate limits</h2>
<p>A common problem when using APIs is hitting the rate limit. A rate limit is a maximum number of API requests you are allowed to do within a certain time frame.</p>
<p>GitHub allows 60 API requests per hour, which means you'll very quickly get errors appearing if you play with the site you've built. You don't need to launch it to have these problems, I started experiencing them after a few minutes looking up some of my favourite developer tools companies.</p>
<p>In the Request History you can see this problem clearly:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1663951938674/d6wS9bo1q.png" alt="Rate limiting" /></p>
<p>I have <code>0/60</code> requests left and will have to wait until 5:37pm until I get more.</p>
<p>Clearly we can't launch like this.</p>
<h2 id="heading-11-add-authentication-to-increase-your-rate-limit">11. Add authentication to increase your rate limit</h2>
<p>You can add authentication in 1 minute, increasing your rate limit.</p>
<p>Go back to your project page and click the "Add authentication" button.
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1663952102534/wjtg9ncgQ.png" alt="Add authentication" /></p>
<p>We're going to add a Personal Access Token, first we need to create one on GitHub: </p>
<ol>
<li>Go to the <a target="_blank" href="https://github.com/settings/tokens">tokens page</a></li>
<li>Select "Generate a new token"</li>
<li>Name it and select the expiry</li>
<li>Don't tick any of the scopes for this token. All the information is public. You should be careful when enabling scopes.</li>
<li>Press "Generate token"</li>
<li>Click the token to copy it to your clipboard</li>
</ol>
<p>Now all we need to do is fill in the form back on API Hero. Use your GitHub username and the token you just copied.
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1663954743330/0aPtY_kzQ.png" alt="Fill in the personal access token" /></p>
<p>The next time you look up a user's repositories the rate limit will be higher. You can view it in the request history:
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1663954828132/Gjm0Jh-1i.png" alt="Higher rate limit after authentication" /></p>
<h2 id="heading-12-adding-caching">12. Adding caching</h2>
<p>5000 API calls per hour is quite a high rate limit. But it still won't be enough if the site was to get a lot of traffic.</p>
<p>We can make the site very scalable with the flick of a switch.</p>
<p>Go back to the project page, turn caching on, set the duration to 3600 seconds (one hour) and save.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1663955035046/cFfB2Mqzy.png" alt="Caching is on" /></p>
<p>API calls for the same username will now be cached for one hour, so they won't count against your rate limit. You can see this in the request history:
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1663955099123/nZT2qmGJC.png" alt="Caching is working" /></p>
<h1 id="heading-wrapping-up">Wrapping up</h1>
<p>You should now be able to create a Next.js app from scratch, integrate the GitHub API and make the site scalable.</p>
<p>View the <a target="_blank" href="https://github.com/apihero-run/github-user-repos">final source code</a>.</p>
<p>Find out more about <a target="_blank" href="https://apihero.run">API Hero</a></p>
]]></content:encoded></item><item><title><![CDATA[Introducing API Hero: integrate popular APIs in seconds and scale without servers]]></title><description><![CDATA[6 months ago we released JSON Hero, in a bid to 10x the experience of JSON files over conventional methods. Today we're releasing API Hero, in a bid to 10x…]]></description><link>https://blog.apihero.run/introducing-api-hero</link><guid isPermaLink="true">https://blog.apihero.run/introducing-api-hero</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[TypeScript]]></category><category><![CDATA[React]]></category><category><![CDATA[Node.js]]></category><category><![CDATA[APIs]]></category><dc:creator><![CDATA[Eric Allam]]></dc:creator><pubDate>Thu, 22 Sep 2022 13:22:31 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1663335105821/2fnndILCA.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-api-hero-in-60-seconds">API Hero in 60 seconds</h2>
<p>6 months ago we released JSON Hero, in a bid to 10x the experience of JSON files over conventional methods. </p>
<p>Today we're releasing <a target="_blank" href="https://apihero.run">API Hero</a>, in a bid to 10x the experience of integrating APIs into the frameworks you know and love, starting with React.</p>
<p>We think we can accomplish this goal by not just shipping better client-side libraries, but pairing a client-side library with a cloud service (think API gateway) and making them work great together. With this combination, we can solve the following painful parts of working with a 3rd-party API:</p>
<ul>
<li>Viewing and monitoring requests &amp; responses 🔎</li>
<li>No more "429 Too Many Requests" errors (👋🏼 server-side caching)</li>
<li>No more CORS errors 😱</li>
<li>Securely store API keys in the cloud 🔐</li>
<li>Retry requests or queue them up to prevent rate-limiting🚦</li>
<li>Get all results from a paginated endpoint, without recursive boilerplate </li>
<li>Type-safe responses and errors</li>
<li>Endpoint search and superior documentation 🕵️‍♀️</li>
<li>And many more (OAuth, fine-grained ACL, rotating credentials, etc.)</li>
</ul>
<p>We've put together this "API Hero in 60 seconds" video as a quick breakdown of what we've built so far:</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://www.youtube.com/watch?v=nek3WHRUwow">https://www.youtube.com/watch?v=nek3WHRUwow</a></div>
<h2 id="heading-show-me-the-code">Show me the code</h2>
<p>Let's speed run a React application that connects to the GitHub API and displays a repository's star count:</p>
<h4 id="heading-run-the-api-hero-cli">Run the API Hero CLI</h4>
<p>Add the API Hero &amp; the GitHub integration to your React project and follow the prompts:</p>
<pre><code class="lang-bash">npx apihero@latest add GitHub
</code></pre>
<h4 id="heading-add-the-apiheroprovider">Add the ApiHeroProvider</h4>
<p>Add the <code>ApiHeroProvider</code> component to the top of your component tree, providing the <code>projectKey</code> prop printing out in the previous step. For Next.js you could update <code>pages/_app.tsx</code> to be the following</p>
<pre><code class="lang-jsx"><span class="hljs-comment">// other imports here</span>
<span class="hljs-keyword">import</span> { ApiHeroProvider } <span class="hljs-keyword">from</span> <span class="hljs-string">"@apihero/react"</span>;

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">MyApp</span>(<span class="hljs-params">{ Component, pageProps }: AppProps</span>) </span>{
  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">ApiHeroProvider</span> <span class="hljs-attr">projectKey</span>=<span class="hljs-string">"&lt;projectKey&gt;"</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">Component</span> {<span class="hljs-attr">...pageProps</span>} /&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">ApiHeroProvider</span>&gt;</span>
  );
}

export default MyApp;</span>
</code></pre>
<h4 id="heading-export-an-endpoint-hook">Export an endpoint hook</h4>
<pre><code class="lang-jsx"><span class="hljs-keyword">import</span> { repos } <span class="hljs-keyword">from</span> <span class="hljs-string">"@apihero/github"</span>;
<span class="hljs-keyword">import</span> { createEndpoint } <span class="hljs-keyword">from</span> <span class="hljs-string">"@apihero/react"</span>;

<span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> useGetRepository = createEndpoint(repos.getRepo);
</code></pre>
<h4 id="heading-use-the-endpoint-hook">Use the endpoint hook</h4>
<pre><code class="lang-jsx"><span class="hljs-keyword">export</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">StarCount</span>(<span class="hljs-params">{ owner, repo }: { owner: string; repo: string }</span>) </span>{
  <span class="hljs-keyword">const</span> { data, status, error } = useGetRepository({
    owner,
    repo,
  });

  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;&gt;</span>
      {status === "loading" ? (
        <span class="hljs-tag">&lt;<span class="hljs-name">Spinner</span> /&gt;</span>
      ) : status === "error" ? (
        <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Oops, repo {error.message.toLowerCase()}<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
      ) : (
        <span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span>{data.stargazers_count} stars<span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span>
      )}
    <span class="hljs-tag">&lt;/&gt;</span></span>
  );
}
</code></pre>
<p>Because <code>repos.getRepo</code> contains the TypeScript types for the endpoint, using the <code>useGetRepository</code> hook presents helpful typed suggestions for the props:</p>
<p><img src="https://docs.apihero.run/assets/images/useGetRepositoryTypes-16d5c86b8ecc9ab951a9c6b4f37972c9.png" alt="useGetRepository prop types" /></p>
<p>And the response body:</p>
<p><img src="https://docs.apihero.run/assets/images/stargazers_count-5356a9cb398bb5a5ec74232c77385d4a.png" alt="useGetRepository response body types" /></p>
<h4 id="heading-inspect-the-request-in-api-hero">Inspect the request in API Hero:</h4>
<p>After running your React app and using the StarCount component, head over to <code>app.apihero.run</code> and inspect the request in the Request History:</p>
<p><img src="https://docs.apihero.run/assets/images/nodeLogs-cd59c0ecd8d5067782ede82a788d97f0.png" alt="request history" /></p>
<p>Next you'll probably want to add <a target="_blank" href="https://docs.apihero.run/features/authentication">Authentication</a> and <a target="_blank" href="https://docs.apihero.run/features/caching">Caching</a>, which you can now do without changing a single line of code!</p>
<h2 id="heading-how-does-it-work">How does it work?</h2>
<p>API Hero is a collection of technologies that are all designed to work together</p>
<h3 id="heading-frontend">Frontend</h3>
<p>The API Hero frontend is where you'll go to signup and configure your integrations, adding authentication, caching, additional headers, monitoring, alerts, and more. It's also where you can inspect your request history, with powerful filtering capabilities:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1663849027986/TOHW_o7ZE.png" alt="CleanShot 2022-09-22 at 13.16.58.png" /></p>
<h3 id="heading-api-gateway">API Gateway</h3>
<p>Using information via the frontend, the gateway can augment requests from clients with caching, authentication, and more. Additionally the gateway validates requests and responses, making sure they conform to the JSON schema defined by the API integration. </p>
<h3 id="heading-client-integrations">Client integrations</h3>
<p>We've written a custom Open API spec generator to create the types and data required by a specific integration.  Each integration is deployed as it's own npm package. They really are just a <a target="_blank" href="https://github.com/apihero-run/github/blob/main/src/repos.ts#L449">bunch of types</a> along with a unique ID per endpoint to identify them in our gateway:</p>
<pre><code class="lang-ts">* Get a repository
* The <span class="hljs-string">`parent`</span> and <span class="hljs-string">`source`</span> objects are present when the repository is a fork. <span class="hljs-string">`parent`</span> is the repository <span class="hljs-built_in">this</span> repository was forked <span class="hljs-keyword">from</span>, <span class="hljs-string">`source`</span> is the ultimate source <span class="hljs-keyword">for</span> the network.
* <span class="hljs-meta">@param</span> owner - The account owner <span class="hljs-keyword">of</span> the repository. The name is not <span class="hljs-keyword">case</span> sensitive.
* <span class="hljs-meta">@param</span> repo - The name <span class="hljs-keyword">of</span> the repository. The name is not <span class="hljs-keyword">case</span> sensitive. 
*/
<span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> getRepo: ApiHeroEndpoint&lt;{ owner: <span class="hljs-built_in">string</span>; repo: <span class="hljs-built_in">string</span> }, FullRepository&gt; = {
  id: <span class="hljs-string">"repos/get"</span>,
  clientId: <span class="hljs-string">"github"</span>,
};
</code></pre>
<h3 id="heading-platform-libraries">Platform libraries</h3>
<p>The code for actually performing requests in your apps are split out into separate platform libraries. We're starting with <a target="_blank" href="https://github.com/apihero-run/apihero-react">React</a> and <a target="_blank" href="https://github.com/apihero-run/apihero-node">Node.js</a>. These libraries are specifically tailored to work well with the platform of your choice (and we plan on adding more soon).</p>
<p>This separation between client integrations and platforms allows us to quickly build new platforms and new client integrations, without having to deal with the combinatorial explosion of including platform specific code in each integration (the sum total lines of code of our platform libraries so far is &lt;200).</p>
<h2 id="heading-why-now">Why now?</h2>
<p>After years of integrating dozens and dozens of 3rd-party APIs, and running into the same few issues that halted our progress, we decided that there must be a better way. 
As we started building more heavily front-end applications (e.g. <a target="_blank" href="https://jsonhero.io">JSON Hero</a>) we found that we just couldn't solve the issues with 3rd-party APIs unless we wrote backend code (rate-limiting, authentication, caching, CORs, etc.).</p>
<p>There are lots of great tools in the API space, but we found most of them targeted API providers and backend developers, and very few catered to the rest of us who just want to use great APIs and build apps quickly. </p>
<p>And with <a target="_blank" href="https://www.openapis.org/">OpenAPI spec</a> becoming more and more popular, it is actually now possible to generate our own (very nice) TypeScript types and clients, as well as the request and response data needed to make and validate requests.</p>
<h2 id="heading-upcoming">Upcoming</h2>
<p>As well as adding more integrations and improving the experience, we're planning on delivering API Hero as a Commercial Open Source project, similar to Supabase and Prisma. That way you can always choose to host and run API Hero yourself, or use our cloud offering if you just want to get started quickly.  We plan on coming out of private beta and open sourcing our code at the same time.</p>
<h2 id="heading-today">Today</h2>
<p>We're starting with a single integration, the <a target="_blank" href="https://docs.github.com/en/rest">GitHub API</a>, that encompasses 878 different endpoints for all your source control needs. We're going deep on this one integration for the next few months, at least, and plan on sticking with it until we're happy with the experience.  We're also launching with two platforms: React and Node.js, with more to come shortly.</p>
<h2 id="heading-join-us">Join us</h2>
<p>Today we're opening API Hero to a select few private beta participants to gather early feedback to help shape the product. We're on a mission to advance the API integration experience of developers, and hopefully make it so simple that developers no longer hesitate to reach for third-party APIs. </p>
<p>Head over to <a target="_blank" href="https://apihero.run">API Hero</a> today and join the mission.</p>
]]></content:encoded></item><item><title><![CDATA[🐣 New Release: the JSON Hero Chrome extension - a different kind of JSON beautifier in your browser]]></title><description><![CDATA[Announcing the new JSON Hero Chrome extension, a different kind of JSON extension that goes beyond beautification, giving you the full power of JSON Hero.]]></description><link>https://blog.apihero.run/announcing-the-json-hero-chrome-extension</link><guid isPermaLink="true">https://blog.apihero.run/announcing-the-json-hero-chrome-extension</guid><category><![CDATA[json]]></category><category><![CDATA[chrome extension]]></category><category><![CDATA[Open Source]]></category><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[Eric Allam]]></dc:creator><pubDate>Mon, 06 Jun 2022 12:51:52 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1654519633538/gxHAUyW7W.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>It's been a little under 2 months since we <a target="_blank" href="https://blog.jsonhero.io/introducing-json-hero">launched</a> JSON Hero and it's been received delightfully by the developer community. It's been visited by over 30k people who've created a total of 31k JSON documents. Our <a target="_blank" href="https://github.com/jsonhero-io/jsonhero-web">GitHub repo</a> has reached 3.3k stars and we've even picked up a few new contributors. </p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://twitter.com/github/status/1519000876714708992">https://twitter.com/github/status/1519000876714708992</a></div>
<p>One of the most requested features since launch has been to provide JSON Hero as a Chrome extension, to improve the experience of viewing a blob of JSON in the browser. </p>
<p>We're happy to announce that our Chrome extension is now available to install from the Chrome web store:</p>
<p>👉👉👉 <a target="_blank" href="https://chrome.google.com/webstore/detail/json-hero/dneionnnnjnofppmhcccbiaklandilch">JSON Hero Chrome extension</a></p>
<h2 id="heading-a-different-kind-of-json-extension">A different kind of JSON extension</h2>
<p>Most <a target="_blank" href="https://chrome.google.com/webstore/detail/json-formatter/bcjindcccaagfpapjjmafapmmgkkhgoa">of</a> <a target="_blank" href="https://chrome.google.com/webstore/detail/json-viewer/gbmdgpbipfallnflgajpaliibnhdgobh">the</a> <a target="_blank" href="https://chrome.google.com/webstore/detail/json-handle/iahnhfdhidomcpggpaimmmahffihkfnj">popular</a> JSON extensions available in Chrome work in a similar way: detect a pure JSON response and rewrite the document to prettify the JSON blob.</p>
<p>The JSON Hero extension takes a different approach: by default it will leave the JSON blob as-is, and only when clicking on the extension icon in the toolbar will it send the JSON to JSON Hero and open it in a new tab:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1654514148427/-Re8jCt1C.gif" alt="JSONHeroChromeActivate.gif" /></p>
<p>You can easily opt-in to automatically viewing JSON blobs with JSON Hero by visiting the extension settings and ticking the "auto-mode" checkbox on.  </p>
<blockquote>
<p><strong>Warning</strong> This will cause any pure JSON responses to be sent to the jsonhero.io service, so please use this feature carefully. If you are running your own instance of JSON Hero, there is also the option of using a Custom Server URL.</p>
</blockquote>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1654514650861/mR79rGXHc.gif" alt="JSONHeroChromeAutoMode.gif" /></p>
<h2 id="heading-more-than-just-json">More than just JSON</h2>
<p>The JSON Hero Chrome extension goes beyond just viewing pure JSON blobs. For <a target="_blank" href="https://firebase.google.com/products/firestore?gclid=CjwKCAjwy_aUBhACEiwA2IHHQENmYOQZy0OYzqSkaTpMAhmJBuFwsLumjMW3mrF8qQIU4sm1Mv_zuBoC81kQAvD_BwE&amp;gclsrc=aw.ds">Firebase Firestore</a> users, we've added a way to send the currently selected Firestore document to JSON Hero (reading complex documents in the Firestore console is a mess):</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1654518572263/G5YH7X3qd.gif" alt="JSONHeroChromeFirestore.gif" /></p>
<p>Browsing files in a GitHub repo and want to preview a JSON file in JSON Hero? We've got you covered:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1654518834584/SWQehkPst.gif" alt="JSONHeroChromeGithub.gif" /></p>
<p>We've even added a way to quickly view the <a target="_blank" href="https://ogp.me/">Open Graph</a> info of any website in JSON Hero:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1654519160077/6V1nmr90l.gif" alt="JSONHeroOpenGraph.gif" /></p>
<h3 id="heading-more-to-come">More to come</h3>
<p>Please <a target="_blank" href="https://chrome.google.com/webstore/detail/json-hero/dneionnnnjnofppmhcccbiaklandilch">install</a> the Chrome extension today and let us know your thoughts and feature ideas on <a target="_blank" href="https://twitter.com/json_hero">Twitter</a> or over in our <a target="_blank" href="https://discord.gg/ZQq6Had5nP">Discord</a>. We'd especially be interested to hear of any more integration opportunities for the extension.</p>
<p>And as always, if you'd like to support us please <a target="_blank" href="https://github.com/jsonhero-io/jsonhero-web">⭐️ us on GitHub</a>.  We've also open-sourced the Chrome extension code <a target="_blank" href="https://github.com/jsonhero-io/chrome-extension">here</a>.</p>
]]></content:encoded></item><item><title><![CDATA[Feature Showcase #1: Related Values]]></title><description><![CDATA[Use JSON Hero's Related Values feature to discover edge cases in your JSON data, and quickly traverse between related paths.]]></description><link>https://blog.apihero.run/feature-showcase-1-related-values</link><guid isPermaLink="true">https://blog.apihero.run/feature-showcase-1-related-values</guid><category><![CDATA[json]]></category><category><![CDATA[features]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[TypeScript]]></category><dc:creator><![CDATA[Eric Allam]]></dc:creator><pubDate>Fri, 13 May 2022 12:30:01 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1652430793057/woeiYkNW0.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<blockquote>
<p>Welcome to the first edition of a weekly showcase of some of the most useful features in <a target="_blank" href="https://jsonhero.io">JSON Hero</a>. Be sure to checkout our <a target="_blank" href="https://blog.jsonhero.io/introducing-json-hero">Introduction to JSON Hero</a> first to find out what it's all about.</p>
</blockquote>
<p>Stop me if this sounds familiar: you are working with JSON data and your code throws a <code>TypeError</code> or maybe you thought the field you are accessing only contains strings but one random instance has a number or array of strings.</p>
<p>Tracking down these types of issues in JSON can be cumbersome.  It doesn't help that this is the type of error message you are presented with:</p>
<pre><code>TypeError: Cannot <span class="hljs-keyword">read</span> properties <span class="hljs-keyword">of</span> <span class="hljs-keyword">null</span> (reading <span class="hljs-string">'toUpperCase'</span>)
</code></pre><h3 id="heading-related-values-to-the-rescue">Related Values to the rescue</h3>
<p>JSON Hero makes finding these edge cases really easy using a feature called Related Values, which displays a grouped list of all other values at the selected path:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1652432912454/9ikpYonJG.png" alt="Screen Shot 2022-05-13 at 10.08.26.png" /></p>
<p>You can also expand each related value and navigate to it's path:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1652433216607/4XUJrX4ic.gif" alt="RelatedValuesOpen.gif" /></p>
<p>Related Values really shines when you are looking for <code>undefined</code> or <code>null</code> values at a specific path:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1652433436877/kqx42fGvz.png" alt="Screen Shot 2022-05-13 at 10.17.03.png" /></p>
<p>As you can see above there are 6 records that don't include the <code>Designer</code> array (and 14 that do).  This works for <code>null</code> values as well:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1652433528248/OroPY4ls9.png" alt="Screen Shot 2022-05-13 at 10.18.33.png" /></p>
<p>It also gives you the ability to quick preview many different values efficiently:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1652433708896/9WCiZBINC.gif" alt="ScreenFlow.gif" /></p>
<h3 id="heading-objects-in-arrays-in-objects-in-arrays">Objects in arrays in objects in arrays</h3>
<p>Related Values comprehensively traverses your JSON to find all possible related values for the currently selected path. For example, let's say you have the following JSON data:</p>
<pre><code class="lang-json">[
  {
    <span class="hljs-attr">"records"</span>: [
      {
        <span class="hljs-attr">"images"</span>: [
          { <span class="hljs-attr">"url"</span>: <span class="hljs-string">"https://i.imgur.com/HJRk15p.jpeg"</span> },
          { <span class="hljs-attr">"url"</span>: <span class="hljs-string">"https://i.imgur.com/SXVRTOW.jpeg"</span> }
        ]
      }
    ]
  },
  {
    <span class="hljs-attr">"records"</span>: [
      {
        <span class="hljs-attr">"images"</span>: [
          { <span class="hljs-attr">"url"</span>: <span class="hljs-string">"https://i.imgur.com/ABSS8nn.jpeg"</span> },
          { <span class="hljs-attr">"url"</span>: <span class="hljs-string">"https://i.imgur.com/sNVVC5i.jpeg"</span> },
          { <span class="hljs-attr">"url"</span>: <span class="hljs-string">"https://i.imgur.com/Gu9v4OW.jpeg"</span> }
        ]
      },
      {
        <span class="hljs-attr">"images"</span>: [
          { <span class="hljs-attr">"url"</span>: <span class="hljs-string">"https://i.imgur.com/U7zFOe9.jpeg"</span> }
        ]
      }
    ]
  }
]
</code></pre>
<blockquote>
<p>You can test this out on JSON Hero <a target="_blank" href="https://jsonhero.io/j/kpfinxlP0i2z?path=%24.0.records.0.images.0.url">here</a></p>
</blockquote>
<p>When you select <code>$.0.records.0.images.0.url</code> you will see all 6 other Related Values because we basically "wildcard" the array parts (i.e. <code>$.*.records.*.images.*.url</code>).:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1652434573040/r3BBJsy2D.png" alt="Screen Shot 2022-05-13 at 10.36.02.png" /></p>
<blockquote>
<p>If you liked this feature please <a target="_blank" href="https://github.com/jsonhero-io/jsonhero-web">give us a ⭐️ on GitHub</a>, or let us know what you think by reaching us on <a target="_blank" href="https://twitter.com/json_hero">Twitter</a> or <a target="_blank" href="https://discord.gg/ZQq6Had5nP">Discord</a>.</p>
</blockquote>
]]></content:encoded></item><item><title><![CDATA[Introducing JSON Hero: an open-source, beautiful JSON viewer for the web that lets you browse, search and navigate your JSON files at speed. 🚀]]></title><description><![CDATA[Programming on the web in 2022: So we set out to create a new tool to make reading and understanding JSON easier and more efficient than a Wall-O-Text…]]></description><link>https://blog.apihero.run/introducing-json-hero</link><guid isPermaLink="true">https://blog.apihero.run/introducing-json-hero</guid><category><![CDATA[json]]></category><category><![CDATA[introduction]]></category><category><![CDATA[ShowHashnode]]></category><category><![CDATA[Open Source]]></category><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[Eric Allam]]></dc:creator><pubDate>Fri, 22 Apr 2022 13:33:08 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1650628276956/sHWSA0GZD.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Programming on the web in 2022:</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://twitter.com/tlakomy/status/1491049739978436612">https://twitter.com/tlakomy/status/1491049739978436612</a></div>
<p>So we set out to create a new tool to make reading and understanding JSON easier and more efficient than a Wall-O-Text:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1650628468309/6pVji7mEs.png" alt="brandbird (8).png" /></p>
<p>It's too easy to get lost in a deeply nested document, and you end up having to resort to   manually collapsing parts of the hierarchy so you can more easily focus on subset of the JSON you care about. Unfortunately, this makes comparing related values difficult and time consuming.</p>
<p>The macOS Finder solves some of these issues by providing a handy Column View</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1650618949807/hg8lnmXnM.png" alt="Screen Shot 2022-04-22 at 10.15.45.png" /></p>
<p>If we apply those same principles to a JSON document, it might look something like this:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1650619091762/R5qXB8_7Y.gif" alt="features-columnview.gif" /></p>
<p>It has all the features you'd expect: keyboard navigation, path bar, history. Try it now on <a target="_blank" href="https://jsonhero.io">jsonhero.io</a></p>
<p>It also has a nifty feature that allows you to "hold" a descendent selected and travel up through the hierarchy, and then move between siblings and view the different values found at that path. It's hard to describe, but here is an animation to help demonstrate:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1650619153895/w06qOpZ74.gif" alt="features-traversewithcontext.gif" /></p>
<h4 id="heading-the-smart-preview-pane">The smart preview pane</h4>
<p>We built a preview pane that displays more information about the current selection. It can automatically infer the content of the selected item and give you intelligent previews for dates and times, websites, tweets, youtube videos, colors, and more:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1650619546686/psl7vbgQM.png" alt="features-preview-imageurls.png" /></p>
<h4 id="heading-related-values">Related values</h4>
<p>Easily see all the related values across your entire JSON document for a specific field, including any undefined or null values:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1650619605026/syKnQznnl.gif" alt="features-relatedvalues.gif" /></p>
<h4 id="heading-search-everything">Search everything</h4>
<p>Looking for something specific? Use <code>CMD+K</code> and quickly pull up the fuzzy search palette. Search for object keys, paths, values, and even formatted values (e.g. searching for "Dec" will find "2021-12-01T13:56:12Z")</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1650619698077/KLZhq6_d1.gif" alt="features-search.gif" /></p>
<h4 id="heading-keeping-with-tradition">Keeping with tradition</h4>
<p>Column view might not be the right view for all occasions, so we built a classic JSON tree view as well</p>
<p><img src="https://raw.githubusercontent.com/jsonhero-io/documentation-hosting/main/images/features-treeview.gif" alt="Tree View" /></p>
<p>We built this tree view from the ground-up to be fast and scale to large documents, making use of the great <a target="_blank" href="https://github.com/TanStack/react-virtual">react-virtual</a> project to ensure buttery-smooth scrolling. It's also a <a target="_blank" href="https://www.w3.org/TR/wai-aria-practices-1.1/examples/treeview/treeview-2/treeview-2a.html">ARIA-compliant</a> tree view and has all the keyboard shortcuts you'd expect for quickly traversing and collapsing/expanding content.</p>
<p>We also included a <a target="_blank" href="https://codemirror.net/6/">CodeMirror 6</a>-powered editor that keeps the nice previews and related values you get from the sidebar as you move around the document:</p>
<p><img src="https://raw.githubusercontent.com/jsonhero-io/documentation-hosting/main/images/features-editorview.gif" alt="Editor View" /></p>
<h4 id="heading-automatically-inferred-json-schema">Automatically inferred JSON Schema</h4>
<p>Get a head-start on creating a JSON Schema document from your JSON using our automatically inferred schema generator, powered by <a target="_blank" href="https://github.com/jsonhero-io/schema-infer">@jsonhero/schema-infer</a>:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1650620957623/fwCkUrXxF.png" alt="Screen Shot 2022-04-22 at 10.48.31.png" /></p>
<h4 id="heading-sharing-is-caring">Sharing is caring</h4>
<p>Easily share the link to your JSON and even link to a specific part of the document</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1650621075929/3td6K9XW_.png" alt="Screen Shot 2022-04-22 at 10.50.16.png" /></p>
<blockquote>
<p>IMPORTANT: Anyone who has the URL to your JSON will be able to view it, and all of JSON Hero is public. If you are using jsonhero.io, your data is stored in Cloudflare KV. </p>
</blockquote>
<h4 id="heading-100-open-source">100% Open Source</h4>
<p>If you'd like to contribute or run JSON Hero yourself, feel free to join us on our <a target="_blank" href="https://github.com/jsonhero-io/jsonhero-web">GitHub</a>. JSON Hero is a <a target="_blank" href="https://remix.run">remix</a> React app that runs on <a target="_blank" href="https://workers.cloudflare.com/">Cloudflare Workers</a>, written in Typescript. </p>
<p>👉 Please give us a star on <a target="_blank" href="https://github.com/jsonhero-io/jsonhero-web">GitHub</a> to get the latest updates 🌟</p>
]]></content:encoded></item></channel></rss>