Bill Garrison Bill Garrison - 1 year ago 91
reST (reStructuredText) Question

Rest API - Getting one-off information for an object

Here is my example. I have a basic rest api for a Member. Simple CRUD. Project manager says "we need an endpoint that will return the remaining pension amount for that member.

I get this stuff a lot where they want a very specific piece of information about an object.I don't want to include this in the Read request as the calculation can be time consuming. So, how do I do this in a RESTful way??

Answer Source

You could create a new endpoint called Pension, which could have a RemainingAmount property (and probably a RemainingCurrencyIso one, too), and expose that through a link from the Member resource like so:

GET /api/member/{id}/pension

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download