Can you anyone tell me what is the best practice?
REST doesn't care what spelling conventions you use for your resource identifiers.
RFC 3986 defines paths and path segments.
The path component contains data, usually organized in hierarchical form...
Many will therefore choose to align their identifier hierarchy with the hierarchy of their resources. It's not required that you do so, but as an organizing principle it's not bad, and of course no worse than any other arbitrarily selected convention.
For example, a common practice is that collection items will have identifier spellings subordinate to the identifier of the collection itself.
/photos <-- the collection
/photos/17 <-- an item in the collection
So you might reasonably ask whether api is one item of several in a membership collection, or if membership is one item of several in an api collection.
You might also want to review relative resolution and how dot-segments can be used to navigate up the hierarchy. If references between memberships and some other idea are more common than references between api and some other idea, then the spelling /api/membership may prove to be the more convenient choice.
I think a good guideline is this: any path segment implies the existence of siblings at the same hierarchical level. /membership/api
implies the existence of /membership/something-that-isnt-api
-- otherwise, why not just /membership
?