Factiva Javascript Library for Dow Jones Users
- Node v13
npm install @factiva/core
Manual Example:
Download Factiva Core Javascript
Run `npm link` at the root directory of Factiva Core
Run `npm link @factiva/core` at the root directory of Factiva News
npm install @factiva/news
npm run babel
Example of importing modules:
const { helper, core } = require('@factiva/core');
const { Snapshot, SnapshotQuery } = require('../lib/factiva/news/snapshot');
- Explain
const s = await Snapshot.create(null, false, {
query: VALID_WHERE_STATEMENT,
});
await s.processExplain();
- Analytics
const s = await Snapshot.create(null, false, {
query: VALID_WHERE_STATEMENT,
});
await s.processAnalytics();
- Extraction
const s = await Snapshot.create(VALID_USER_KEY, false, {
snapshotId: VALID_SNAPSHOT_ID,
});
await s.downloadExtractionFiles();
- Update
const uj = new UpdateJob(null, { updateId: VALID_UPDATE_ID });
await uj.getJobResults();
await uj.downloadJobFiles();
- Create a stream from snapshot id
const stream = new Stream({
snapshotId: '<snapshotId>',
apiKey: '<apiKey>',
});
stream.create().then(result => console.log(result));
- Create a stream from a query
const stream = new Stream({
query: "query",
apiKey: '<apiKey>'
});
stream.create().then(result => console.log(result));
- Get info from an existing Stream
Stream.create({
streamId: '<streamId>',
apiKey: '<apiKey>',
})
.then((stream) => stream.getInfo('<subscriptionId>'))
.then((subscription) => console.log(subscription));
- Delete a stream
const stream = new Stream({
streamId: '<streamId>',
apiKey: '<apiKey>'
});
stream.delete().then(result => console.log(result));
- Deleting a subscription
Stream.create({
streamId: '<streamId>',
apiKey: '<apiKey>',
})
.then((stream) => stream.deleteSubscription('<subscriptionId>'))
.then((subscription) => console.log(subscription));
- Creating a subscription
Stream.create({
streamId: '<streamId>',
apiKey: '<apiKey>',
})
.then((stream) => stream.createSubscription())
.then((subscription) => console.log(subscription));
- Consuming from Pubsub
Stream.create({
streamId: '<streamId>',
apiKey: '<apiKey>',
})
.then((stream) => {
stream.consumeMessages({
subscriptionId: '<subscriptionId>'
});
});
- Get Categories
const taxonomy = await Taxonomy.create(VALID_USER_KEY, false);
const industryCodes = await taxonomy.getCategoryCodes('industries');
- Get Company
const taxonomy = await Taxonomy.create(VALID_USER_KEY);
const companyData = await taxonomy.getCompany('isin', {
companyCode: 'PLUNMST00014',
});
- Get Multiple Companies
const taxonomy = await Taxonomy.create(VALID_USER_KEY, false);
const companiesData = await taxonomy.getCompany('isin', {
companiesCodes: [
'US0378331005',
'US0231351067',
'US5949181045',
'US4523531083',
],
});
For running active tests
npm run test