Skip to content

struckchure/wallet-system-api

Repository files navigation

Wallet System API

The Wallet System API is a robust and secure financial transactions management system. It provides a set of endpoints to create and manage user wallets, process credit and debit transactions, handle webhooks, and ensure the integrity and security of financial operations.

Setup

Start the database:

docker compose up --force-recreate -d

Install Bun

curl -fsSL https://bun.sh/install | bash

To install dependencies:

bun install

To run:

bun run dev

Api Docs

Authentication

Register

Endpoint: POST /api/auth/register/

Registers a new user.

Request:

{
  "email": "mail@mail.com",
  "password": "123456"
}

Response:

{
  "tokens": {
    "access": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "refresh": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
  }
}

Login

Endpoint: POST /api/auth/login/

Logs in a user.

Request:

{
  "email": "mail@mail.com",
  "password": "123456-"
}

Response:

{
  "tokens": {
    "access": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "refresh": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
  }
}

Refresh Token

Endpoint: POST /api/auth/refresh-token/

Refreshes the access token.

Request:

{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}

Response:

{
  "tokens": {
    "access": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "refresh": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
  }
}

Wallet

Create Wallet

Endpoint: POST /api/wallet/

Creates a new wallet.

Request:

{
  "passphrase": "buttercup"
}

Response:

{
  "id": "0461a08e-2ab4-49de-8f84-175be316534f",
  "createdAt": "2024-01-17T07:03:08.781Z",
  "updatedAt": "2024-01-17T07:03:08.781Z",
  "userId": "c2635150-2bb2-4e9e-b5b1-ba951fe2d49f",
  "address": "04F311E2D6"
}

Get Wallet

Endpoint: GET /api/wallet/

Retrieves wallet information.

Response:

{
  "id": "0461a08e-2ab4-49de-8f84-175be316534f",
  "createdAt": "2024-01-17T07:03:08.781Z",
  "updatedAt": "2024-01-17T07:13:24.663Z",
  "userId": "c2635150-2bb2-4e9e-b5b1-ba951fe2d49f",
  "address": "04F311E2D6",
  "balance": 2000
}

Update Wallet

Endpoint: PATCH /api/wallet/

Updates wallet information.

Request:

{
  "passphrase": "something-nice"
}

Response:

{
  "id": "0461a08e-2ab4-49de-8f84-175be316534f",
  "createdAt": "2024-01-17T07:03:08.781Z",
  "updatedAt": "2024-01-17T07:13:24.663Z",
  "userId": "c2635150-2bb2-4e9e-b5b1-ba951fe2d49f",
  "address": "04F311E2D6"
}

Delete Wallet

Endpoint: DELETE /api/wallet/

Deletes the user's wallet.

Wallet Deposit

Endpoint: POST /api/wallet/deposit/

Deposits funds into the wallet.

Request:

{
  "amount": 100
}

Response:

{
  "balance": 2100
}

Wallet Withdrawal

Endpoint: POST /api/wallet/withdraw/

Withdraws funds from the wallet.

Request:

{
  "amount": 300,
  "passphrase": "something-nice"
}

Response:

{
  "balance": 1500
}

This documentation provides a comprehensive guide on using the Wallet System API. For more details on each endpoint, refer to the respective sections.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published