Looking at this post, I may have spoken to soon and it may not be available in the spec object, but you do have access to the API ID.
What you could do is fetch the API ID in the middleware using the dashboard or gateway REST API, then cache it so you can look it up quickly on the next request.