Complete REST API reference for the MyEnglishNote backend.
Base URL: http://localhost:9501
API Prefix: /api
Content-Type: application/json
Authentication: JWT Bearer Token (except login/register)
Endpoint: POST /login
Request Body:
{
"username": "admin",
"password": "admin123"
}Response (Success - 200):
{
"code": 200,
"msg": "操作成功",
"token": "eyJhbGciOiJIUzUxMiJ9...",
"userId": 1
}Example:
curl -X POST http://localhost:9501/login \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"admin123"}'Endpoint: POST /register
Request Body:
{
"username": "newuser",
"password": "password123",
"email": "user@example.com"
}Response (Success - 200):
{
"code": 200,
"msg": "注册成功"
}Include the token in all subsequent requests:
curl -X GET http://localhost:9501/api/note/list \
-H "Authorization: Bearer YOUR_TOKEN_HERE"{
"code": 200,
"msg": "操作成功",
"data": {
// Response data
}
}{
"code": 500,
"msg": "错误信息"
}{
"code": 200,
"msg": "查询成功",
"rows": [
// Array of items
],
"total": 100
}| Code | Description |
|---|---|
| 200 | Success |
| 401 | Unauthorized (invalid/expired token) |
| 403 | Forbidden (no permission) |
| 404 | Not Found |
| 500 | Internal Server Error |
Endpoint: POST /api/note/add
Headers:
Authorization: Bearer {token}Content-Type: application/json
Request Body:
{
"content": "apple - 苹果, a red or green fruit",
"tags": "vocabulary,fruit,food"
}Response (200):
{
"code": 200,
"msg": "操作成功",
"data": {
"id": 1,
"userId": 1,
"content": "apple - 苹果, a red or green fruit",
"embedding": [0.123, 0.456, ...], // 1024-dimensional vector
"embeddingModel": "deepseek-embedding",
"tags": "vocabulary,fruit,food",
"createdAt": "2025-02-10 10:30:00",
"updatedAt": "2025-02-10 10:30:00",
"delFlag": "0"
}
}Example:
curl -X POST http://localhost:9501/api/note/add \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"content": "apple - 苹果, a red fruit",
"tags": "vocabulary,fruit"
}'Endpoint: GET /api/note/list
Headers:
Authorization: Bearer {token}
Query Parameters:
pageNum(optional, default: 1): Page numberpageSize(optional, default: 10): Items per page
Response (200):
{
"code": 200,
"msg": "查询成功",
"rows": [
{
"id": 1,
"userId": 1,
"content": "apple - 苹果",
"embedding": [...],
"embeddingModel": "deepseek-embedding",
"tags": "vocabulary,fruit",
"createdAt": "2025-02-10 10:30:00",
"updatedAt": "2025-02-10 10:30:00",
"delFlag": "0"
}
],
"total": 50
}Example:
curl -X GET "http://localhost:9501/api/note/list?pageNum=1&pageSize=10" \
-H "Authorization: Bearer YOUR_TOKEN"Endpoint: GET /api/note/{id}
Headers:
Authorization: Bearer {token}
Path Parameters:
id: Note ID
Response (200):
{
"code": 200,
"msg": "操作成功",
"data": {
"id": 1,
"userId": 1,
"content": "apple - 苹果",
"embedding": [...],
"tags": "vocabulary",
"createdAt": "2025-02-10 10:30:00",
"updatedAt": "2025-02-10 10:30:00"
}
}Example:
curl -X GET http://localhost:9501/api/note/1 \
-H "Authorization: Bearer YOUR_TOKEN"Endpoint: PUT /api/note/{id}
Headers:
Authorization: Bearer {token}Content-Type: application/json
Path Parameters:
id: Note ID
Request Body:
{
"content": "apple - 苹果 (updated)",
"tags": "vocabulary,fruit,updated"
}Response (200):
{
"code": 200,
"msg": "操作成功",
"data": {
"id": 1,
"userId": 1,
"content": "apple - 苹果 (updated)",
"embedding": [...], // Re-generated
"tags": "vocabulary,fruit,updated",
"updatedAt": "2025-02-10 11:00:00"
}
}Example:
curl -X PUT http://localhost:9501/api/note/1 \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"content": "apple - 苹果 (updated)",
"tags": "vocabulary"
}'Endpoint: DELETE /api/note/{id}
Headers:
Authorization: Bearer {token}
Path Parameters:
id: Note ID
Response (200):
{
"code": 200,
"msg": "操作成功"
}Example:
curl -X DELETE http://localhost:9501/api/note/1 \
-H "Authorization: Bearer YOUR_TOKEN"Endpoint: DELETE /api/note/batch
Headers:
Authorization: Bearer {token}Content-Type: application/json
Request Body:
[1, 2, 3, 4, 5]Response (200):
{
"code": 200,
"msg": "操作成功"
}Example:
curl -X DELETE http://localhost:9501/api/note/batch \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '[1, 2, 3]'Endpoint: GET /api/note/count
Headers:
Authorization: Bearer {token}
Response (200):
{
"code": 200,
"msg": "操作成功",
"data": 42
}Example:
curl -X GET http://localhost:9501/api/note/count \
-H "Authorization: Bearer YOUR_TOKEN"Endpoint: POST /api/rag/search
Headers:
Authorization: Bearer {token}Content-Type: application/json
Request Body:
{
"question": "What is apple?",
"similarityThreshold": 0.7,
"maxResults": 5
}Parameters:
question(required): Search querysimilarityThreshold(optional, default: 0.7): Minimum similarity score (0-1)maxResults(optional, default: 5): Maximum number of results
Response (200):
{
"code": 200,
"msg": "操作成功",
"data": [
{
"id": 1,
"content": "apple - 苹果, a red fruit",
"similarity": 0.95,
"tags": "vocabulary,fruit"
},
{
"id": 5,
"content": "red apple - 红苹果",
"similarity": 0.82,
"tags": "vocabulary"
}
]
}Example:
curl -X POST http://localhost:9501/api/rag/search \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"question": "What is apple?",
"similarityThreshold": 0.7,
"maxResults": 5
}'Endpoint: POST /api/rag/answer
Headers:
Authorization: Bearer {token}Content-Type: application/json
Request Body:
{
"question": "What is the difference between apple and banana?",
"similarityThreshold": 0.7,
"maxResults": 5,
"includeContext": true
}Parameters:
question(required): Your questionsimilarityThreshold(optional): Similarity thresholdmaxResults(optional): Max related notesincludeContext(optional, default: true): Include context in answer
Response (200):
{
"code": 200,
"msg": "操作成功",
"data": {
"success": true,
"question": "What is the difference between apple and banana?",
"answer": "Based on your notes:\n\nApple (苹果) is typically red or green and is often described as crisp. Banana (香蕉) is yellow and has a softer texture. Both are fruits, but they have different tastes and nutritional profiles.",
"relatedNotes": [
{
"id": 1,
"content": "apple - 苹果, a red or green fruit",
"tags": "vocabulary,fruit"
},
{
"id": 2,
"content": "banana - 香蕉, a yellow fruit",
"tags": "vocabulary,fruit"
}
],
"processingTime": 1234,
"similarityThreshold": 0.7,
"maxResults": 5
}
}Error Response:
{
"code": 500,
"msg": "生成回答失败",
"data": {
"success": false,
"question": "What is apple?",
"errorMessage": "Deepseek API error: Rate limit exceeded",
"processingTime": 0
}
}Example:
curl -X POST http://localhost:9501/api/rag/answer \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"question": "Explain the word apple",
"includeContext": true
}'Endpoint: POST /api/rag/chat
Headers:
Authorization: Bearer {token}Content-Type: application/json
Request Body:
{
"question": "Tell me more about fruits",
"similarityThreshold": 0.7,
"maxResults": 5
}Response: Same format as /api/rag/answer
Note: Currently uses same implementation as answer. Future versions will support conversation history.
Example:
curl -X POST http://localhost:9501/api/rag/chat \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"question": "What fruits do I have notes about?"
}'Endpoint: GET /api/review/next
Headers:
Authorization: Bearer {token}
Query Parameters:
limit(optional, default: 1): Number of items to return
Response (200 - Single Item):
{
"code": 200,
"msg": "操作成功",
"data": {
"id": 1,
"noteId": 5,
"userId": 1,
"quality": 4,
"easinessFactor": 2.5,
"intervalDays": 1,
"repetitions": 0,
"nextReviewDate": "2025-02-10 10:00:00",
"reviewedAt": "2025-02-09 10:00:00"
}
}Response (200 - Multiple Items):
{
"code": 200,
"msg": "操作成功",
"data": [
{
"id": 1,
"noteId": 5,
...
},
{
"id": 2,
"noteId": 8,
...
}
]
}Response (200 - No Items):
{
"code": 200,
"msg": "暂无待复习项目",
"data": null
}Example:
curl -X GET "http://localhost:9501/api/review/next?limit=1" \
-H "Authorization: Bearer YOUR_TOKEN"Endpoint: POST /api/review/record
Headers:
Authorization: Bearer {token}
Query Parameters:
noteId(required): Note IDquality(required): Review quality (0-5)
Quality Scale:
- 0: Complete blackout
- 1: Incorrect, but familiar
- 2: Incorrect, but easy to recall
- 3: Correct, but difficult
- 4: Correct, with hesitation
- 5: Perfect recall
Response (200):
{
"code": 200,
"msg": "操作成功",
"data": {
"id": 2,
"noteId": 5,
"userId": 1,
"quality": 4,
"easinessFactor": 2.6,
"intervalDays": 6,
"repetitions": 1,
"nextReviewDate": "2025-02-16 10:00:00",
"reviewedAt": "2025-02-10 10:00:00"
}
}Example:
curl -X POST "http://localhost:9501/api/review/record?noteId=5&quality=4" \
-H "Authorization: Bearer YOUR_TOKEN"Endpoint: GET /api/review/stats
Headers:
Authorization: Bearer {token}
Response (200):
{
"code": 200,
"msg": "操作成功",
"data": {
"totalReviews": 150,
"dueToday": 5,
"dueThisWeek": 23,
"dueThisMonth": 67,
"averageQuality": 4.2,
"streak": 7
}
}Example:
curl -X GET http://localhost:9501/api/review/stats \
-H "Authorization: Bearer YOUR_TOKEN"Endpoint: POST /api/review/initialize
Headers:
Authorization: Bearer {token}
Query Parameters:
noteId(required): Note ID
Response (200):
{
"code": 200,
"msg": "操作成功",
"data": {
"id": 1,
"noteId": 5,
"userId": 1,
"quality": 0,
"easinessFactor": 2.5,
"intervalDays": 1,
"repetitions": 0,
"nextReviewDate": "2025-02-11 10:00:00",
"reviewedAt": "2025-02-10 10:00:00"
}
}Example:
curl -X POST "http://localhost:9501/api/review/initialize?noteId=5" \
-H "Authorization: Bearer YOUR_TOKEN"# 1. Login
TOKEN=$(curl -s -X POST http://localhost:9501/login \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"admin123"}' \
| jq -r '.token')
# 2. Create a note
curl -X POST http://localhost:9501/api/note/add \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"content": "computer - 计算机, an electronic device",
"tags": "vocabulary,technology"
}'
# 3. List notes
curl -X GET http://localhost:9501/api/note/list \
-H "Authorization: Bearer $TOKEN"
# 4. Search with RAG
curl -X POST http://localhost:9501/api/rag/answer \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"question": "What is a computer?",
"includeContext": true
}'
# 5. Initialize review for note
curl -X POST "http://localhost:9501/api/review/initialize?noteId=1" \
-H "Authorization: Bearer $TOKEN"
# 6. Get next review
curl -X GET http://localhost:9501/api/review/next \
-H "Authorization: Bearer $TOKEN"
# 7. Record review
curl -X POST "http://localhost:9501/api/review/record?noteId=1&quality=5" \
-H "Authorization: Bearer $TOKEN"import requests
BASE_URL = "http://localhost:9501"
# Login
response = requests.post(f"{BASE_URL}/login", json={
"username": "admin",
"password": "admin123"
})
token = response.json()["token"]
# Create headers
headers = {
"Authorization": f"Bearer {token}",
"Content-Type": "application/json"
}
# Create note
response = requests.post(
f"{BASE_URL}/api/note/add",
headers=headers,
json={
"content": "apple - 苹果",
"tags": "vocabulary"
}
)
note = response.json()["data"]
print(f"Created note: {note['id']}")
# RAG search
response = requests.post(
f"{BASE_URL}/api/rag/answer",
headers=headers,
json={
"question": "What is apple?",
"includeContext": True
}
)
answer = response.json()["data"]
print(f"Answer: {answer['answer']}")const BASE_URL = 'http://localhost:9501';
// Login
const loginResponse = await fetch(`${BASE_URL}/login`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
username: 'admin',
password: 'admin123'
})
});
const { token } = await loginResponse.json();
// Create note
const noteResponse = await fetch(`${BASE_URL}/api/note/add`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
content: 'apple - 苹果',
tags: 'vocabulary'
})
});
const note = await noteResponse.json();
console.log('Created note:', note.data);
// RAG search
const ragResponse = await fetch(`${BASE_URL}/api/rag/answer`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
question: 'What is apple?',
includeContext: true
})
});
const answer = await ragResponse.json();
console.log('Answer:', answer.data.answer);Currently no rate limiting is implemented. In production, consider:
- Request rate limits per user
- API key quotas
- Deepseek API rate limits
API version is not explicitly specified. All endpoints are in v1.
Future versions may include /api/v2/... prefix.
For API-related questions:
- Check Swagger UI:
http://localhost:9501/swagger-ui.html - Review backend logs
- Check GitHub issues