:art: Python and REST APIs

:art: Python and REST APIs

- 1 min

There 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

Restful Methods

  1. POST
     @app.route('/', methods=['POST'])
     def create_record():
    
  2. GET
     @app.route('/', methods=['GET'])
     def query_records():
    
  3. PUT
     @app.route('/', methods=['PUT'])
     def update_record():
    
  4. DELETE
     @app.route('/', methods=['DELETE'])
     def delte_record():
    
    

Testing

Next Steps

Follow the below links for the source code and Dockerfile

Example Source Code

README.md

Makefile

Docker Image

I hope that these references will make getting started extremely easy.

Enjoy!

Web Resources

Satya Dillikar

Satya Dillikar

Hands-on Software Architect with extensive experience developing and delivering distributed enterprise-class mission-critical software applications.

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.

comments powered by Disqus