Live data from Hacker News

Ask HN: What's the best way to write an API spec?

news.ycombinator.com

11–20 of 58 posts

Re: Ask HN: What's the best way to write an API spec?

#11
post #8

There have been an explosion of API specification formats in the last few years. No clear winner has emerged. JSON Schema and JSON Hyperschema are JSON-based formats for describing JSON and REST (hypermedia-driven) APIs. The formats make decent sense and can be used to generate docs, validators, client libraries, UIs, and more. http://json-schema.org/ API Blueprint is another emerging format for API description. It's…

[deleted]

Re: Ask HN: What's the best way to write an API spec?

#13
post #5

I guess I'll take this opportunity to plug my own little tool for this. I use Swagger [1] and more specifically Swagger UI [2] to generate interactive web-based documentation like the sample at [3]. But rather than relying upon source code annotations to have swagger auto-generate the documentation, or hand-writing swagger's verbose JSON structure, I created a little DSL for it as demonstrated at [4] and available on…

This is really cool. Thanks for sharing that!

Re: Ask HN: What's the best way to write an API spec?

#16
I used apiary.io which is the best tool I've found for writing API specs. You can write your specs using an online API Blueprint format editor via their site. Alternatively, you can put a text file in your repo and authorize apiary to pull the file every time you make a commit to github. This way you do everything via your development environment.

The documentation they provide based on the specs looks very well designed and intuitive.

One of my favorite features about apiary was the mock backend server they use based on my API specs. So if you're doing a single page app, just write your specs then point your frontend app to the mock server they provide. This greatly simplified development process for me.

Re: Ask HN: What's the best way to write an API spec?

#17
After working on a couple API's used by mobile devices I would recommend starting with some static pages containing JSON, then write a client against them first. That will help verify that you have all of the needed data and the format is correct.

Once the format is nailed down it's easier to write documentation, and the server side code will go quickly because less time is spent iterating changes.

Re: Ask HN: What's the best way to write an API spec?

#20
I've really liked using Apiary http://apiary.io/ It lets you build sample output and URI address for your API's, document multiple routes, and stores everything nicely on your account on their cloud. I've used it for 2 projects this year already and have really liked it.
Post reply on HN