FUNCTION REFERENCE

webread

Read content from a web service (HTTP or HTTPS GET).

Read content from a web service (HTTP or HTTPS GET).

Syntax

data = webread(url)

Syntax

data = webread(url, name1, value1, ...)

Syntax

data = webread(..., options)

Name/value pairs are added to the URL as a percent-encoded query (numeric values as comma-separated numbers). options comes from weboptions. With ContentType 'auto', a JSON response (application/json or +json) is decoded as jsondecode does, a text response (text/*, XML, JavaScript) is returned as a character vector and anything else as a uint8 column vector of the bytes. ContentType 'text', 'json' and 'binary' force one of these; 'raw' returns text responses as text without decoding JSON. Redirects are followed (at most 10). A status of 400 or more is an error.

Example

data = webread('https://api.example.org/items', 'page', 2)   % decoded JSON struct

Example

html = webread('https://example.org', weboptions('Timeout', 20))

Differences from MATLAB: Requests run through the system curl program (Windows 10 and later, macOS and most Linux systems include it); there is no webread in the browser console. GET only; no Username/Password, key or certificate options. Images, audio, tables and XML documents are not parsed (ContentType 'image', 'audio', 'table', 'xmldom'); image and audio responses come back as uint8 bytes. Responses are limited to 64 MiB.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.