Skip to content

Commit 4abf117

Browse files
docs(api): sync documentation from api@b02d62331ed4013d6fb72c2e5d6dc91302f5c589
1 parent cd6443b commit 4abf117

8 files changed

Lines changed: 47 additions & 66 deletions

File tree

docs/api/API_ERRORS.md

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ All errors follow [RFC 7807 Problem Details](./PROBLEM_DETAILS_RFC_7807.md).
1616
- Vehicle with specified make/model/year does not exist
1717
- Manufacturer slug is invalid or has no models
1818

19-
**Resolution:** Verify the resource identifier. Use `/api/v1/makes` to list valid manufacturers or `/api/v1/vehicles` to browse available vehicles.
19+
**Resolution:** Verify the resource identifier. Use `/api/v1/makes/list` to list valid manufacturers or `/api/v1/vehicles/list` to browse available vehicles.
2020

2121
**Example:**
2222
```json
2323
{
2424
"type": "https://github.com/open-ev-data/open-ev-data-api/blob/main/docs/API_ERRORS.md#errorsnot-found",
2525
"title": "Resource Not Found",
2626
"status": 404,
27-
"detail": "Vehicle not found: invalid/model/2024",
28-
"instance": "/api/v1/vehicles/invalid/model/2024"
27+
"detail": "Vehicle not found with code: invalid:model:2024:unknown",
28+
"instance": "/api/v1/vehicles/code/invalid:model:2024:unknown"
2929
}
3030
```
3131

@@ -50,7 +50,7 @@ All errors follow [RFC 7807 Problem Details](./PROBLEM_DETAILS_RFC_7807.md).
5050
"title": "Invalid Request",
5151
"status": 400,
5252
"detail": "Search query must be at least 2 characters",
53-
"instance": "/api/v1/search"
53+
"instance": "/api/v1/vehicles/search"
5454
}
5555
```
5656

@@ -75,7 +75,7 @@ All errors follow [RFC 7807 Problem Details](./PROBLEM_DETAILS_RFC_7807.md).
7575
"title": "Internal Server Error",
7676
"status": 500,
7777
"detail": "Database query failed",
78-
"instance": "/api/v1/vehicles"
78+
"instance": "/api/v1/vehicles/list"
7979
}
8080
```
8181

@@ -111,10 +111,7 @@ All errors follow [RFC 7807 Problem Details](./PROBLEM_DETAILS_RFC_7807.md).
111111
| Endpoint | Possible Errors |
112112
|----------|-----------------|
113113
| `GET /health` | 500, 503 |
114-
| `GET /makes` | 500 |
115-
| `GET /makes/{make}/models` | 404, 500 |
116-
| `GET /vehicles` | 400, 500 |
117-
| `GET /vehicles/code/{unique_code}` | 404, 500 |
118-
| `GET /vehicles/{make}/{model}/{year}` | 404, 500 |
119-
| `GET /vehicles/{make}/{model}/{year}/variants` | 404, 500 |
120-
| `GET /search` | 400, 500 |
114+
| `GET /makes/list` | 500 |
115+
| `GET /vehicles/list` | 400, 500 |
116+
| `GET /vehicles/code/{code}` | 404, 500 |
117+
| `GET /vehicles/search` | 400, 500 |

docs/api/ARCHITECTURE.md

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -279,12 +279,12 @@ sequenceDiagram
279279
280280
Deploy->>API: Deploy ev-server + vehicles.db
281281
API->>API: Load database into memory
282-
Client->>API: GET /api/v1/vehicles?make=tesla
282+
Client->>API: GET /api/v1/vehicles/list?make=tesla
283283
API->>API: Query local database
284284
API-->>Client: Return JSON response
285285
286-
Client->>API: GET /api/v1/vehicles/tesla/model_3/2024
287-
API->>API: Query by composite key
286+
Client->>API: GET /api/v1/vehicles/code/tesla:model_3:2024:model_3
287+
API->>API: Query by unique code
288288
API-->>Client: Return vehicle details
289289
290290
```
@@ -607,7 +607,7 @@ Health check endpoint
607607
}
608608
```
609609

