How to access WP REST API for WordPress.com sites?

我们两清 提交于 2019-12-04 05:31:16

问题


I see WordPress.com recently started using Gutenberg, which relies on the WP REST API. I'm building a plugin and I'd like to use the WP REST API from a self-hosted site, and have it communicate with a WordPress.com site, but I'm having trouble finding the REST API base URL. For example, https://cmljnelson.wordpress.com/wp-json is a 404. The documentation about REST API discovery doesn't seem to apply to WordPress.com. How can I find the WP REST API base URL for WordPress.com sites?


回答1:


WordPress.com's REST API apparently is shared among sites hosted there and you can access it here: https://public-api.wordpress.com/wp/v2/.

If you want access to the REST routes of a specific site in WordPress.com, use the /sites route:

https://public-api.wordpress.com/wp/v2/sites/{site-id or domain}/

Further reading:

  • WordPress REST API on WordPress.com.
  • WordPress.com REST API Resources.
  • WordPress.com API Console.


来源:https://stackoverflow.com/questions/53344737/how-to-access-wp-rest-api-for-wordpress-com-sites

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!