From a73eb41835c0e1d10201533e5b57edb1174ba2a6 Mon Sep 17 00:00:00 2001 From: KOSASIH Date: Thu, 31 Oct 2024 09:46:51 +0700 Subject: [PATCH] Create API_Documentation.md --- .../pi_network/docs/API_Documentation.md | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 blockchain_integration/pi_network/docs/API_Documentation.md diff --git a/blockchain_integration/pi_network/docs/API_Documentation.md b/blockchain_integration/pi_network/docs/API_Documentation.md new file mode 100644 index 000000000..04a7badaa --- /dev/null +++ b/blockchain_integration/pi_network/docs/API_Documentation.md @@ -0,0 +1,63 @@ +# API Documentation + +## Base URL + +[http://localhost:3000/api](http://localhost:3000/api) + +## Authentication +### Register User +- **Endpoint**: `/users/register` +- **Method**: `POST` +- **Request Body**: + ```json + 1 { + 2 "username": "string", + 3 "password": "string" + 4 } + ``` +- **Response**: + - **201 Created**: User registered successfully. + - **400 Bad Request**: User already exists. + +### Login User +- **Endpoint**: `/users/login` +- **Method**: `POST` +- **Request Body**: + ```json + 1 { + 2 "username": "string", + 3 "password": "string" + 4 } + ``` +- **Response**: + - **200 OK**: Returns a JWT token. + - **401 Unauthorized**: Invalid credentials. + +### Get User Profile +- **Endpoint**: `/users/profile` +- **Method**: `GET` +- **Headers**: + - `Authorization: Bearer ` +- **Response**: + - **200 OK**: Returns user profile data. + +## Contract Endpoints +### Get Contract Details +- **Endpoint**: `/contracts/:contractAddress` +- **Method**: `GET` +- **Response**: + - **200 OK**: Returns contract details. + - **500 Internal Server Error**: Error fetching contract details. + +### Interact with Contract +- **Endpoint**: `/contracts/:contractAddress/interact` +- **Method**: `POST` +- **Request Body**: + ```json + 1 { + 2 "value": "uint256" + 3 } + ``` +- **Response**: + - **200 OK**: Interaction successful, returns transaction hash. + - **500 Internal Server Error**: Error interacting with contract.