MATLAB: How to fetch and process data from a set of RESTful web APIs using MATLAB

endpointhttpinterfaceMATLABrequestresponserest

How can I fetch and process data from a set of RESTful web APIs using MATLAB?

Best Answer

The most common method of performing this task is to use the "webread" function. 
The "webread" function accepts a URL for a specific API endpoint and it fetches data from this endpoint by making an HTTP request. If the response data is in a format that MATLAB recognizes, such as JSON or XML, the "webread" function will process this data and return the data in a form that is easier to use in MATLAB, such as a structure array. Otherwise, the response from the API endpoint will be returned as it is. More information about the "webread" function can be found on the following documentation page. 
For example, in the section titled "Read Data from Web Service API" on the above documentation page, the "webread" function is used to fetch data from a specific API endpoint (specified by the URL). Since this data is returned by the API endpoint in JSON format, the "webread" function is able to convert the response into a structure array of data. 
The documentation for the API endpoints should instruct how to construct the actual URL for the endpoint that you wish to communicate with. 
If the call to the "webread" function needs to be customized, then a "weboptions" object can be passed as an additional input argument to the "webread" function. For example, the "weboptions" object can be used to specify an API key if one is needed. More information about the "weboptions" function can be found at the following documentation page:
The section in the "webread" documentation page titled "Specify Request Option" provides an example demonstrating how to use the "weboptions" object in a call to "webread". 
Related Question