-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
63 additions
and
0 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
blockchain_integration/pi_network/docs/API_Documentation.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <token>` | ||
- **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. |