Skip to main content

A Python package that wraps CNBC API endpoints and returns financial data in JSON.

Project description

CNBC

A Python package that wraps CNBC API endpoints and returns financial data in JSON. The API queries business news and live market data to streamline the development of financial applications.

IMPORTANT LEGAL DISCLAIMER


cnbc is not affiliated, endorsed, or vetted by CNBC, Inc. It is an open-source tool that uses a publicly available API and is intended for research and educational purposes.

Installation

pip install cnbc

Subscribe to CNBC API

Utilization

APIWrapper

The APIWrapper class is used to make requests to the CNBC API.
Note: A majority of the CNBC API endpoints require parameters. These must be set by an additional instruction.

from cnbc import APIWrapper, Endpoints

api_wrapper = APIWrapper(
    api_key='YOUR_API_KEY',
    endpoint=Endpoints.TRANSLATE
)
# The APIWrapper class will supply the required parameters for the configured CNBC API endpoint.
api_wrapper_params = api_wrapper.params
api_wrapper_params['symbol'] = 'AAPL'
# The APIWrapper class will make a request to the CNBC API and return the response in JSON.
json_response = api_wrapper.request()

# The APIWrapper class can be repurposed to make multiple requests to the CNBC API.
api_wrapper.endpoint = Endpoints.GET_SUMMARY
api_wrapper_params = api_wrapper.params
api_wrapper_params['issueIds'] = json_response['issueId']
json_response = api_wrapper.request()

Translate Endpoint

A majority of the CNBC API endpoints require an issueId or issueIds parameter. The translate endpoint is used to convert a symbol to an issueId.
Note: The APIWrapper class contains a translation table which can be loaded and saved to a file to reduce the number of requests to the CNBC API.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cnbc-1.0.0.tar.gz (16.8 kB view hashes)

Uploaded Source

Built Distribution

cnbc-1.0.0-py3-none-any.whl (17.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page