How to Create and Publish API Documentation on Postman

How to Create and Publish API Documentation on Postman

Oftentimes, beginners have asked the question, How can I publish an API on Postman?

Today, I will be writing about a quick guide to help you through this process. But, first, I would like to talk a little about Postman.

Postman is an application for testing and documenting your API endpoints.

In Postman, you can group your requests or endpoints into something called a COLLECTION to help keep your workspace organized, collaborate with teammates, generate API documentation, and automate request runs (i.e you don't have to always write requests each time you want to run them or return a response).

As a backend developer, when you create an API or an endpoint, you most likely won't be the one to consume or use it. Your endpoint(s) is most likely to be used by other developers thus there is a need to create documentation for the endpoints you have created. After creating a collection and testing that your endpoints work, you then have to PUBLISH that collection. This makes the collection accessible to other people via a URL. This URL holds your written documentation. It usually starts with "documenter.postman..."

Now, let's proceed to why we are here. But, before you dive right in, I am assuming you already have basic knowledge of creating an API - making a request and receiving a response. If yes, then below are the steps to take to create and publish your own API documentation on Postman

1. Create a Collection

  • Click on the Collections tab

  • Click the + New Collection

Screenshot from 2021-02-22 21-47-18.png

  • Enter the "Name" of the collection

  • Add a "Description". Note, that this is optional

  • Click the Create button

Screenshot from 2021-02-23 14-57-56.png

  • You should be able to see the Users collection as part of the list of collections you have.

Screenshot from 2021-02-23 20-34-34.png

2. Create an Endpoint and Save it into a Collection.

  • Create an endpoint. E.g. localhost:8080/api/test-users

Screenshot from 2021-02-23 14-58-59.png

  • Click on the Save dropdown button

  • Click on Save as

Screenshot from 2021-02-23 14-59-03.png

  • You can rename the endpoint if you want to. E.g. Get Users

Screenshot from 2021-02-23 15-00-27.png

  • Scroll down, select the collection you want to save the endpoint into

  • Click on the Save button

Screenshot from 2021-02-23 15-00-41.png

  • You should be able to see the saved endpoint inside the collection

Screenshot from 2021-02-23 15-02-03.png

  • Let's save the Response we got after making the GET request

  • Click on the Save Response dropdown

  • Click on Save as example

Screenshot from 2021-02-23 15-01-23.png

  • Finally, click on the Save Example button

Screenshot from 2021-02-23 15-01-37.png

  • Repeat step 2 for all other requests or endpoints

3. Publish the Collection

  • Hover on the collection you created (e.g. Users), and click on the three-dotted icon on the right-hand side of it.

  • Click on Publish Docs. A page will open on the web browser.

Screenshot from 2021-02-23 15-54-02.png

  • You can choose to change the default colors provided by the postman

  • Scroll down to the bottom of the page

  • Click on the Publish Collection button

image.png

  • You will be redirected to a page where you can see the URL generated for the API documentation

image.png

  • Here is the URL generated for me