Skip to main content

Event Delivery Client SDKs

This section demonstrates some of the tasks you can complete with JavaScript SDKs. Macrometa offers the following SDKs:

Pre-requisites

  • Download photoniq-eds-ws.min.js or photoniq-eds-sse.min.js from section above.
  • Attach the module to your html:
<script src="path/to/photoniq-eds-ws.min.js"></script>
<!-- or -->
<script src="path/to/photoniq-eds-sse.min.js"></script>

Basic Example

Connect to Event Delivery Service, retrieve and subsribe to SQL:

let config = {
host: "<YOUR-PHOTONIQ>.photoniq.macrometa.io",
customerId: "<YOUR-CUSTOMER-ID>",
apiKey: "<YOUR-API-KEY>",
fabric: "<YOUR-FABRIC>",
};

let connection = PhotoniqEdsWs.connect(config);

let querySet = connection.querySet();

querySet.retrieveAndSubscribe("SELECT * FROM <YOUR-COLLECTION> WHERE key=<YOUR-KEY>", (event) => {
console.log(`Message event: `, event);
})
note

The example uses the WebSocket client. To use an SSE connection, replace PhotoniqEdsWs with PhotoniqEdsSse.

Config Schema

PropertyTypeRequredDescription
hoststringYesHost of the connectionn
fabricstringNoFabric to be used. Default is _system
customerIdstringYesCustomer ID credentails
apiKeystringYesApiKey credentails
pingSecondsnumberNoSeconds between ping-pong messages to the server. Default is 29

Disconnect

To gracefully disconnect from the Event Delivery Service:

connection.disconnect();