Skip to content

Latest commit

 

History

History
executable file
·
120 lines (98 loc) · 2.21 KB

File metadata and controls

executable file
·
120 lines (98 loc) · 2.21 KB

FastAPI Onboarding Member Registration API

This is a simple FastAPI backend for onboarding member registration with basic authentication. It is intended for testing and learning purposes.

Features

  • Register new members
  • Authenticate users
  • Read member info
  • Update member info
  • Delete member info

Requirements

  • Python 3.10+
  • Install dependencies:
    pip install -r requirements.txt

API Endpoints

1. Register Member

POST /create

Body (JSON):

{
  "first_name": "John",
  "last_name": "Doe",
  "user_name": "johndoe",
  "phone": "1234567890",
  "email": "john@example.com",
  "tin": 123456,
  "password": "yourpassword"
}

Curl Example:

curl -X POST http://localhost:8000/create \
  -H "Content-Type: application/json" \
  -d '{"first_name":"John","last_name":"Doe","user_name":"johndoe","phone":"1234567890","email":"john@example.com","tin":123456,"password":"yourpassword"}'

2. Read Member Info

POST /read/{user_name}

Curl Example:

curl -X POST http://localhost:8000/read/johndoe

3. Update Member Info

POST /update/{user_name}/{field}

Body (JSON):

{
  "password": "yourpassword"
}

Query Parameter: value (new value for the field)

Curl Example:

curl -X POST "http://localhost:8000/update/johndoe/phone?value=0987654321" \
  -H "Content-Type: application/json" \
  -d '{"password":"yourpassword"}'

4. Delete Member

POST /delete/{user_name}

Body (JSON):

{
  "password": "yourpassword"
}

Curl Example:

curl -X POST http://localhost:8000/delete/johndoe \
  -H "Content-Type: application/json" \
  -d '{"password":"yourpassword"}'

5. Authenticate Member

POST /authenticate/{user_name}

Body (JSON):

{
  "password": "yourpassword"
}

Curl Example:

curl -X POST http://localhost:8000/authenticate/johndoe \
  -H "Content-Type: application/json" \
  -d '{"password":"yourpassword"}'

Notes

  • All endpoints use POST for simplicity.
  • Passwords are stored as SHA256 hashes.
  • For testing, run the server with:
    uvicorn main:app --reload

Made for onboarding and testing purposes.