Skip to content

Commit

Permalink
Create API_Documentation.md
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Oct 31, 2024
1 parent 50ecaa9 commit a73eb41
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions blockchain_integration/pi_network/docs/API_Documentation.md
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.

0 comments on commit a73eb41

Please sign in to comment.