@xano/developer-mcp 1.0.3 → 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 +56 -20
package/package.json
CHANGED
package/xanoscript_docs/apis.md
CHANGED
|
@@ -9,7 +9,8 @@ HTTP endpoint definitions in XanoScript.
|
|
|
9
9
|
## Quick Reference
|
|
10
10
|
|
|
11
11
|
```xs
|
|
12
|
-
query "<
|
|
12
|
+
query "<name>" verb=<METHOD> {
|
|
13
|
+
api_group = "<GroupName>" # Required: API group for organization
|
|
13
14
|
description = "What this endpoint does"
|
|
14
15
|
auth = "<table>" # Optional: require authentication
|
|
15
16
|
input { ... }
|
|
@@ -18,12 +19,30 @@ query "<path>" verb=<METHOD> {
|
|
|
18
19
|
}
|
|
19
20
|
```
|
|
20
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
|
+
|
|
21
36
|
### HTTP Methods
|
|
22
37
|
`GET`, `POST`, `PUT`, `PATCH`, `DELETE`
|
|
23
38
|
|
|
24
39
|
### API Groups (Required)
|
|
25
40
|
|
|
26
|
-
Every API endpoint **must** belong to an API group.
|
|
41
|
+
Every API endpoint **must** belong to an API group. API groups organize related endpoints together.
|
|
42
|
+
|
|
43
|
+
**Two requirements for API groups:**
|
|
44
|
+
1. Each `query` definition **must** include an `api_group` property specifying which group it belongs to
|
|
45
|
+
2. API groups are organized as folders within `apis/`, each with an `api_group.xs` file
|
|
27
46
|
|
|
28
47
|
- API groups appear as top-level folders under `apis/`
|
|
29
48
|
- Each group **must** have an `api_group.xs` file that defines the group
|
|
@@ -37,36 +56,42 @@ Create an `api_group.xs` file in the group folder:
|
|
|
37
56
|
|
|
38
57
|
```xs
|
|
39
58
|
api_group "users" {
|
|
59
|
+
canonical = "users" # Required: the URL path segment
|
|
40
60
|
description = "User management endpoints"
|
|
41
61
|
}
|
|
42
62
|
```
|
|
43
63
|
|
|
44
64
|
#### API Group Properties
|
|
45
65
|
|
|
46
|
-
| Property | Description |
|
|
47
|
-
|
|
48
|
-
| `
|
|
49
|
-
| `
|
|
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 |
|
|
50
70
|
|
|
51
71
|
```xs
|
|
52
72
|
api_group "events" {
|
|
53
|
-
canonical = "events-api" # URL will use /events-api
|
|
73
|
+
canonical = "events-api" # Required: URL will use /events-api
|
|
74
|
+
description = "Event management"
|
|
54
75
|
}
|
|
55
76
|
```
|
|
56
77
|
|
|
78
|
+
> **Important:** The `canonical` property is required. It defines the base path for all endpoints in this group.
|
|
79
|
+
|
|
57
80
|
### File Structure
|
|
58
81
|
```
|
|
59
82
|
apis/
|
|
60
83
|
├── users/ # API group folder
|
|
61
|
-
│ ├── api_group.xs # Required: defines the group
|
|
62
|
-
│ ├── list.xs # GET /users
|
|
63
|
-
│ ├── create.xs # POST /users
|
|
64
|
-
│ └──
|
|
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}
|
|
65
88
|
└── products/ # Another API group
|
|
66
|
-
├── api_group.xs # Required: defines the group
|
|
89
|
+
├── api_group.xs # Required: defines the group (canonical = "products")
|
|
67
90
|
└── search.xs # GET /products/search
|
|
68
91
|
```
|
|
69
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
|
+
|
|
70
95
|
> **Note:** Files placed directly in `apis/` without a group folder are invalid. Each API group folder must contain an `api_group.xs` file.
|
|
71
96
|
|
|
72
97
|
---
|
|
@@ -75,6 +100,7 @@ apis/
|
|
|
75
100
|
|
|
76
101
|
```xs
|
|
77
102
|
query "products" verb=GET {
|
|
103
|
+
api_group = "Products"
|
|
78
104
|
description = "List all products"
|
|
79
105
|
input {
|
|
80
106
|
int page?=1 filters=min:1
|
|
@@ -96,6 +122,7 @@ query "products" verb=GET {
|
|
|
96
122
|
### Public Endpoint (default)
|
|
97
123
|
```xs
|
|
98
124
|
query "status" verb=GET {
|
|
125
|
+
api_group = "System"
|
|
99
126
|
stack { }
|
|
100
127
|
response = { status: "ok" }
|
|
101
128
|
}
|
|
@@ -104,6 +131,7 @@ query "status" verb=GET {
|
|
|
104
131
|
### Authenticated Endpoint
|
|
105
132
|
```xs
|
|
106
133
|
query "profile" verb=GET {
|
|
134
|
+
api_group = "Users"
|
|
107
135
|
auth = "user" # Requires valid JWT
|
|
108
136
|
stack {
|
|
109
137
|
db.get "user" {
|
|
@@ -128,6 +156,7 @@ Use `{param}` in the path:
|
|
|
128
156
|
|
|
129
157
|
```xs
|
|
130
158
|
query "users/{user_id}" verb=GET {
|
|
159
|
+
api_group = "Users"
|
|
131
160
|
auth = "user"
|
|
132
161
|
input {
|
|
133
162
|
int user_id { table = "user" }
|
|
@@ -149,6 +178,7 @@ query "users/{user_id}" verb=GET {
|
|
|
149
178
|
### List (GET)
|
|
150
179
|
```xs
|
|
151
180
|
query "products" verb=GET {
|
|
181
|
+
api_group = "Products"
|
|
152
182
|
input {
|
|
153
183
|
text category? filters=trim|lower
|
|
154
184
|
int page?=1
|
|
@@ -168,6 +198,7 @@ query "products" verb=GET {
|
|
|
168
198
|
### Create (POST)
|
|
169
199
|
```xs
|
|
170
200
|
query "products" verb=POST {
|
|
201
|
+
api_group = "Products"
|
|
171
202
|
auth = "user"
|
|
172
203
|
input {
|
|
173
204
|
text name filters=trim
|
|
@@ -193,6 +224,7 @@ query "products" verb=POST {
|
|
|
193
224
|
### Read (GET with ID)
|
|
194
225
|
```xs
|
|
195
226
|
query "products/{product_id}" verb=GET {
|
|
227
|
+
api_group = "Products"
|
|
196
228
|
input {
|
|
197
229
|
int product_id { table = "product" }
|
|
198
230
|
}
|
|
@@ -214,6 +246,7 @@ query "products/{product_id}" verb=GET {
|
|
|
214
246
|
### Update (PATCH)
|
|
215
247
|
```xs
|
|
216
248
|
query "products/{product_id}" verb=PATCH {
|
|
249
|
+
api_group = "Products"
|
|
217
250
|
auth = "user"
|
|
218
251
|
input {
|
|
219
252
|
int product_id { table = "product" }
|
|
@@ -248,6 +281,7 @@ query "products/{product_id}" verb=PATCH {
|
|
|
248
281
|
### Delete (DELETE)
|
|
249
282
|
```xs
|
|
250
283
|
query "products/{product_id}" verb=DELETE {
|
|
284
|
+
api_group = "Products"
|
|
251
285
|
auth = "user"
|
|
252
286
|
input {
|
|
253
287
|
int product_id { table = "product" }
|
|
@@ -370,11 +404,13 @@ When using `return = { type: "list", paging: {...} }`:
|
|
|
370
404
|
|
|
371
405
|
## Best Practices
|
|
372
406
|
|
|
373
|
-
1. **
|
|
374
|
-
2. **
|
|
375
|
-
3. **
|
|
376
|
-
4. **
|
|
377
|
-
5. **
|
|
378
|
-
6. **
|
|
379
|
-
7. **
|
|
380
|
-
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
|