Postman is a popular tool for testing and developing APIs. It allows you to create, send, and analyze requests, as well as generate code snippets. But how can you use Postman to work with APIs that are defined using the Open API Specification (OAS), like Bevy?
OAS is a standard format for describing RESTful APIs, using either YAML or JSON syntax. It provides a way to document the structure, parameters, responses, and security of an API, as well as the endpoints and operations that it supports. OAS can help you design, build, and consume APIs in a consistent and interoperable way.
In this article, we will show you how to import the Bevy's OAS JSON document into Postman.
Importing Bevy OAS document into Postman
To import an OAS document into Postman, follow these steps:
- Download the OAS JSON from the article Bevy API Reference
- In Postman, Select Import in the sidebar.
- Upload the OAS JSON file you just downloaded
- Click Continue to review your import options.
- Select Generate Collection to create a collection based on the OAS document.
- Click **Import** to finish the import process.
You should now see the API endpoints in the Collections tab. You can also view the OAS document in the **Define** tab of the API schema.
Consume the APIs from Postman using variables
The APIs can use variables to ease consumption. Variables are placeholders that can store dynamic values for your API requests. By using variables, you can avoid hard-coding values that may change frequently, such as base URLs, authentication tokens, or query parameters.
You can use the variables by selecting the collection generated ("Bevy Public API Reference" in the example image) and going to the Variables tab.
baseUrl: it's the URL from your Bevy instance plus the
apiKey: It's the value to use in the Authorization header. Example:
The next image shows an example of how to set these variables:
After you set up these variables, you can use the different endpoints without they need to set these values.