Main Content

createRequest

Create Bloomberg Hypermedia data request

Since R2023b

Description

example

[requestID,response] = createRequest(c,userCatalog,payload) creates a Bloomberg® Hypermedia data request, where c is the Bloomberg Hypermedia connection object, userCatalog is your catalog ID from Bloomberg, and payload is a structure that defines the request.

example

[requestID,response] = createRequest(c,userCatalog,universeID,fieldListID,triggerID) alternatively creates a Bloomberg Hypermedia data request that specifies the universe, field list, and trigger identifiers.

Examples

collapse all

Create a Bloomberg Hypermedia data request.

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 and create the payload structure that holds the essential query information required by the Bloomberg Hypermedia data server.

userCatalog = "123";
payload.type = "HistoryRequest";
payload.identifier = requestID;
payload.title = "My History Request";
payload.description = "My favorite history request";
payload.universe = strcat(testCase.connection.URL,"/eap/catalogs/123/universes/u2022060615481086fc10");
payload.fieldList = strcat(testCase.connection.URL,"/eap/catalogs/123/fieldLists/histFieldList2022060611005354b015");
payload.trigger = strcat(testCase.connection.URL,"/eap/catalogs/bbg/triggers/oneshot/");
payload.formatting.type = "HistoryFormat";
payload.formatting.dateFormat = "yyyymmdd";
payload.formatting.fileType = "unixFileType";
payload.formatting.displayPricingSource = true;

% add options for historical request
payload.runtimeOptions.type = "HistoryRuntimeOptions";
payload.runtimeOptions.historyPriceCurrency = "USD";
payload.runtimeOptions.period = "daily";
payload.runtimeOptions.dateRange.type = "IntervalDateRange";
payload.runtimeOptions.dateRange.startDate = string(datetime('today','Format','yyyy-MM-dd')-10);
payload.runtimeOptions.dateRange.endDate = string(datetime('today','Format','yyyy-MM-dd'));
payload.pricingSourceOptions.type = "HistoryPricingSourceOptions";
payload.pricingSourceOptions.exclusive = true;

Use the createRequest function to create the data request.

[requestID,response] = createRequest(c,userCatalog,payload)
requestID = 

    "r202303211130197aaa0d"


response = 

  ResponseMessage with properties:

    StatusLine: 'HTTP/1.1 201 CREATED'
    StatusCode: Created
        Header: [1×15 matlab.net.http.HeaderField]
          Body: [1×1 matlab.net.http.MessageBody]
     Completed: 0

You can also call the createRequest function using the arguments universeID, fieldlistID, and triggerID. The triggerID argument is optional and defaults to a one-time request if not specified.

universeID = "u20220126162804d2b7dd";
fieldlistID = "fieldList202201261703442bf16a";
[requestID,response] = createRequest(c,userCatalog,universeID,fieldlistID)
requestID = 
  
      "r20220524135441e10a41"
  
  
response = 
  
    ResponseMessage with properties:
  
      StatusLine: 'HTTP/1.1 201 CREATED'
      StatusCode: Created
          Header: [1×14 matlab.net.http.HeaderField]
            Body: [1×1 matlab.net.http.MessageBody]
       Completed: 1

After you create the request and it runs on the Bloomberg server, you can retrieve the returned data from MATLAB® by using the getRequests and getData functions.

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 information, specified as a structure array.

Universe identifier, specified as a character vector or string scalar. If you use payload instead of userCatalog for the second input argument, universeID is not required.

Field list identifier, specified as a character vector or string scalar. If you use payload instead of userCatalog for the second input argument, fieldListID is not required.

Trigger identifier, specified as a character vector or string scalar. This argument is not required and the default is /eap/catalogs/bbg/triggers/oneshot/.

Output Arguments

collapse all

Field list identifier, returned as a string scalar.

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

Version History

Introduced in R2023b