The response structure used by IPNI for GET /multihash/<multihash> is optimised for batch find: it includes the multihash that is being looked up as base64 encoded string, along with a nested array of results.
I believe the rationale has been to use the same response model for both batch find, and single find request. For non-streaming responses this is fine; however, for responses streamted using new-line delimited json (i.e. ndjson) it becomes suboptimal:
in ndjson each response needs to be a JSON object.
because the results for a single mulithash are nested in an array, to stream the response using the current model one has to repeat the multihash that is being looked up in every streamed response.
This is less than optimum considering the vast majority of traffic received by cid.contact is for explicit multihash lookups.
Consider spec changes for a more optimal response structure for single multihash lookup, such that:
the original multihash looked up via GET request is not repeated in the response or optionally included.
the response model is preferably made up of a series of self contained JSON objects optimised for the streaming case, which hopefully becomes the default/preferred response media type when Accept request header permits it.
The response structure used by IPNI for
GET /multihash/<multihash>
is optimised for batch find: it includes the multihash that is being looked up as base64 encoded string, along with a nested array of results.I believe the rationale has been to use the same response model for both batch find, and single find request. For non-streaming responses this is fine; however, for responses streamted using new-line delimited json (i.e. ndjson) it becomes suboptimal:
This is less than optimum considering the vast majority of traffic received by cid.contact is for explicit multihash lookups.
Consider spec changes for a more optimal response structure for single multihash lookup, such that:
GET
request is not repeated in the response or optionally included.Accept
request header permits it.