Make WordPress Core

Opened 5 months ago

Last modified 4 weeks ago

#49116 new enhancement

Add Links to the REST version of a Resource in the header of the page

Reported by: dshanske Owned by:
Milestone: 5.5 Priority: normal
Severity: normal Version: 4.7
Component: REST API Keywords: needs-patch needs-unit-tests dev-feedback
Focuses: rest-api Cc:


Proposing as suggested by @timothybjacobs in Slack, that on each page, a link in the header of the HTML file to the REST route for that resource.

So, an author page would link to the user endpoint for that user. A post to the rest route to that specific post, etc.

The rel on the link to the REST API endpoint is rel="https://api.w.org/". This should probably be a rel="alternate" which indicates an alternative representation of the page, with type "application/json" as it is technically a json representation of the page, but this may need more discussion.

Change History (6)

#1 @TimothyBlynJacobs
5 months ago

I would agree that alternate makes sense for the relation. https://html.spec.whatwg.org/multipage/links.html#rel-alternate

#2 @dshanske
4 months ago

@TimothyBlynJacobs Do we want to try to get this in for the next release?

This ticket was mentioned in Slack in #core-restapi by dshanske. View the logs.

4 weeks ago

#5 @dshanske
4 weeks ago

Been looking at this again, and the problem with this is that mime type application/json is too generic. It doesn't indicate this is a rest return. And the api.w.org alternate compound rel I was looking at was ignored by many of the third-party parsers I tried.

So, the best solution appears to be to register a vendor specific mime type for the rest api. https://www.iana.org/form/media-types. I would suggest application/vnd.wordpress+json or application/vnd.wp+json. Then we can simply identify a wordpress rest api resource link. This may require a separate issue to discuss.

#6 @dshanske
4 weeks ago

  • Milestone changed from Awaiting Review to 5.5
Note: See TracTickets for help on using tickets.