I'm currently trying to build an API to be used for reporting-purposes. Therefore I do only need to implement some GET
endpoints.
In my simple scenario there are two resources. An event and the creator of the event. Each event has one creator.
For one report I do need all events created between a given time-frame.
GET /api/Events/?start=someStartDate&end=someEndDate
which will get me those events. Now I do need the creators as well.
How can this be done without calling GET /api/Creators/{creatorId}
for each event returned by the first call (which can be quite a lot)?
It's no option to pass event-ids as they are Guid
s which would exceed the maximum url-length for GET
.
Are there any best practices like a new endpoint? But how would this endpoint look like?
I also thought about including the creator directly into the EventResource
. Unfortunately, this got me also headaches as of a creator can have a list of events (which have a creator, which has events, ... and so on).
Would it make sense to have two kinds of resources like some sort of base-eventresource which has only simple properties and an extenden event-resource which has other resources encapsulated? But where should I draw the line? Also I then would need two endpoints for each resource (base and extended) which may confuse the client.
Hope here is the right place for such kind of questions. Maybe the solution is obvious but I'm already in too deep to see it.