/contact_store_api

Primary LanguagePythonMIT LicenseMIT

Python API to Store Contact

Instagram LinkedIn

Discription


The Api can store Name,Contact,Address In Database.
It comes with build source code of docker Fully customizable
It can perform GET/POST/PUT/DELETE Operation
I is based on FastAPI
Installation is simple It si based on docker-compose so OneClick Implementation

!! NOTE : Your host network CIDR can Conflict with docker network so accordingly change the
- subnet in compose network
- ipv4 address of containers

For E.g 10.0.0.0/24 (default in this example) , 12.0.0.1/24 , 192.168.10.1/24

API Request and Responce


The request and responce format is straight and consistent

# Post Request
You can make post request passing 3 Parameters

The responce body will be json like.
> E.g Request : http://10.0.0.2:8000/?name=mike&phone_num=+977985*****&addr=nepal

{
  "success": true,
  "responce": {
    "id": 1
  }
}

# Get Request
You can make Get request passing ID as Parameter

The responce body will be json like.
> E.g Request : http://10.0.0.2:8000/?id=user_id

{
  "success": true,
  "responce": {
    "name": "mike",
    "contact": "+977985******",
    "addr": "nepal"
  }
}

# PUT Request
You can make PUT request passing parameter name and value to Update along with ID of user

The responce body will be json like.
E.g Request : http://10.0.0.2:8000/?id=id_of_username=name_to_update&phone_num=num_to_update&addr=address_to_update

{
  "success": true,
  "responce": "Updated ID 1"
}

Again GET request gives

{
  "success": true,
  "responce": {
    "name": "updated_name",
    "contact": "updated_number",
    "addr": "updated_address"
  }
}

# Delete Request
You can make Delete request passing ID as Parameter which will delete the record with given ID

The responce body will be json like.
> E.g Request : http://10.0.0.2:8000/?id=user_id_to_delete

{
  "success": true,
  "responce": "Removed ID 1"
}

Again Get Request for deleted id

{
  "success": false,
  "reason": "User Not found"
}

Installation


It is based on Docker and Docker-compose Which comes with Persistent Volume No Data Loss

Check Installation

# Shell Commands
> docker -v
> docker-compose -v

Api Installation

> git clone url_
> cd dir
> docker-compose up -d

The default CIDR in Docker-compose Network is 10.0.0.1/24 db is on 10.0.0.3 and app is on 10.0.0.2 So You can access your api now on http://10.0.0.3/ using any api client eg. Browser, Insomnia