3 ms·
If you need separate responses for each resource, why not make separate requests in the first place? - OR - You can design a structured format that communicat
by niftich 10y ago
If you need separate responses for each resource, why not make separate requests in the first place?
- OR -
You can design a structured format that communicates the information you want. For example, a format based on JSON with an array of objects, or a format based on JSON with an key-value map of objects (ie. object of objects).
- themihai 10y agoWell that's exactly what I need: A format that communicates structured data, friendly with GET requests and backward compatible with query string encoding. Why there is no such format/standard yet? Is it that unusual?
- niftich 10y agoThere are ready-made mediatypes to communicate collections; some have even been registered as mediatypes with IANA. A simple one that would meet your needs is Collection+JSON [1]. There are others. This blog post [2] from 2014 lists some from a hypermedia perspective, although you may find some of these formats excessive for what you're trying to accomplish. Before JSON became a favorite for HTTP APIs, there used to be XML-based ones as well. AtomPub is a very good protocol, which defines an 'application/atomcoll+xml' mediatype for collections [3] [1] http://amundsen.com/media-types/collection/ http://amundsen.com/media-types/collection/ [2] http://sookocheff.com/post/api/on-choosing-a-hypermedia-format/ http://sookocheff.com/post/api/on-choosing-a-hypermedia-form... [3] http://bitworking.org/projects/atom/draft-ietf-atompub-protocol-04.html#collection_resource http://bitworking.org/projects/atom/draft-ietf-atompub-proto...