Ask HN: In REST APIs, should the version be at the start or end of the path?

1 points by _448 ↗ HN
Say I have this REST API path: /api/ca/cb/cc

Which of the following is a better way to include version string, e.g. v0, in the API?

/api/v0/ca/cb/cc

or

/api/ca/cb/cc/v0

2 comments

[ 2.9 ms ] story [ 11.8 ms ] thread
Whatever works better for you. Generally I'd recommend the former, simply due to the fact the other one might imply everything from vX is a part of vY, which usually isn't the case in my experience. Though, you shouldn't really care about those kind of micro-optimizations at any point of (early) development, let alone post on hn asking about it.
> you shouldn't really care about those kind of micro-optimizations at any point of (early) development

Changing APIs afterwards would become very difficult, hence the reason for early decision.