API Overview
The API specification of the FDC3 standard support the following goals:
- Create a consistent developer interface for working with FDC3
- Standardize interfaces for reference implementations
- Standardize interfaces between desktop agents
The role of FDC3 API specification is to establish a baseline interface for interoperability between applications. Because FDC3 is largely an agreement between existing platforms and applications - standards should be optimized for ease of adoption rather than functional completeness. Functionality absent from a FDC3 specification is in no way a commentary on its importance.
The focus of the FDC3 Standard Working Group has been to create a small but consistent API, the following docs go through the components and API's in detail.
Key Elements
window.fdc3
global object andfdc3Ready
event, for accessing FDC3 operations globallyDesktopAgent
interface, which exposes FDC3 operationsChannel
interface, for subscribing to specific context channelsListener
interface, which allows unsubscribing intent or context listeners
Usage
There are two main ways FDC3 can be used from web applications:
1. Direct Usage
Simply rely on the global object being made available by your desktop agent, and address the API directly:
function sendData() {
window.fdc3.broadcast({
type: 'fdc3.instrument',
id: { ticker: 'AAPL' }
})
}
if (window.fdc3) {
sendData();
} else {
window.addEventListener("fdc3Ready", sendData);
}
2. NPM Wrapper
The @finos/fdc3
npm package provides a wrapper around FDC3, allowing you to use it with ES6 import syntax:
import * as fdc3 from '@finos/fdc3'
await fdc3.raiseIntent('ViewAnalysis', {
type: 'fdc3.instrument',
id: { ticker: 'AAPL' }
})
It also includes a helper function you can use to wait for FDC3 to become available:
import { fdc3Ready, addIntentListener } from '@finos/fdc3'
await fdc3Ready();
const listener = addIntentListener('ViewAnalysis', instrument => {
// handle intent
})