Main Content

getData

Retrieve Bloomberg Hypermedia data for a given request

Since R2023b

Description

example

[data,response] = getData(c,userCatalog,requestID,requestDate) retrieves Bloomberg® Hypermedia data for a given request, where c is the Bloomberg Hypermedia connection object, userCatalog is your catalog ID from Bloomberg, requestID is the request identifier, and requestDate is the creation date of requestID.

[data,response] = getData(c,userCatalog,requestID,requestDate,outputFormat) retrieves Bloomberg Hypermedia request data for a specific format type contained in outputFormat.

Examples

collapse all

Once you create and run a request on the Bloomberg server, you can retrieve the data using the getData function.

Create a Bloomberg Hypermedia connection object by using the API key provided by Bloomberg.

credentialsString = '{"client_id":"89beaeab724bbdf5e186b733c58af2","client_secret":"77050429aee81eb31793fb10fa4301c54911db545de8b2990252ffe2b56b11","name":"BloombergHAIDevelopment","scopes":["eap","beapData","reportingapi"],"expiration_date":1699198358934,"created_date":1651764758934}'
c = bloombergHypermedia(credentialsString)
c = 
 
  bloombergHypermedia with properties:

      TimeOut: 200.00

Specify your catalog ID, request ID, request date, and use the getData function to retrieve the data. If you do not specify the output format, it defaults to bbg. Replace "123" with your login credentials for the catalog you want to access.

userCatalog = "123";
requestID = "r20220523195612215b68";
requestDate = "20220523";
[data,response] = getData(c,userCatalog,requestID,requestDate)
data =

  1×6 table

        SECURITIES        ERROR CODE    NUM FLDS        PX_BID           PX_LAST          ID_BB_GLOBAL  
    __________________    __________    ________    ______________    ______________    ________________

    {'SHOP US Equity'}      {'0'}        {'3'}      {'368.480000'}    {'368.490000'}    {'BBG008HBD923'}


response = 

  ResponseMessage with properties:

    StatusLine: 'HTTP/1.1 200 OK'
    StatusCode: OK
        Header: [1×14 matlab.net.http.HeaderField]
          Body: [1×1 matlab.net.http.MessageBody]
     Completed: 1

The market data is now in the MATLAB® workspace. You can now use the data to make investment decisions related to risk and return optimization.

Input Arguments

collapse all

Bloomberg Hypermedia connection, specified as a Bloomberg Hypermedia object.

User catalog identifier, specified as a character vector or string scalar.

Request identifier, specified as a character vector or string scalar.

Request creation date, specified as a character vector or string scalar in YYYYMMDD format.

Format of the data request output, specified as a json or csv. If you do not specify an output format, getData retrieves the data in bbg format.

Output Arguments

collapse all

Request data, returned as a MATLAB table.

HTTP request response, returned as a ResponseMessage object. For details, see matlab.net.http.ResponseMessage.

Version History

Introduced in R2023b