610-
#### GET `/api/v1/vehicles`
610+
#### GET `/api/v1/vehicles/list`
611611
List all vehicles with pagination and filtering
612612

613613
**Query Parameters**:
@@ -633,48 +633,36 @@ List all vehicles with pagination and filtering
633633
}
634634
```
635635

636-
#### GET `/api/v1/vehicles/{make}/{model}/{year}`
637-
Get specific vehicle details
636+
#### GET `/api/v1/vehicles/code/{code}`
637+
Get specific vehicle by unique code
638638

639639
**Path Parameters**:
640-
- `make`: Manufacturer slug
641-
- `model`: Model slug
642-
- `year`: Model year
640+
- `code`: Vehicle unique code (format: `make:model:year:filename`)
643641

644642
**Response**: Full canonical vehicle object
645643

646-
#### GET `/api/v1/vehicles/{make}/{model}/{year}/variants`
647-
List all variants for a specific vehicle
644+
#### GET `/api/v1/vehicles/search`
645+
Full-text search across vehicles
646+
647+
**Query Parameters**:
648+
- `q`: Search query (minimum 2 characters)
649+
- `page`, `per_page`: Pagination
648650

649-
**Response**: Array of variant vehicles
651+
**Response**: Ranked search results with pagination
650652

651-
#### GET `/api/v1/makes`
652-
List all manufacturers
653+
#### GET `/api/v1/makes/list`
654+
List all manufacturers with model information
653655

654656
**Response**:
655657
```json
656658
{
657659
"makes": [
658-
{ "slug": "tesla", "name": "Tesla", "vehicle_count": 42 },
659-
{ "slug": "byd", "name": "BYD", "vehicle_count": 38 }
660+
{ "slug": "tesla", "name": "Tesla", "vehicle_count": 42, "models": ["Model 3", "Model S", "Model X", "Model Y"] },
661+
{ "slug": "byd", "name": "BYD", "vehicle_count": 38, "models": ["Dolphin", "Seal", "Atto 3"] }
660662
]
661663
}
662664
```
663665

664-
#### GET `/api/v1/makes/{make}/models`
665-
List all models for a manufacturer
666-
667-
**Response**: Array of models with vehicle counts
668-
669-
#### GET `/api/v1/search`
670-
Full-text search across vehicles
671-
672-
**Query Parameters**:
673-
- `q`: Search query
674-
- `page`, `per_page`: Pagination
675-
676-
**Response**: Ranked search results
677-
678666
### 7.3. Configuration
679667

680668
Configuration via environment variables:

docs/api/CRATE_EV_ETL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This crate provides a command-line tool for transforming layered JSON vehicle da
99
## Usage
1010

1111
```bash
12-
ev-etl --input ../open-ev-data-dataset/src --output ./output --formats json,sqlite
12+
cargo run -p ev-etl -- --input ../open-ev-data-dataset/src --output ./output --formats json,sqlite
1313
```
1414

1515
## Output Formats

docs/api/CRATE_EV_SERVER.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This crate provides a high-performance HTTP REST API server for querying electri
99
## Usage
1010

1111
```bash
12-
DATABASE_URL=vehicles.db ev-server
12+
DATABASE_URL=./output/vehicles.db cargo run -p ev-server
1313
```
1414

1515
## Environment Variables
@@ -26,12 +26,10 @@ DATABASE_URL=vehicles.db ev-server
2626
## Endpoints
2727

2828
- `GET /api/v1/health` - Health check
29-
- `GET /api/v1/vehicles` - List vehicles with filters
30-
- `GET /api/v1/vehicles/{make}/{model}/{year}` - Get vehicle details
31-
- `GET /api/v1/vehicles/{make}/{model}/{year}/variants` - List variants
32-
- `GET /api/v1/makes` - List manufacturers
33-
- `GET /api/v1/makes/{make}/models` - List models
34-
- `GET /api/v1/search?q=query` - Full-text search
29+
- `GET /api/v1/vehicles/list` - List vehicles with filters and pagination
30+
- `GET /api/v1/vehicles/code/{code}` - Get vehicle by unique code
31+
- `GET /api/v1/vehicles/search?q=query` - Full-text search
32+
- `GET /api/v1/makes/list` - List manufacturers with model names
3533

3634
## OpenAPI Documentation
3735

docs/api/GET_STARTED.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ Test endpoints:
8989

9090
```bash
9191
curl http://localhost:3000/api/v1/health
92-
curl http://localhost:3000/api/v1/makes
93-
curl http://localhost:3000/api/v1/vehicles
94-
curl http://localhost:3000/api/v1/vehicles/tesla/model_3/2024
95-
curl "http://localhost:3000/api/v1/search?q=dolphin"
92+
curl http://localhost:3000/api/v1/makes/list
93+
curl http://localhost:3000/api/v1/vehicles/list
94+
curl http://localhost:3000/api/v1/vehicles/code/tesla:model_3:2024:model_3
95+
curl "http://localhost:3000/api/v1/vehicles/search?q=dolphin"
9696
```
9797

9898
Swagger UI is available at: `http://localhost:3000/docs`

