Flexibility

The data from the API should be independent of resources or methods. It implies REST API should handle multiple types of calls and return various data formats, even with some change in the structure representing hypermedia. In other words, the data of the API response isn't tied to the resources or methods.

The GitHub API summary representations and detailed representations may be examples of API flexibility. List of repository API GET /orgs/myorg/repos gets the summary representation, and single repository API GET /repos/myorg/myhelloworld.rb fetches the detailed description of the indicated repository.

The Salesforce API provides flexibility with its response formats, so API developers can serialize the data in either XML or JSON format.

GraphQL endpoint implementation for API developers is another best example of API flexibility. With GraphQL, developers can request the data that they want based on a predefined schema and so the API can respond according to the predefined schema:

The preceding screenshot reflects a sample GraphQL request (schema) for specific fields (book name and rating) and response with specified fields.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.27.251