SAPUI5 MVC Apps にEDGAR Online データ連携を追加

SAPUI5 でビルトインODataModel を使って、EDGAR Online data をリアルタイムでウェブアプリに連携。

本記事では、CData API Server とADO.NET Provider for EDGAR Online (もしくは210+ の他のADO.NET Providers) を組み合わせて、バックエンドの同期DB を使わずに、リアルタイムEDGAR Online API にリアルタイム連携するSAPUI5 アプリを開発できます。API Server は、EDGAR Online data のOData フィードを生成するライトウェイトなアプリです。OData はSAPUI5 およびOpenUI5 でサポートされています。

Set Up the API Server

Follow the steps below to begin producing secure EDGAR Online OData services:


The API Server runs on your own server. On Windows, you can deploy using the stand-alone server or IIS. On a Java servlet container, drop in the API Server WAR file. See the help documentation for more information and how-tos.

The API Server is also easy to deploy on Microsoft Azure, Amazon EC2, and Heroku.

Connect to EDGAR Online

After you deploy the API Server and the ADO.NET Provider for EDGAR Online, provide authentication values and other connection properties needed to connect to EDGAR Online by clicking Settings -> Connections and adding a new connection in the API Server administration console.

  1. Navigate to and create an account.
  2. Register a new application and retrieve the AppKey. You should select one of the available Web APIs this application will use like HackPack, Insider Trades or Institutional Ownership.
    Note: HackPack is the most important Web API that an application can use since it supports a large number of endpoints. If you are getting the "Access Denied" error you must create a new app and select the correct Web API which supports the resource you are querying.
  3. After successfully creating a new app, you can access your keys through your "my account" area. Set the AppKey connection property value equal to the Key of your application.

You can then choose the EDGAR Online entities you want to allow the API Server access to by clicking Settings -> Resources. This article uses Subscriptions as an example.

Authorize API Server Users

After determining the OData services you want to produce, authorize users by clicking Settings -> Users. The API Server uses authtoken-based authentication and supports the major authentication schemes. You can authenticate as well as encrypt connections with SSL. Access can also be restricted by IP address; Access is restricted to only the local machine by default.

Create the View

In this article the user views and interacts with EDGAR Online data through an SAPUI5 table control. Table columns will be automatically detected from the metadata retrieved from the API Server's API endpoint. We define the following table in a separate View.view.xml file:

          path: 'meta>/dataServices/schema/[${namespace}===\'CData\']/entityType/[${name}===\'Subscriptions\']/property',
          factory: '.columnFactory'
            <m:Title text="EDGAR Online Subscriptions"></m:Title>
          <m:BusyIndicator class="sapUiMediumMargin"/>

Create the Model and Controller

In SAPUI5, you do not need to write any OData queries; an ODataModel instance handles the application's data access commands. The API Server then translates the queries into EDGAR Online API calls.

The controller processes user input and represents information to the user through a view. Define the controller in a new file, Controller.controller.js. Instantiate the model in the onInit function -- you will need to replace the placeholder values for the URL to the API Server, a user allowed to access the OData endpoint of the API Server, and the authtoken for the user.

], function(Controller, ODataModel, JSONModel, Column, Text ) {
  "use strict";

  return Controller.extend("sap.ui.table.sample.OData2.Controller", {
    onInit : function () {
      var oView = this.getView();
      var oDataModel = new ODataModel("http://myserver/api.rsc/",{user: "MyUser", password: "MyAuthToken"});
        oView.setModel(oDataModel.getMetaModel(), "meta");
      var oTable = oView.byId("table");
      var oBinding = oTable.getBinding("rows");
      var oBusyIndicator = oTable.getNoData();
        oTable.setNoData(null); //use default again ("no data" in case no data is available)
    onExit : function () {
    columnFactory : function(sId, oContext) {
      var oModel = this.getView().getModel();
      var sName = oContext.getProperty("name");
      var sType = oContext.getProperty("type");
      var iLen = oContext.getProperty("maxLength");
      iLen = iLen ? parseInt(iLen, 10) : 10;
      return new Column(sId, {
        sortProperty: sName, 
        filterProperty: sName,
        width: (iLen > 9 ? (iLen > 50 ? 15 : 10) : 5) + "rem",
        label: new sap.m.Label({text: "{/#Subscriptions/" + sName + "/@name}"}),
        hAlign: sType && sType.indexOf("Decimal") >= 0 ? "End" : "Begin",
        template: new Text({text: {path: sName}})


Describe Application Logic

Create a component that contains the resources of your application. Define the following in Component.js:

], function(UIComponent) {
  "use strict";

  return UIComponent.extend("sap.ui.table.sample.OData2.Component", {
    metadata : {
      rootView : "sap.ui.table.sample.OData2.View",
      dependencies : {
        libs : [

      config : {
        sample : {
          stretch : true,
          files : [


Bootstrap OpenUI5 and Launch

To complete the MVC application, simply add the bootstrap and initialization code. Add these directly to index.html:


  <meta http-equiv="x-ua-compatible" content="ie=edge" />
  <meta charset="utf-8"> 
  <title>EDGAR Online Subscriptions</title>
  <script id="sap-ui-bootstrap"
    data-sap-ui-resourceroots='{"sap.ui.table.sample.OData2": "./", "sap.ui.demo.mock": "mockdata"}'>
  <!-- application launch configuration -->
      sap.ui.getCore().attachInit(function() {
        new sap.m.App ({
          pages: [
                new sap.m.Page({
                    title: "EDGAR Online Subscriptions", 
                    enableScrolling : false,
                  content: [ new sap.ui.core.ComponentContainer({
                  height : "100%", name : "sap.ui.table.sample.OData2"

  <!-- UI Content -->
<body class="sapUiBody" id="content" role="application">

The resulting SAPUI5 table control reflects any changes to a table in the remote EDGAR Online data. You can now browse and search current EDGAR Online data.