docs/api/PROBLEM_DETAILS_RFC_7807.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ All error responses return a JSON object with these fields:
2525
"type": "https://github.com/open-ev-data/open-ev-data-api/blob/main/docs/API_ERRORS.md#errorsnot-found",
2626
"title": "Resource Not Found",
2727
"status": 404,
28-
"detail": "Vehicle not found: tesla/model_x/2099",
29-
"instance": "/api/v1/vehicles/tesla/model_x/2099"
28+
"detail": "Vehicle not found with code: tesla:model_x:2099:model_x",
29+
"instance": "/api/v1/vehicles/code/tesla:model_x:2099:model_x"
3030
}
3131
```
3232

docs/api/TESTING.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,14 @@ Test complete API workflows from request to response.
114114
**Example:**
115115
```rust
116116
#[tokio::test]
117-
async fn test_get_vehicle_success() {
118-
let response = client.get("/api/v1/vehicles/tesla/model_3/2024").await;
117+
async fn test_get_vehicle_by_code_success() {
118+
let response = client.get("/api/v1/vehicles/code/tesla:model_3:2024:model_3").await;
119119
assert_eq!(response.status(), 200);
120120
}
121121

122122
#[tokio::test]
123-
async fn test_get_vehicle_not_found() {
124-
let response = client.get("/api/v1/vehicles/invalid/invalid/9999").await;
123+
async fn test_get_vehicle_by_code_not_found() {
124+
let response = client.get("/api/v1/vehicles/code/invalid:code:2024:unknown").await;
125125
assert_eq!(response.status(), 404);
126126
let body: ProblemDetails = response.json().await;
127127
assert!(body.error_type.contains("not-found"));

docs/api/index.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,10 @@ This repository provides a **production-ready REST API** for querying electric v
4747
| Endpoint | Description |
4848
|----------|-------------|
4949
| `GET /api/v1/health` | Health check |
50-
| `GET /api/v1/vehicles` | List vehicles with filters |
51-
| `GET /api/v1/vehicles/{make}/{model}/{year}` | Get vehicle details |
52-
| `GET /api/v1/vehicles/{make}/{model}/{year}/variants` | List variants |
53-
| `GET /api/v1/makes` | List manufacturers |
54-
| `GET /api/v1/makes/{make}/models` | List models |
55-
| `GET /api/v1/search?q=query` | Full-text search |
50+
| `GET /api/v1/vehicles/list` | List vehicles with filters and pagination |
51+
| `GET /api/v1/vehicles/code/{code}` | Get vehicle by unique code |
52+
| `GET /api/v1/vehicles/search?q=query` | Full-text search |
53+
| `GET /api/v1/makes/list` | List manufacturers with model names |
5654

5755
## Use Cases
5856

0 commit comments

Comments
 (0)