NV Manufacturing Analytics

S. "Leo" Tindle / Joshua Roth-Colson

API

There are several ways to use the API. The simplest method is to use the premade widgets, but it can be accessed using the Javascript API library or by any other means where the raw data can be received from an HTTP request. The HTTP API itself tries to follow the REST paradigm, but also provides extra functionality where it might be required, such as the callback parameter when performing Cross-Site Scripting.

Premade Widgets

See: Premade Widgets

Premade Widgets are lines of iframe-based code that you can place into your web pages to display common representations of information in the Request for Discovery/Supplier Discovery database. By using just one line of code, an automatically-updated representation of the requested information will be displayed, with custom sizing available to fit into any design. These widgets will automatically call the APIs detailed below as needed.

Widget Example: Process Cloud


This is an example of the Process Cloud widget, which displays all of the processes currently in the RfD taxonomy, with the font size of each process reflecting its prevalence across all suppliers.

HTTP-based API

See: HTTP-based API

An HTTP-based API is available at the dedicated root URL of http://api.eresourcecenter.org/nvman/ for use in a wide array of applications in any language that can process JSON dictionaries. This API has been designed to provide JSON outputs from basic HTTP calls in a simple and RESTful manner. It also provides the framework for the Javascript API, which provides basic Javascript functions for querying the HTTP-based API, as well as additional structures for further processing.

Javascript API

See: Javascript API

A Javascript API library is available by including the following <script> tags within the <head> tag of the desired page:

   1 <html>
   2   <head>
   3     <title> ... </title>
   4     <script src="//static.eresourcecenter.org/erapi/erapi.js"
   5             type="text/javascript"></script>
   6     <script src="//static.eresourcecenter.org/erapi/nvman.js"
   7             type="text/javascript"></script>
   8   </head>
   9   <body>
  10     ...
  11   </body>
  12 </html>

This library provides an easy-to-use interface in your own browser-based applications, and has the advantage of not requiring that your applications deal with the issues of Cross-Site Scripting that would normally be required when running on your own domain.

The performance of the Javascript API has been enhanced by its use of a callback architecture, which prevents the API from blocking execution of other code while the asynchronous request is processing. This is similar to many other Javascript libraries (such as Dojo), and makes it possible to create high-performance applications.

As an example of how to use this feature of the API, the following code shows how to create a page with an up-to-date count of the number of suppliers supporting the Drilling process:

   1 <html>
   2   <head>
   3     <title>API Example</title>
   4     <script src="//static.eresourcecenter.org/erapi/erapi.js"
   5             type="text/javascript"></script>
   6     <script src="//static.eresourcecenter.org/erapi/nvman.js"
   7             type="text/javascript"></script>
   8   </head>
   9   <body>
  10     <div>There are <span id="drilling_suppliers">(loading)</span> 
  11          suppliers that support Drilling.</div>
  12     <script type="text/javascript">
  13       erapi.nvman.get_process("drilling", function (data) {
  14         var node = document.getElementById("drilling_suppliers");
  15         node.innerHTML = data.suppliers;
  16       });
  17     </script>
  18   </body>
  19 </html>

Actual Example

There are (loading) suppliers that support Drilling.

The Reason for "//" at the Beginning of "src" Properties


In the above example code, all "src" properties of script tags begin with "//". This is intentional, and is designed to allow the script to be loaded across either unencrypted (HTTP) or encrypted (HTTPS) channels, depending on the status of the page that is loading the script. Without the "//", encrypted pages could attempt to load the scripts across an unencrypted connection, which most browsers will treat as a security risk and subsequently alert the user. Additionally, unencrypted pages could also possibly attempt to load the scripts across an encrypted connection, which may cause unneeded latency.

Command Line Access

As this API does not need to be aware of any session or context other than the provided URI, it is very simple to access the data from the command line using any application that can perform HTTP requests. This type of command line access is useful when generating reports using common shell commands.

The following is an example using the CLI utility curl:

   1 $ curl http://api.eresourcecenter.org/nvman/oebuckets
   2 {
   3   // Reformatted for readability
   4   // Actual output removes whitespace/carriage returns
   5   "buckets": {
   6     "association": {
   7       "entries": 47,
   8       "title": "association",
   9       "uri": "/nvman/oebuckets/association"
  10     },
  11     "certification": {
  12       "entries": 65,
  13       "title": "certification",
  14       "uri": "/nvman/oebuckets/certification"
  15     },
  16     "format": {
  17       "entries": 233,
  18       "title": "format",
  19       "uri": "/nvman/oebuckets/format"
  20     },
  21     "metal": {
  22       "entries": 550,
  23       "title": "metal",
  24       "uri": "/nvman/oebuckets/metal"
  25     },
  26     "model": {
  27       "entries": 238,
  28       "title": "model",
  29       "uri": "/nvman/oebuckets/model"
  30     },
  31     "otherMaterial": {
  32       "entries": 50,
  33       "title": "otherMaterial",
  34       "uri": "/nvman/oebuckets/otherMaterial"
  35     },
  36     "plastic": {
  37       "entries": 106,
  38       "title": "plastic",
  39       "uri": "/nvman/oebuckets/plastic"
  40     },
  41     "segment": {
  42       "entries": 359,
  43       "title": "segment",
  44       "uri": "/nvman/oebuckets/segment"
  45     },
  46     "standard": {
  47       "entries": 72,
  48       "title": "standard",
  49       "uri": "/nvman/oebuckets/standard"
  50     }
  51   },
  52   "entries": 1720
  53 }
  54 $

Goals

API Goals

  • Supported for two years
  • No authentication necessary
  • RESTful
  • API Root: http://api.eresourcecenter.org/nvman

Documentation Goals

  • Every API function fully documented
  • Example code for each

Kit Goals

  • Full Javascript data client without external dependencies
  • Full Javascript widgets available within iframes (external dependencies may be allowed, such as Dojo)
  • Static file root: http://static.eresourcecenter.org/api/nvman


Univ/NvManAnalytics (last edited 2013-02-22 23:55:16 by jroth)