JSON:API 服务器端点文档
JSON:API 服务器端点文档
过滤器
根据标签 ID 筛选文章
GET
{{host}}/jsonapi/node/article?include=field_image,field_tags&sort=-created&filter[field_tags.meta.drupal_internal__tid]=2
查询参数:
| 参数 | 值 |
|---|---|
| include | field_image,field_tags |
| sort | -created |
| filter[field_tags.meta.drupal_internal__tid] | 2 |
根据标签 UUID 筛选文章
GET
{{host}}/jsonapi/node/article?include=field_image,field_tags&sort=-created&filter[field_tags.id]=f203b178-3672-4312-b974-4fb5ea8b35cb
查询参数:
| 参数 | 值 |
|---|---|
| include | field_image,field_tags |
| sort | -created |
| filter[field_tags.id] | f203b178-3672-4312-b974-4fb5ea8b35cb |
根据标题筛选文章
GET
{{host}}/jsonapi/node/article?filter[title]=Drupal CMS
查询参数:
| 参数 | 值 |
|---|---|
| filter[title] | Drupal CMS |
根据标题筛选文章(部分匹配)
GET
{{host}}/jsonapi/node/article?filter[title][value]=Drupal&filter[title][operator]=CONTAINS
查询参数:
| 参数 | 值 |
|---|---|
| filter[title][value] | Drupal |
| filter[title][operator] | CONTAINS |
根据发布状态筛选文章
GET
{{host}}/jsonapi/node/article?filter[status]=1
查询参数:
| 参数 | 值 |
|---|---|
| filter[status] | 1 |
2024 年 1 月 1 日之后创建的文章
GET
{{host}}/jsonapi/node/article?filter[created][value]=2024-01-01T00:00:00&filter[created][operator]=>=
查询参数:
| 参数 | 值 |
|---|---|
| filter[created][value] | 2024-01-01T00:00:00 |
| filter[created][operator] | >= |
分页
GET
{{host}}/jsonapi/node/article?page[limit]=5&page[offset]=0
查询参数:
| 参数 | 值 |
|---|---|
| page[limit] | 5 |
| page[offset] | 0 |
组合过滤器(AND 逻辑)
GET
{{host}}/jsonapi/node/article?filter[status]=1&filter[field_tags.meta.drupal_internal__tid]=5
查询参数:
| 参数 | 值 |
|---|---|
| filter[status] | 1 |
| filter[field_tags.meta.drupal_internal__tid] | 5 |
标签
获取标签
GET
{{host}}/jsonapi/taxonomy_term/tags?sort=name&fields[taxonomy_term--tags]=name,drupal_internal__tid
查询参数:
| 参数 | 值 |
|---|---|
| sort | name |
| fields[taxonomy_term--tags] | name,drupal_internal__tid |
文章
文章列表
GET
{{host}}/jsonapi/node/article?include=field_image,field_tags&sort=-created
查询参数:
| 参数 | 值 |
|---|---|
| include | field_image,field_tags |
| sort | -created |
文章图片
GET
{{host}}/jsonapi/node/article/b26c80d2-155c-4c7e-9135-5a4011e2ae17/field_image?resourceVersion=id%3A5
查询参数:
| 参数 | 值 |
|---|---|
| resourceVersion | id:5 |
菜单
主菜单
GET
{{host}}/jsonapi/menu_items/main
页面
根据 ID 获取页面节点
GET
{{host}}/jsonapi/node/page?filter[nid][value]=4
查询参数:
| 参数 | 值 |
|---|---|
| filter[nid][value] | 4 |
根据 UUID 获取页面节点
GET
{{host}}/jsonapi/node/page/8b53db13-613e-45c4-80d7-dc81eba75f11
Webform
Webform
GET
{{host}}/webform/contact
请求头:
| 键 | 值 |
|---|---|
| content-type | application/json |
Webform REST
POST
{{host}}/webform_rest/submit
请求头:
| 键 | 值 |
|---|---|
| Content-Type | application/json |
请求体:
{
"webform_id": "contact",
"name": "Ivan Abramenko",
"subject": "Webform 测试提交",
"email": "levmyshkin89@gmail.com",
"message": "Webform 测试提交"
}
认证
API Key 认证
所有端点都需要使用以下请求头进行 API Key 认证:
| 请求头 | 值 |
|---|---|
| X-API-Key | {{token}} |