131 lines
1.3 KiB
Markdown
131 lines
1.3 KiB
Markdown
|
||
# 📄 API Documentation – **Stupid APIs**
|
||
|
||
## Base URL
|
||
|
||
```
|
||
http://localhost:3000/api
|
||
```
|
||
|
||
**Default Headers:**
|
||
|
||
```
|
||
Content-Type: application/json
|
||
```
|
||
|
||
---
|
||
|
||
## 1️⃣ POST `/sort`
|
||
|
||
Sorts an array (numeric or alphabetical) and returns the sorted array.
|
||
|
||
### Request
|
||
|
||
**URL:**
|
||
|
||
```
|
||
POST /sort
|
||
```
|
||
|
||
|
||
**Body Example:**
|
||
|
||
```json
|
||
{
|
||
"array": [3, 1, 4, 1, 5, 9]
|
||
}
|
||
```
|
||
|
||
### Successful Response
|
||
|
||
```json
|
||
{
|
||
"sortedArray": [1, 1, 3, 4, 5, 9]
|
||
}
|
||
```
|
||
|
||
|
||
## 2️⃣ POST `/isOdd`
|
||
|
||
Checks if a given number is odd.
|
||
|
||
### Request
|
||
|
||
**URL:**
|
||
|
||
```
|
||
POST /isOdd
|
||
```
|
||
|
||
**Body Example:**
|
||
|
||
```json
|
||
{
|
||
"number": 7
|
||
}
|
||
```
|
||
|
||
### Successful Response
|
||
|
||
```json
|
||
{
|
||
"ret": true
|
||
}
|
||
```
|
||
|
||
---
|
||
|
||
## 3️⃣ POST `/isEven`
|
||
|
||
Checks if a given number is even.
|
||
|
||
### Request
|
||
|
||
**URL:**
|
||
|
||
```
|
||
POST /isEven
|
||
```
|
||
|
||
**Body Example:**
|
||
|
||
```json
|
||
{
|
||
"number": 4
|
||
}
|
||
```
|
||
|
||
### Successful Response
|
||
|
||
```json
|
||
{
|
||
"ret": true
|
||
}
|
||
```
|
||
|
||
## 📌 Example Usage with `curl`
|
||
|
||
### Sort an array (Linux/macOS)
|
||
|
||
```bash
|
||
curl -X POST http://localhost:3000/sort \
|
||
-H "Content-Type: application/json" \
|
||
-d '{"array":[3,1,4,1,5,9]}'
|
||
```
|
||
|
||
### Check if odd
|
||
|
||
```bash
|
||
curl -X POST http://localhost:3000/is-odd \
|
||
-H "Content-Type: application/json" \
|
||
-d '{"number":7}'
|
||
```
|
||
|
||
### Check if even
|
||
|
||
```bash
|
||
curl -X POST http://localhost:3000/is-even \
|
||
-H "Content-Type: application/json" \
|
||
-d '{"number":4}'
|
||
```
|