Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Standard methods for documenting a RESTful API [closed]

I'm writing a specification for a RESTful API for a new internal web service. It's not hugely long and fairly simple, but even so, it's my first time using strict REST (as opposed to cheating for practical reasons - avoiding PUT and DELETE because they're a pain in PHP, and so on). I was wondering if there were any standard methods or best practices for documenting a REST interface? I want the rest of the team to understand it at a glance, and for anyone that wants to write a client to be able to do so without understanding the underlying code.

like image 859
Samir Talwar Avatar asked May 22 '09 15:05

Samir Talwar


People also ask

How can RESTful Apis be documented?

Write in a writing tool Write as much as possible in a format that's designed for writing. “Writing documentation in annotations is horrendous,” Andy explained. Consider a tool such as ASCIIDoctor, a plain-text writing format for authoring documentation, notes, books, and also a publication toolchain.

What is the standard format for a REST API?

Data Formats Most API requests will return content from the server that the client needs to interpret. Rarely is this content plain text—usually, it will use a structured data format. While REST does not specify any data formats, JSON and XML are the two most commonly used.


2 Answers

Sure, REST APIs should ideally use HATEOAS and be hypertext driven (with heavy use of media types), but also having simple human-friendly documentation for developers to work off of is helpful.

Some specific tools that are helpful for generating documentation like this:

  • Swagger
    • An open spec for describing REST APIs [ github ]
    • Tools for auto-generating
      • Documentation
      • Code for your API
    • Donated to the OpenAPI initiative and renamed OpenAPI in 2015
  • Mashery
    • An open source project [ github ]
    • Tools for generating
      • Documentation
      • An exploration interface for your API
  • Apiary and API Blueprint
    • Write the API description in a DSL within markdown
    • Tools for auto-generating
      • Documentation
      • Mock server
    • Seems to be focused on ruby+mac devs
  • RAML
    • A spec for describing REST APIs [ github ]
  • WADL
    • A spec for writing discoverable API docs with XML
    • Some discussion comparing WSDL and WADL
  • APIgee
    • A commercial product with some documentation features
  • 3scale
    • A commercial product with some documentation features
  • miredot
    • Commercial REST API documentation generator
    • Java specific
like image 165
turtlemonvh Avatar answered Sep 17 '22 17:09

turtlemonvh


I've been using http://apiary.io, which is pretty nice. You can also export the API documentation to github.

like image 44
14 revs, 12 users 16% Avatar answered Sep 17 '22 17:09

14 revs, 12 users 16%