@xano/developer-mcp 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/xanoscript_docs/apis.md +41 -19
package/package.json
CHANGED
package/xanoscript_docs/apis.md
CHANGED
|
@@ -9,7 +9,7 @@ HTTP endpoint definitions in XanoScript.
|
|
|
9
9
|
## Quick Reference
|
|
10
10
|
|
|
11
11
|
```xs
|
|
12
|
-
query "<
|
|
12
|
+
query "<name>" verb=<METHOD> {
|
|
13
13
|
api_group = "<GroupName>" # Required: API group for organization
|
|
14
14
|
description = "What this endpoint does"
|
|
15
15
|
auth = "<table>" # Optional: require authentication
|
|
@@ -19,6 +19,20 @@ query "<path>" verb=<METHOD> {
|
|
|
19
19
|
}
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
+
### Query Name (Required)
|
|
23
|
+
|
|
24
|
+
The query name is **required** and cannot be empty. It defines the endpoint path after the API group canonical.
|
|
25
|
+
|
|
26
|
+
**Full URL path structure:**
|
|
27
|
+
```
|
|
28
|
+
/<api_group canonical>/<query name>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The query name can include slashes for nested paths:
|
|
32
|
+
- `query "list" verb=GET` → `/<canonical>/list`
|
|
33
|
+
- `query "users/{id}" verb=GET` → `/<canonical>/users/{id}`
|
|
34
|
+
- `query "admin/reports/daily" verb=GET` → `/<canonical>/admin/reports/daily`
|
|
35
|
+
|
|
22
36
|
### HTTP Methods
|
|
23
37
|
`GET`, `POST`, `PUT`, `PATCH`, `DELETE`
|
|
24
38
|
|
|
@@ -42,36 +56,42 @@ Create an `api_group.xs` file in the group folder:
|
|
|
42
56
|
|
|
43
57
|
```xs
|
|
44
58
|
api_group "users" {
|
|
59
|
+
canonical = "users" # Required: the URL path segment
|
|
45
60
|
description = "User management endpoints"
|
|
46
61
|
}
|
|
47
62
|
```
|
|
48
63
|
|
|
49
64
|
#### API Group Properties
|
|
50
65
|
|
|
51
|
-
| Property | Description |
|
|
52
|
-
|
|
53
|
-
| `
|
|
54
|
-
| `
|
|
66
|
+
| Property | Required | Description |
|
|
67
|
+
|----------|----------|-------------|
|
|
68
|
+
| `canonical` | **Yes** | The URL path segment for this group. You cannot access a Xano API without it. |
|
|
69
|
+
| `description` | No | What this API group contains |
|
|
55
70
|
|
|
56
71
|
```xs
|
|
57
72
|
api_group "events" {
|
|
58
|
-
canonical = "events-api" # URL will use /events-api
|
|
73
|
+
canonical = "events-api" # Required: URL will use /events-api
|
|
74
|
+
description = "Event management"
|
|
59
75
|
}
|
|
60
76
|
```
|
|
61
77
|
|
|
78
|
+
> **Important:** The `canonical` property is required. It defines the base path for all endpoints in this group.
|
|
79
|
+
|
|
62
80
|
### File Structure
|
|
63
81
|
```
|
|
64
82
|
apis/
|
|
65
83
|
├── users/ # API group folder
|
|
66
|
-
│ ├── api_group.xs # Required: defines the group
|
|
67
|
-
│ ├── list.xs # GET /users
|
|
68
|
-
│ ├── create.xs # POST /users
|
|
69
|
-
│ └──
|
|
84
|
+
│ ├── api_group.xs # Required: defines the group (canonical = "users")
|
|
85
|
+
│ ├── list.xs # GET /users/list
|
|
86
|
+
│ ├── create.xs # POST /users/create
|
|
87
|
+
│ └── by-id.xs # GET/PATCH/DELETE /users/{id}
|
|
70
88
|
└── products/ # Another API group
|
|
71
|
-
├── api_group.xs # Required: defines the group
|
|
89
|
+
├── api_group.xs # Required: defines the group (canonical = "products")
|
|
72
90
|
└── search.xs # GET /products/search
|
|
73
91
|
```
|
|
74
92
|
|
|
93
|
+
> **URL Path:** The full endpoint URL is always `/<canonical>/<query name>`. For example, if `api_group.xs` has `canonical = "users"` and a query has `query "profile" verb=GET`, the endpoint URL is `/users/profile`.
|
|
94
|
+
|
|
75
95
|
> **Note:** Files placed directly in `apis/` without a group folder are invalid. Each API group folder must contain an `api_group.xs` file.
|
|
76
96
|
|
|
77
97
|
---
|
|
@@ -384,11 +404,13 @@ When using `return = { type: "list", paging: {...} }`:
|
|
|
384
404
|
|
|
385
405
|
## Best Practices
|
|
386
406
|
|
|
387
|
-
1. **
|
|
388
|
-
2. **
|
|
389
|
-
3. **
|
|
390
|
-
4. **
|
|
391
|
-
5. **
|
|
392
|
-
6. **
|
|
393
|
-
7. **
|
|
394
|
-
8. **
|
|
407
|
+
1. **Always set canonical** - Every `api_group` requires a `canonical` property
|
|
408
|
+
2. **Always name queries** - Every `query` requires a non-empty name
|
|
409
|
+
3. **RESTful design** - Use appropriate HTTP methods
|
|
410
|
+
4. **Consistent naming** - Use lowercase, hyphens for multi-word paths
|
|
411
|
+
5. **Authenticate sensitive operations** - Always auth for writes
|
|
412
|
+
6. **Validate inputs** - Use filters and preconditions
|
|
413
|
+
7. **Return appropriate errors** - Use correct error types
|
|
414
|
+
8. **Paginate lists** - Never return unbounded lists
|
|
415
|
+
9. **Document with description** - Explain what endpoint does
|
|
416
|
+
10. **Group related endpoints** - Organize by resource in api groups
|