Python and REST APIs
- 1 minThere are several Web services available on the internet. Many web services, like Twilio and Facebook, make their data accessible to third-party applications through an application programming interface (API). One of the most popular ways to build APIs is the REST(REpresentational Stateless Transfer) architecture style.
This post will be a good primer for a python programmer looking to integrate any web-service APIs.
In this post, I shall show a working source code and a docker container image to get started quickly.
Use below two commands to see the example in action.
make build-container
make test-container
Purpose
Provide a sample or starter example code for RESTful Web Services in python.
Installation
Please refer to Makefile and Dockerfile for install and build instructions.
Resource
- Flask Server Flask is a widely used micro web framework for creating APIs in Python.
Restful Methods
- POST
@app.route('/', methods=['POST']) def create_record():
- GET
@app.route('/', methods=['GET']) def query_records():
- PUT
@app.route('/', methods=['PUT']) def update_record():
- DELETE
@app.route('/', methods=['DELETE']) def delte_record():
Testing
- Run Server
make build
- Run Client
make test-container
Next Steps
Follow the below links for the source code and Dockerfile
I hope that these references will make getting started extremely easy.
Enjoy!
Web Resources
DISCLAIMER: All views expressed on this site are my own and do not represent the opinions of any entity whatsoever with which I have been, am now, or will be affiliated. Any collateral used is referenced in the Web Resources or others sections on this page. The information provided on this website does not constitute investment advice, financial advice, or trading advice.