Overview
This project utilizes Apache Kafka to extract stock data from the Polygon.io API and stores it in an Apache Cassandra database. It leverages Python for implementation and Confluent for Kafka management.
Step-by-Step Analysis
Step 1: Import Required Libraries
import requests import os import json from dotenv import load_dotenv from confluent_kafka import Producer
requests : A library for making HTTP requests to external APIs.
os: Used to access environment variables.
json: For encoding and decoding JSON data.
dotenv: Loads environment variables from a .env file, keeping sensitive information secure.
confluent_kafka: Provides the Kafka Producer class for sending messages to Kafka topics.
Step 2: Load Environment Variables
load_dotenv()
This line reads the .env file and loads the environment variables, allowing for secure management of sensitive information like API keys and connection details.
Step 3: Set Up API Parameters
api_key = os.getenv('API_KEY_DATA') params = { 'adjusted': True,…