用于访问你的内容的 Strapi API
¥Strapi APIs to access your content
创建并配置 Strapi 项目、使用 内容类型生成器 创建数据结构并开始通过 内容管理者 添加数据后,你可能想要访问你的内容。
¥Once you've created and configured a Strapi project, created a data structure with the Content-Type Builder and started adding data through the Content Manager, you likely would like to access your content.
从前端应用,你的内容可以通过 Strapi 的 Content API 访问,该 API 公开:
¥From a front-end application, your content can be accessed through Strapi's Content API, which is exposed:
-
默认通过 REST API
¥by default through the REST API
-
如果你安装了 Strapi 内置 GraphQL 插件,也可以通过 GraphQL API。
¥and also through the GraphQL API if you installed the Strapi built-in GraphQL plugin.
REST 和 GraphQL API 代表暴露给外部应用的 Content API 的顶层。Strapi 还提供 2 个更底层的 API:
¥REST and GraphQL APIs represent the top-level layers of the Content API exposed to external applications. Strapi also provides 2 lower-level APIs:
-
文档服务 API 是推荐的 API,用于在 后端服务器 内或通过 plugins 与应用的数据库进行交互。文档服务是处理文档 以及 Strapi 复杂数据结构(如组件和动态区域)的层。
¥The Document Service API is the recommended API to interact with your application's database within the backend server or through plugins. The Document Service is the layer that handles documents as well as Strapi's complex data structures like components and dynamic zones.
-
查询引擎 API 与更底层的数据库层交互,并在幕后用于执行数据库查询。它提供对数据库层的无限制内部访问,但不知道 Strapi 5 可以处理的任何高级 Strapi 功能,如草稿和发布、国际化、内容历史记录等。
⚠️ 在大多数(如果不是全部)用例中,你应该改用文档服务 API。¥The Query Engine API interacts with the database layer at a lower level and is used under the hood to execute database queries. It gives unrestricted internal access to the database layer, but is not aware of any advanced Strapi features that Strapi 5 can handle, like Draft & Publish, Internationalization, Content History, and more.
⚠️ In most, if not all, use cases, you should use the Document Service API instead.
本文档部分包括有关以下 Strapi API 的参考信息以及一些与第三方技术的集成指南:
¥This documentation section includes reference information about the following Strapi APIs and some integration guides with 3rd party technologies:
REST API
Query the Content API from a front-end application through REST.
GraphQL API
Query the Content API from a front-end application through GraphQL.
Document Service API
Query your data through the backend server or plugins.
如果你正在寻找如何将 Strapi 与其他平台集成,请参阅 Strapi 的 集成页面。
¥If you're looking for how to integrate Strapi with other platforms, please refer to Strapi's integrations pages.