简体   繁体   中英

in a rest api design, is there a pattern to get history of object

I have to design a REST API resource, where it needs to be possible to GET the previous version, and other history versions of an object.

Is there a useful pattern to achieve this?

Would it be a good idea, eg to amend restapi.baseurl/resourcename/{ID} with restapi.baseurl/resourcename/{ID}/version/{ID}

or are there better design options to achieve this?

RFC5829 defines a number of link relations for usage with versioning.

They include:

  • latest-version
  • version-history
  • predecessor-version
  • successor-version

You can use these link relationships with the Link header, or by choosing a response format for your API that has hypermedia support, such as HAL, JSON:API, Siren, etc.

restapi.baseurl/resourcename/{ID}/history?from_version=x&to_version=y是我更喜欢使用的

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM