npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@factset/sdk-utils

v2.0.1

Published

Utilities for interacting with FactSet APIs.

Downloads

2,619

Readme

FactSet SDK Utilities for TypeScript and JavaScript

npm Apache-2 license

This repository contains a collection of utilities that supports FactSet's SDK in TypeScript and JavaScript, and facilitate usage of FactSet APIs.

Installation

npm

npm install @factset/sdk-utils

yarn

yarn add @factset/sdk-utils

Usage

This library contains multiple modules, sample usage of each module is below.

Authentication

First, you need to create the OAuth 2.0 client configuration that will be used to authenticate against FactSet's APIs:

  1. Create a new application on FactSet's Developer Portal.
  2. When prompted, download the configuration file and move it to your development environment.
import { ConfidentialClient } from '@factset/sdk-utils';
import axios from 'axios';

async function exampleRequest() {
  // The ConfidentialClient instance should be reused in production environments.
  const confidentialClient = new ConfidentialClient('/path/to/config.json');
  const accessToken = await confidentialClient.getAccessToken();

  const response = await axios.get('https://api.factset.com/analytics/lookups/v3/currencies', {
    headers: {
      Authorization: `Bearer ${accessToken}`,
    },
  });

  console.log(response.data);
}

exampleRequest();

Configure a Proxy

You can pass proxy settings to the ConfidentialClient if necessary. The proxy URL can be passed as an object with the proxyUrl property:

const confidentialClient = new ConfidentialClient('/path/to/config.json', { proxyUrl: 'http://username:[email protected]:8080' });

Modules

Information about the various utility modules contained in this library can be found below.

Authentication

The authentication module provides helper classes that facilitate OAuth 2.0 authentication and authorization with FactSet's APIs. Currently, the module has support for the client credentials flow.

Each helper class in the module has the following features:

  • Accepts a Configuration instance that contains information about the OAuth 2.0 client, including the client ID and private key.
  • Performs authentication with FactSet's OAuth 2.0 authorization server and retrieves an access token.
  • Caches the access token for reuse and requests a new access token as needed when one expires.
    • In order for this to work correctly, the helper class instance should be reused in production environments.

Configuration

Classes in the authentication module require OAuth 2.0 client configuration information to be passed to the constructor in the ConfidentialClient through a JSON-formatted file or a ConfidentialClientConfiguration object. Below is an example of a JSON-formatted file:

{
    "name": "Application name registered with FactSet's Developer Portal",
    "clientId": "OAuth 2.0 Client ID registered with FactSet's Developer Portal",
    "clientAuthType": "Confidential",
    "owners": ["USERNAME-SERIAL"],
    "jwk": {
        "kty": "RSA",
        "use": "sig",
        "alg": "RS256",
        "kid": "Key ID",
        "d": "ECC Private Key",
        "n": "Modulus",
        "e": "Exponent",
        "p": "First Prime Factor",
        "q": "Second Prime Factor",
        "dp": "First Factor CRT Exponent",
        "dq": "Second Factor CRT Exponent",
        "qi": "First CRT Coefficient"
    }
}

The other option is to pass in the ConfidentialClientConfiguration instance which is initialised as shown below:

const confidentialClientConfiguration = {
    name: "Application name registered with FactSet's Developer Portal",
    clientId: "OAuth 2.0 Client ID registered with FactSet's Developer Portal",
    clientAuthType: "Confidential",
    owners: ["USERNAME-SERIAL"],
    jwk: {
        kty: "RSA",
        use: "sig",
        alg: "RS256",
        kid: "Key ID",
        d: "ECC Private Key",
        n: "Modulus",
        e: "Exponent",
        p: "First Prime Factor",
        q: "Second Prime Factor",
        dp: "First Factor CRT Exponent",
        dq: "Second Factor CRT Exponent",
        qi: "First CRT Coefficient"
    }
};

If you're just starting out, you can visit FactSet's Developer Portal to create a new application and download a configuration file in this format.

If you're creating and managing your signing key pair yourself, see the required JWK parameters for public-private key pairs.

Contributing

Please refer to the contributing guide.

Copyright

Copyright 2024 FactSet Research Systems Inc

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.