This may be one of the first questions to come to mind when designing a RESTful web service. However, no single format may be right for all kinds of resources and representations. Picking up a format like JSON or XML for all representations may reduce the flexibility that HTTP has to offer.
You want to know how to choose a format and a media type for representations.
Keep the choice of media types and formats flexible to allow for varying application use cases and client needs for each resource.
Determine whether there is a standard format and media type that matches your use cases. The best place to start your search is the Internet Assigned Numbers Authority (IANA, http://www.iana.org/assignments/media-types/) media type registry.
If there is no standard media type and format, use extensible
formats such as XML (
application/xml), Atom Syndication
application/atom+xml), or JSON (
Use image formats like
image/png or rich document
application/pdf to provide alternative representations of
data. When using such formats, consider adding a
Content-Disposition header, as in
filename=<status.xls> to give a hint of the filename that
the client could use to save the representation to the
Prefer to use well-known media types for representations. If you are designing a new media type, register the format and media ...