Free tool to write API documentation – PHP, MySQL
I was looking for a tool that allows me to write API documentation so I can provide it to the frontend developers and also for myself. I checked many but didn’t find any that fits to all of my requirements. So I decided to create one of my own. Creating my own tool gives me flexibility to modify it as much as I want.
I also wanted it to share it with other developers who might be having problem in finding the tool to write documentation for their API. So I uploaded it on Github and it is available for anyone for free.
How to write API documentation
A tool is created in PHP and MySQL that allows developers to write API documentation, and this tool is available for free. You can create multiple sections to group the APIs based on modules. For example, user authentication, user posts, comments, replies can be separate sections.
To write each API, you need to tell:
- The section where it goes.
- The name of the endpoint. It can be the URL of API.
- The method, it can be either GET or POST. But since you will have the code, you can add more methods as per your needs.
- Add a little description about the API, for example what this API does.
- Headers:
- You need to tell the key of header, whether it is required or optional. And a little description about the header, for example, it’s possible values.
- Parameters:
- Parameters are usually send in the URL. You can define them along with their key, and value and whether they are optional or not.
- Arguments:
- For defining the arguments, you need to specify it’s type too. Whether it can be an integer, a string, boolean value or a file object.
- Example request body. You can write the CURL code inside it to give an example.
- Status codes and their responses.
I wrote a complete documentation of a project using this tool. You can check that from here.