This is an example ecommerce api based on the OpenApi 3.0 specification which can be run on the local server and tested with the help of Postman as described below.
Firetail is an open source library that you can incorporate into your api that helps secure the endpoints. It also provides authentication and prevents common malicious queries from reaching the endpoint.
For more information, click here
Hotel booking api
Library management api
Social media api
Swagger 2.0 Petstore api
Swagger 3.0 Petstore api
Steps to run the example from scratch
Download and install python (3.6+) here
You can either download the files from Github as a zip or clone the repo to your local machine using -
git clone https://github.com/FireTail-io/python-openapi-quickstarts.git
-
You can download and use postman or use the web version in which case you have to download the postman desktop agent to be able to send api requests to your local host.
Download and install postman here -
Open the postman client and import the postman imports by clicking on File -> import
-
Click on folder, choose "postman_import" folder and click open
Move to the ecommerce-example folder and install the required libraries using the following command
python3 -m pip install -r requirements.txt
Run the file main.py
or use the following command to start the local server (It runs on http://127.0.0.1:8080)
python3 main.py
NOTE: Call the endpoint called 'RETURN JWT TOKEN' to generate and set an authorization token which will allow access to the other endpoints. If the token expires, simply call the endpoint again.
Once you have the local server running, you can now send requests via postman.
- Click on collection on the left and then select the request that you would like to send. Then fill in the parameters and body as required.
- Click send and the response will be displayed as shown.
Here are some examples of sending requests to the endpoints with some sample data.
All the sample cases assume that you have done the above steps to initialize the authorization token for the endpoints that may need them and that you are running the related example as a local server.
If you want to undo the changes you have made, just restart the local server.
- Click on the "Get a single product" endpoint and give 1 as the input value for the product_id as shown below and click send.
- At the bottom under "Body", you will see the following output if everything was done correctly.
- Click on the "Update a product" endpoint and give 1 as the input value for the product_id as shown below.
- Click on the Body tab and then enter the details to be updated as shown below and then click send.
- You can check the updated details by using the get product endpoint as shown in the first sample case.