fds.sdk.utils


Namefds.sdk.utils JSON
Version 2.0.1 PyPI version JSON
download
home_pagehttps://developer.factset.com
SummaryUtilities for interacting with FactSet APIs.
upload_time2024-08-28 12:09:00
maintainerNone
docs_urlNone
authorFactSet Research Systems
requires_python<4.0.0,>=3.8.0
licenseApache-2.0
keywords factset api sdk
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <img alt="FactSet" src="https://www.factset.com/hubfs/Assets/images/factset-logo.svg" height="56" width="290">

# FactSet SDK Utilities for Python

[![PyPi](https://img.shields.io/pypi/v/fds.sdk.utils)](https://pypi.org/project/fds.sdk.utils/)
[![Anaconda-Server Badge](https://anaconda.org/factset/fds.sdk.utils/badges/version.svg)](https://anaconda.org/factset/fds.sdk.utils)
[![Apache-2 license](https://img.shields.io/badge/license-Apache2-brightgreen.svg)](https://www.apache.org/licenses/LICENSE-2.0)

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

## Installation

### Poetry

```sh
poetry add fds.sdk.utils
```

### pip

```sh
pip install fds.sdk.utils
```

### Conda

```sh
conda install factset::fds.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](https://developer.factset.com/learn/authentication-oauth2#creating-an-application) on
   FactSet's Developer Portal.
2. When prompted, download the configuration file and move it to your development environment.

```python
from fds.sdk.utils.authentication import ConfidentialClient
import requests

# The ConfidentialClient instance should be reused in production environments.
client = ConfidentialClient(
  config_path='/path/to/config.json'
)
res = requests.get(
  'https://api.factset.com/analytics/lookups/v3/currencies',
  headers={
    'Authorization': 'Bearer ' + client.get_access_token()
  })

print(res.text)
```

### Configure a Proxy

You can pass proxy settings to the ConfidentialClient if necessary.
The `proxy` parameter takes a URL to tell the request library which proxy should be used.

If necessary it is possible to set custom `proxy_headers` as dictionary.

```python
from fds.sdk.utils.authentication import ConfidentialClient

client = ConfidentialClient(
  config_path='/path/to/config.json',
  proxy="http://secret:password@localhost:5050",
  proxy_headers={
    "Custom-Proxy-Header": "Custom-Proxy-Header-Value"
  }
)
```

### Custom SSL Certificate

If you have proxies or firewalls which are using custom TLS certificates,
you are able to pass a custom pem file (`ssl_ca_cert` parameter) so that the
request library is able to verify the validity of that certificate. If a
ca cert is passed it is validated regardless if `verify_ssl` is set to false.

With `verify_ssl` it is possible to disable the verifications of certificates.
Disabling the verification is not recommended, but it might be useful during
local development or testing

```python
from fds.sdk.utils.authentication import ConfidentialClient

client = ConfidentialClient(
  config_path='/path/to/config.json',
  verify_ssl=True,
  ssl_ca_cert='/path/to/ca.pem'
)
```

### Request Retries

In case the request retry behaviour should be customized, it is possible to pass a `urllib3.Retry` object to
the `ConfidentialClient`.

```python
from urllib3 import Retry
from fds.sdk.utils.authentication import ConfidentialClient

client = ConfidentialClient(
  config_path='/path/to/config.json',
  retry=Retry(
    total=5,
    backoff_factor=0.1,
    status_forcelist=[500, 502, 503, 504]
  )
)
```

## Modules

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

### Authentication

The [authentication module](src/fds/sdk/utils/authentication) provides helper classes that
facilitate [OAuth 2.0](https://developer.factset.com/learn/authentication-oauth2) authentication and authorization with
FactSet's APIs. Currently the module has support for
the [client credentials flow](https://github.com/factset/oauth2-guidelines#client-credentials-flow-1).

Each helper class in the module has the following features:

* Accepts a configuration file or `dict` 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 constructors
through a JSON-formatted file or a `dict`. In either case the format is the same:

```json
{
  "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](https://developer.factset.com/applications) and download a configuration file in this
format.

If you're creating and managing your signing key pair yourself, see the
required [JWK parameters](https://github.com/factset/oauth2-guidelines#jwk-parameters) for public-private key pairs.

## Debugging

This library uses the [logging module](https://docs.python.org/3/howto/logging.html) to log various messages that will
help you understand what it's doing. You can increase the log level to see additional debug information using standard
conventions. For example:

```python
logging.getLogger('fds.sdk.utils').setLevel(logging.DEBUG)
```

or

```python
logging.getLogger('fds.sdk.utils.authentication').setLevel(logging.DEBUG)
```

# Contributing

Please refer to the [contributing guide](CONTRIBUTING.md).

# Copyright

Copyright 2022 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.

            

Raw data

            {
    "_id": null,
    "home_page": "https://developer.factset.com",
    "name": "fds.sdk.utils",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0.0,>=3.8.0",
    "maintainer_email": null,
    "keywords": "FactSet, API, SDK",
    "author": "FactSet Research Systems",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/84/86/e2aa9d1e4c13544df08faf4d1af0cd71ad3e0f4337da2f6be95a4163b837/fds_sdk_utils-2.0.1.tar.gz",
    "platform": null,
    "description": "<img alt=\"FactSet\" src=\"https://www.factset.com/hubfs/Assets/images/factset-logo.svg\" height=\"56\" width=\"290\">\n\n# FactSet SDK Utilities for Python\n\n[![PyPi](https://img.shields.io/pypi/v/fds.sdk.utils)](https://pypi.org/project/fds.sdk.utils/)\n[![Anaconda-Server Badge](https://anaconda.org/factset/fds.sdk.utils/badges/version.svg)](https://anaconda.org/factset/fds.sdk.utils)\n[![Apache-2 license](https://img.shields.io/badge/license-Apache2-brightgreen.svg)](https://www.apache.org/licenses/LICENSE-2.0)\n\nThis repository contains a collection of utilities that supports FactSet's SDK in Python and facilitate usage of FactSet\nAPIs.\n\n## Installation\n\n### Poetry\n\n```sh\npoetry add fds.sdk.utils\n```\n\n### pip\n\n```sh\npip install fds.sdk.utils\n```\n\n### Conda\n\n```sh\nconda install factset::fds.sdk.utils\n```\n\n## Usage\n\nThis library contains multiple modules, sample usage of each module is below.\n\n### Authentication\n\nFirst, you need to create the OAuth 2.0 client configuration that will be used to authenticate against FactSet's APIs:\n\n1. [Create a new application](https://developer.factset.com/learn/authentication-oauth2#creating-an-application) on\n   FactSet's Developer Portal.\n2. When prompted, download the configuration file and move it to your development environment.\n\n```python\nfrom fds.sdk.utils.authentication import ConfidentialClient\nimport requests\n\n# The ConfidentialClient instance should be reused in production environments.\nclient = ConfidentialClient(\n  config_path='/path/to/config.json'\n)\nres = requests.get(\n  'https://api.factset.com/analytics/lookups/v3/currencies',\n  headers={\n    'Authorization': 'Bearer ' + client.get_access_token()\n  })\n\nprint(res.text)\n```\n\n### Configure a Proxy\n\nYou can pass proxy settings to the ConfidentialClient if necessary.\nThe `proxy` parameter takes a URL to tell the request library which proxy should be used.\n\nIf necessary it is possible to set custom `proxy_headers` as dictionary.\n\n```python\nfrom fds.sdk.utils.authentication import ConfidentialClient\n\nclient = ConfidentialClient(\n  config_path='/path/to/config.json',\n  proxy=\"http://secret:password@localhost:5050\",\n  proxy_headers={\n    \"Custom-Proxy-Header\": \"Custom-Proxy-Header-Value\"\n  }\n)\n```\n\n### Custom SSL Certificate\n\nIf you have proxies or firewalls which are using custom TLS certificates,\nyou are able to pass a custom pem file (`ssl_ca_cert` parameter) so that the\nrequest library is able to verify the validity of that certificate. If a\nca cert is passed it is validated regardless if `verify_ssl` is set to false.\n\nWith `verify_ssl` it is possible to disable the verifications of certificates.\nDisabling the verification is not recommended, but it might be useful during\nlocal development or testing\n\n```python\nfrom fds.sdk.utils.authentication import ConfidentialClient\n\nclient = ConfidentialClient(\n  config_path='/path/to/config.json',\n  verify_ssl=True,\n  ssl_ca_cert='/path/to/ca.pem'\n)\n```\n\n### Request Retries\n\nIn case the request retry behaviour should be customized, it is possible to pass a `urllib3.Retry` object to\nthe `ConfidentialClient`.\n\n```python\nfrom urllib3 import Retry\nfrom fds.sdk.utils.authentication import ConfidentialClient\n\nclient = ConfidentialClient(\n  config_path='/path/to/config.json',\n  retry=Retry(\n    total=5,\n    backoff_factor=0.1,\n    status_forcelist=[500, 502, 503, 504]\n  )\n)\n```\n\n## Modules\n\nInformation about the various utility modules contained in this library can be found below.\n\n### Authentication\n\nThe [authentication module](src/fds/sdk/utils/authentication) provides helper classes that\nfacilitate [OAuth 2.0](https://developer.factset.com/learn/authentication-oauth2) authentication and authorization with\nFactSet's APIs. Currently the module has support for\nthe [client credentials flow](https://github.com/factset/oauth2-guidelines#client-credentials-flow-1).\n\nEach helper class in the module has the following features:\n\n* Accepts a configuration file or `dict` that contains information about the OAuth 2.0 client, including the client ID\n  and private key.\n* Performs authentication with FactSet's OAuth 2.0 authorization server and retrieves an access token.\n* Caches the access token for reuse and requests a new access token as needed when one expires.\n  * In order for this to work correctly, the helper class instance should be reused in production environments.\n\n#### Configuration\n\nClasses in the authentication module require OAuth 2.0 client configuration information to be passed to constructors\nthrough a JSON-formatted file or a `dict`. In either case the format is the same:\n\n```json\n{\n  \"name\": \"Application name registered with FactSet's Developer Portal\",\n  \"clientId\": \"OAuth 2.0 Client ID registered with FactSet's Developer Portal\",\n  \"clientAuthType\": \"Confidential\",\n  \"owners\": [\n    \"USERNAME-SERIAL\"\n  ],\n  \"jwk\": {\n    \"kty\": \"RSA\",\n    \"use\": \"sig\",\n    \"alg\": \"RS256\",\n    \"kid\": \"Key ID\",\n    \"d\": \"ECC Private Key\",\n    \"n\": \"Modulus\",\n    \"e\": \"Exponent\",\n    \"p\": \"First Prime Factor\",\n    \"q\": \"Second Prime Factor\",\n    \"dp\": \"First Factor CRT Exponent\",\n    \"dq\": \"Second Factor CRT Exponent\",\n    \"qi\": \"First CRT Coefficient\"\n  }\n}\n```\n\nIf you're just starting out, you can visit FactSet's Developer Portal\nto [create a new application](https://developer.factset.com/applications) and download a configuration file in this\nformat.\n\nIf you're creating and managing your signing key pair yourself, see the\nrequired [JWK parameters](https://github.com/factset/oauth2-guidelines#jwk-parameters) for public-private key pairs.\n\n## Debugging\n\nThis library uses the [logging module](https://docs.python.org/3/howto/logging.html) to log various messages that will\nhelp you understand what it's doing. You can increase the log level to see additional debug information using standard\nconventions. For example:\n\n```python\nlogging.getLogger('fds.sdk.utils').setLevel(logging.DEBUG)\n```\n\nor\n\n```python\nlogging.getLogger('fds.sdk.utils.authentication').setLevel(logging.DEBUG)\n```\n\n# Contributing\n\nPlease refer to the [contributing guide](CONTRIBUTING.md).\n\n# Copyright\n\nCopyright 2022 FactSet Research Systems Inc\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Utilities for interacting with FactSet APIs.",
    "version": "2.0.1",
    "project_urls": {
        "Homepage": "https://developer.factset.com"
    },
    "split_keywords": [
        "factset",
        " api",
        " sdk"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "15b0cc4ec076462bb8383d0463003cef3af9052499da0c0a3a1e521b05bbffc1",
                "md5": "71d74ad194fc0208eb26edd283209b76",
                "sha256": "9d1cf732bcdc15a8eef264223d74f3ab92efada39068180c504be4a4691f85d2"
            },
            "downloads": -1,
            "filename": "fds_sdk_utils-2.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "71d74ad194fc0208eb26edd283209b76",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0.0,>=3.8.0",
            "size": 14146,
            "upload_time": "2024-08-28T12:08:59",
            "upload_time_iso_8601": "2024-08-28T12:08:59.765858Z",
            "url": "https://files.pythonhosted.org/packages/15/b0/cc4ec076462bb8383d0463003cef3af9052499da0c0a3a1e521b05bbffc1/fds_sdk_utils-2.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8486e2aa9d1e4c13544df08faf4d1af0cd71ad3e0f4337da2f6be95a4163b837",
                "md5": "92dd7678074abdf6f1ba45d17140b122",
                "sha256": "af906c4bc4422f472545f8c368bc92a5b9e7babdfb921a5b54939f244bc31c88"
            },
            "downloads": -1,
            "filename": "fds_sdk_utils-2.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "92dd7678074abdf6f1ba45d17140b122",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0.0,>=3.8.0",
            "size": 13503,
            "upload_time": "2024-08-28T12:09:00",
            "upload_time_iso_8601": "2024-08-28T12:09:00.653573Z",
            "url": "https://files.pythonhosted.org/packages/84/86/e2aa9d1e4c13544df08faf4d1af0cd71ad3e0f4337da2f6be95a4163b837/fds_sdk_utils-2.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-28 12:09:00",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "fds.sdk.utils"
}
        
Elapsed time: 1.04820s