TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: How do you document a REST API?

2 pointsby fifthofhisnameover 3 years ago
Be it a work, side project or personal REST API - how do you document it for the public to consume?<p>How do you manage multiple documentation pages if parts are separated (e.g. public vs. internal) or paywalled (e.g. free, paid, premium)?

1 comment

Jemaclusover 3 years ago
I typically start with OAS or Swagger[1] and define the API spec in YAML or JSON and then generate documentation based on that. There are a bajillion Swagger doc generators that can make things really pretty, such as Spectacle[2], which I&#x27;ve used in the past.<p>I wouldn&#x27;t try to roll your own, unless you want to pursue that as an educational exercise.<p>As far as splitting it up for public vs internal, I&#x27;d just have two separate repositories for the data. You should ideally be dogfooding your own APIs, so most of your APIs should be in the public area. If you namespace your APIs appropriately, you could have Nginx or Apache rules to block public access to certain URLs, such as &#x2F;internal.<p>[1] <a href="https:&#x2F;&#x2F;swagger.io&#x2F;specification&#x2F;" rel="nofollow">https:&#x2F;&#x2F;swagger.io&#x2F;specification&#x2F;</a> [2] <a href="https:&#x2F;&#x2F;github.com&#x2F;sourcey&#x2F;spectacle" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;sourcey&#x2F;spectacle</a>