### Install Quiver Quantitative Package Source: https://github.com/quiver-quantitative/python-api/blob/main/README.md Install the package using pip. Ensure Python 3 and pip are installed locally. ```python pip install quiverquant ``` -------------------------------- ### Install Dependencies Manually Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/configuration.md Manually install the pandas and requests libraries if not using the quiverquant package. These are the core dependencies. ```bash pip install pandas requests ``` -------------------------------- ### Unix Timestamp Conversion Example Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/api-reference/data-types.md Provides an example of how the client converts Unix timestamps in milliseconds from the API response into pandas.Timestamp objects. This is relevant for endpoints that return time data in this format. ```python df = client.wallstreetbetsCommentsFull() # Raw API response: Time = 1609459200000 (milliseconds since epoch) # After conversion: Datetime = Timestamp('2021-01-01 00:00:00') ``` -------------------------------- ### Get News Across Multiple Tickers Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/usage-patterns.md Aggregate news articles for a list of technology stocks. Useful for getting a broad overview of news impacting a sector. ```python tech_stocks = ["AAPL", "MSFT", "NVDA", "META"] all_news = [] for ticker in tech_stocks: df = client.news(ticker=ticker, page_size="50") all_news.append(df) combined = pd.concat(all_news, ignore_index=True) print(f"Total news items: {len(combined)}") ``` -------------------------------- ### Initialize Client with API Token from ConfigParser Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/configuration.md This example shows how to initialize the Quiver client using an API token read from a 'config.ini' file via Python's ConfigParser. ```python import configparser import quiverquant config = configparser.ConfigParser() config.read('config.ini') token = config['quiver']['api_token'] client = quiverquant.quiver(token) ``` -------------------------------- ### Get News Source: https://github.com/quiver-quantitative/python-api/blob/main/README.md Retrieves recent stock news. Can be filtered by ticker. ```APIDOC ## Get News ### Description Retrieves recent stock news. Can be filtered by ticker. ### Method `quiver.news(ticker=None)` ### Parameters - **ticker** (string) - Optional - The stock ticker symbol (e.g., "ORCL") to filter news for. ``` -------------------------------- ### Get Government Contracts Source: https://github.com/quiver-quantitative/python-api/blob/main/README.md Retrieves data on government contracts. Can be filtered by ticker. ```APIDOC ## Get Government Contracts ### Description Retrieves data on government contracts. Can be filtered by ticker. ### Method `quiver.gov_contracts(ticker=None)` ### Parameters - **ticker** (string) - Optional - The stock ticker symbol (e.g., "LMT") to filter government contracts for. ``` -------------------------------- ### Get All Recent Government Contracts Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/api-reference/quiver-client.md Retrieves all recent government contract awards data. Use this when you need a broad overview of contracts. ```python df = quiver_client.gov_contracts() ``` -------------------------------- ### Handle Empty Query Parameters Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/api-reference/data-types.md Shows that empty string parameters are trimmed and treated as if they were not provided. This example demonstrates filtering out empty values from a payload. ```python # These are equivalent: df1 = client.news(ticker="") df2 = client.news() # An empty parameter is treated as "not provided" payload = {k: v for k, v in payload.items() if v != ""} ``` -------------------------------- ### Verify DataFrame Return Type Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/configuration.md This example demonstrates that all methods return pandas.DataFrame objects. It calls the congress_trading method and prints the type of the returned object. ```python df = quiver_client.congress_trading(ticker="AAPL") print(type(df)) # ``` -------------------------------- ### Handle Missing Data with Empty DataFrame Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/configuration.md This example illustrates how the client handles missing data. When no results are found for a query, an empty DataFrame is returned, and a message is printed to stdout. ```python df = quiver_client.congress_trading(ticker="NONEXISTENT") # Output: No results found print(df.empty) # True ``` -------------------------------- ### Get All Recent Congressional Trades Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/usage-patterns.md Initializes the client and retrieves all recent congressional trading records. Requires an API token. ```python import quiverquant import pandas as pd # Initialize client client = quiverquant.quiver("YOUR_API_TOKEN") # Get all recent congressional trades df = client.congress_trading() print(f"Retrieved {len(df)} records") ``` -------------------------------- ### Get Off-Exchange Short Volume Source: https://github.com/quiver-quantitative/python-api/blob/main/README.md Retrieves data on off-exchange short volume. Can be filtered by ticker. ```APIDOC ## Get Off-Exchange Short Volume ### Description Retrieves data on off-exchange short volume. Can be filtered by ticker. ### Method `quiver.offexchange(ticker=None)` ### Parameters - **ticker** (string) - Optional - The stock ticker symbol (e.g., "AMC") to filter off-exchange short volume for. ``` -------------------------------- ### GET /live/topshareholders/{ticker} Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/endpoints.md Retrieve top shareholders for a company. This endpoint provides a list of top shareholders for a given company ticker. ```APIDOC ## GET /live/topshareholders/{ticker} ### Description Retrieve top shareholders for a company. This endpoint provides a list of top shareholders for a given company ticker. ### Method GET ### Endpoint /live/topshareholders/{ticker} ### Parameters #### Path Parameters - **ticker** (string) - Required - The stock ticker symbol for the company. ### Response Schema ```json { "ownership": [ { "Holder": "string", "Shares": "number", "Percentage": "number" } ] } ``` ### Response Codes 200, 401, 403 ``` -------------------------------- ### GET /live/wsbcommentsfull Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/endpoints.md Retrieve full Wall Street Bets comments. This endpoint provides the complete text of comments from Wall Street Bets. ```APIDOC ## GET /live/wsbcommentsfull ### Description Retrieve full Wall Street Bets comments. This endpoint provides the complete text of comments from Wall Street Bets. ### Method GET ### Endpoint `/live/wsbcommentsfull` ### Query Parameters - **ticker** (string) - Optional - The stock ticker symbol. - **freq** (string) - Optional - The frequency of aggregation (e.g., daily, hourly). - **date_from** (string) - Optional - The start date for the data retrieval. - **date_to** (string) - Optional - The end date for the data retrieval. ### Response #### Success Response (200) - **Ticker** (string) - The stock ticker symbol. - **Text** (string) - The content of the comment. - **Time** (number (milliseconds since epoch)) - The timestamp of the comment. - **Author** (string) - The author of the comment. #### Response Example ```json [ { "Ticker": "string", "Text": "string", "Time": "number (milliseconds since epoch)", "Author": "string" } ] ``` ``` -------------------------------- ### GET /live/offexchange Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/endpoints.md Retrieve recent off-exchange (OTC) short volume data. This endpoint provides information on short volumes traded off the main exchanges. ```APIDOC ## GET /live/offexchange ### Description Retrieve recent off-exchange (OTC) short volume data. This endpoint provides information on short volumes traded off the main exchanges. ### Method GET ### Endpoint /live/offexchange ### Response #### Success Response (200) - **Ticker** (string) - **Date** (ISO8601 datetime) - **Volume** (number) - **PercentageOfVolume** (number) #### Error Response - **401** — Unauthorized (invalid/missing token) - **403** — Forbidden (subscription tier too low) ``` -------------------------------- ### Retrieve All Recent Flight Data Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/api-reference/quiver-client.md Fetches all recent corporate private jet flight data. No specific setup is required beyond initializing the Quiver client. ```python # Get all recent flight data df = quiver_client.flights() ``` -------------------------------- ### Handling Empty DataFrames Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/api-reference/data-types.md When query parameters do not yield any results, the API returns an empty DataFrame. This example shows how to check if a returned DataFrame is empty. ```APIDOC ## Empty DataFrames When no data matches the query parameters, an empty DataFrame is returned: ```python df = client.congress_trading(ticker="INVALID_TICKER") print(df.empty) # True print(df.shape) # (0, 0) or (0, n) depending on response ``` ``` -------------------------------- ### Get Paginated News Articles Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/api-reference/quiver-client.md Retrieves paginated news articles with a specified page size and page number. Returns a pandas DataFrame. ```python df = quiver_client.news(page_size="10", page="2") ``` -------------------------------- ### GET /live/wallstreetbets Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/endpoints.md Retrieve Wall Street Bets discussion data. Supports filtering by date range and an option to count all discussions. ```APIDOC ## GET /live/wallstreetbets ### Description Retrieve discussion data from Wall Street Bets. This endpoint can fetch all discussions or filter by a date range. ### Method GET ### Endpoint `/live/wallstreetbets` or `/live/wallstreetbets?count_all=true` ### Parameters #### Query Parameters - **count_all** (string) - No - Include all discussions when set to `true`. - **date_from** (string) - No - Start date for filtering discussions (YYYYMMDD format). - **date_to** (string) - No - End date for filtering discussions (YYYYMMDD format). ### Response #### Success Response (200) - **data** (array) - Contains discussion data. - **Ticker** (string) - **Date** (ISO8601 datetime) - **Time** (number (milliseconds)) - **Count** (number) #### Response Codes 200, 401, 403 **Subscription Error**: Returns string "Upgrade your subscription plan to access this dataset." ``` -------------------------------- ### Retrieve All Recent Political Beta Data Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/api-reference/quiver-client.md Fetches all recent political beta data for stocks. This data indicates a stock's sensitivity to political and regulatory changes. No specific setup is required beyond initializing the Quiver client. ```python # Get all recent political beta data df = quiver_client.political_beta() ``` -------------------------------- ### Get All Recent Lobbying Activity Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/api-reference/quiver-client.md Retrieves all recent corporate lobbying activity and expenditure data. The 'Date' column is automatically converted to datetime. ```python df = quiver_client.lobbying() ``` -------------------------------- ### GET /beta/historical/lobbying/{ticker} Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/endpoints.md Retrieve historical lobbying for a company. Fetch historical lobbying data for a specific company using its ticker symbol. ```APIDOC ## GET /beta/historical/lobbying/{ticker} ### Description Retrieve historical lobbying for a company. Fetch historical lobbying data for a specific company using its ticker symbol. ### Method GET ### Endpoint /beta/historical/lobbying/{ticker} ### Parameters #### Path Parameters - **ticker** (string) - Required - The stock ticker symbol for the company. ### Response Schema ```json [ { "Ticker": "string", "Company": "string", "Date": "ISO8601 datetime", "LobbyistCount": "number", "Amount": "number" } ] ``` ### Response Codes 200, 401, 403 ``` -------------------------------- ### Retrieve All Recent Patent Filing Data Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/api-reference/quiver-client.md Fetches all recent patent filing data for companies. The 'Date' column is automatically converted to datetime objects. No specific setup is required beyond initializing the Quiver client. ```python # Get all recent patent data df = quiver_client.patents() ``` -------------------------------- ### GET /live/housetrading Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/endpoints.md Retrieve recent House trading activity. This endpoint provides live data on trades made by members of the House of Representatives. ```APIDOC ## GET /live/housetrading ### Description Retrieve recent House trading activity. This endpoint provides live data on trades made by members of the House of Representatives. ### Method GET ### Endpoint /live/housetrading ### Response #### Success Response (200) - **Ticker** (string) - **Representative** (string) - **Date** (ISO8601 datetime) - **Type** (string) - **Amount** (string) #### Error Response - **401** — Unauthorized (invalid/missing token) - **403** — Forbidden (subscription tier too low) ``` -------------------------------- ### Initialize Quiver API Connection Source: https://github.com/quiver-quantitative/python-api/blob/main/README.md Import the package and connect to the API using your obtained token. Replace with your actual API token. ```python #Import the package import quiverquant #Connect to the API using your token #Replace with your token quiver = quiverquant.quiver("") ``` -------------------------------- ### GET /live/govcontractsall Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/endpoints.md Retrieve recent government contracts. This endpoint provides a list of recent government contracts, including details like ticker, company, amount, date, and contract type. ```APIDOC ## GET /live/govcontractsall ### Description Retrieve recent government contracts. This endpoint provides a list of recent government contracts, including details like ticker, company, amount, date, and contract type. ### Method GET ### Endpoint /live/govcontractsall ### Response Schema ```json [ { "Ticker": "string", "Company": "string", "Amount": "number", "Date": "ISO8601 datetime", "ContractType": "string" } ] ``` ### Response Codes 200, 401, 403 ``` -------------------------------- ### Get All Recent Senate Trades Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/api-reference/quiver-client.md Retrieve all recent trading activity by U.S. Senate members. Call the method without any parameters to get all records. ```python # Get all recent Senate trades df = quiver_client.senate_trading() ``` -------------------------------- ### GET /beta/historical/offexchange/{ticker} Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/endpoints.md Retrieve historical OTC volume for a specific ticker. This endpoint allows querying past off-exchange short volume data for a given ticker symbol. ```APIDOC ## GET /beta/historical/offexchange/{ticker} ### Description Retrieve historical OTC volume for a specific ticker. This endpoint allows querying past off-exchange short volume data for a given ticker symbol. ### Method GET ### Endpoint /beta/historical/offexchange/{ticker} ### Parameters #### Path Parameters - **ticker** (string) - Required - The stock ticker symbol. ### Response #### Success Response (200) - **Ticker** (string) - **Date** (ISO8601 datetime) - **Volume** (number) - **PercentageOfVolume** (number) #### Error Response - **401** — Unauthorized (invalid/missing token) - **403** — Forbidden (subscription tier too low) ``` -------------------------------- ### Initialize Client with API Token from Environment Variable (Simplified) Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/configuration.md A simplified version for initializing the Quiver client using an API token stored in the QUIVER_API_TOKEN environment variable. ```python import os import quiverquant token = os.getenv('QUIVER_API_TOKEN') client = quiverquant.quiver(token) ``` -------------------------------- ### Quiver Client Initialization and Data Fetching Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/README.md Demonstrates how to initialize the Quiver client with an API token and fetch various types of financial data using the client's methods. The fetched data is returned as a pandas DataFrame. ```APIDOC ## Quiver Client Initialization and Usage ### Description Initialize the `quiverquant` client with your API token and use its methods to fetch financial data. The data is returned as a pandas DataFrame. ### Method ```python import quiverquant # Initialize client with API token client = quiverquant.quiver("YOUR_API_TOKEN") # Fetch data (returns pandas.DataFrame) df_trading = client.congress_trading(ticker="AAPL") df_news = client.news() df_insiders = client.insiders(ticker="TSLA") ``` ### Parameters - `quiver()` requires an API token string. - `congress_trading()` accepts an optional `ticker` string. - `news()` has no parameters. - `insiders()` accepts an optional `ticker` string. ``` -------------------------------- ### Get Recent Off-Exchange Data Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/api-reference/quiver-client.md Retrieves recent off-exchange (OTC) short volume data across all tickers. The 'Date' column is not converted to datetime by default. ```python df = quiver_client.offexchange() ``` -------------------------------- ### Initialize Client with API Token from JSON Configuration File Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/configuration.md This snippet demonstrates initializing the Quiver client by reading an API token from a JSON configuration file named 'config.json'. This method is not recommended for production environments. ```python import json import quiverquant with open('config.json', 'r') as f: config = json.load(f) client = quiverquant.quiver(config['api_token']) ``` -------------------------------- ### Get Patents Source: https://github.com/quiver-quantitative/python-api/blob/main/README.md Retrieves data on patents filed by companies. Can be filtered by ticker. ```APIDOC ## Get Patents ### Description Retrieves data on patents filed by companies. Can be filtered by ticker. ### Method `quiver.patents(ticker)` ### Parameters - **ticker** (string) - Required - The stock ticker symbol (e.g., "AAPL"). ``` -------------------------------- ### Initialize Quiver Client and Fetch Data Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/README.md Demonstrates how to initialize the Quiver client with an API token and fetch various datasets like congressional trading, news, and insider transactions. The data is returned as pandas DataFrames. ```python import quiverquant # Initialize client with API token client = quiverquant.quiver("YOUR_API_TOKEN") # Fetch data (returns pandas.DataFrame) df = client.congress_trading(ticker="AAPL") df = client.news() df = client.insiders(ticker="TSLA") ``` -------------------------------- ### Minimal API Client Configuration Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/README.md Initialize the QuiverQuant client with only the required API token. No additional configuration files or environment variables are needed for basic usage. ```python # Only required parameter: API token client = quiverquant.quiver(api_token) # No config files, environment variables, or settings objects # All method options passed at call time ``` -------------------------------- ### Initialize Quiver Client with API Token Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/configuration.md Use this snippet to initialize the Quiver client by passing your API authentication token. Obtain your token from https://api.quiverquant.com. ```python import quiverquant # Initialize with token api_token = "your_actual_token_here" quiver_client = quiverquant.quiver(api_token) ``` -------------------------------- ### Get Executive Compensation Source: https://github.com/quiver-quantitative/python-api/blob/main/README.md Retrieves data on executive compensation for a given ticker. ```APIDOC ## Get Executive Compensation ### Description Retrieves data on executive compensation for a given ticker. ### Method `quiver.executive_compensation(ticker)` ### Parameters - **ticker** (string) - Required - The stock ticker symbol (e.g., "NVDA"). ``` -------------------------------- ### Get Top Shareholders Source: https://github.com/quiver-quantitative/python-api/blob/main/README.md Retrieves data on the top shareholders for a given ticker. ```APIDOC ## Get Top Shareholders ### Description Retrieves data on the top shareholders for a given ticker. ### Method `quiver.top_shareholders(ticker)` ### Parameters - **ticker** (string) - Required - The stock ticker symbol (e.g., "WMT"). ``` -------------------------------- ### Get Off-Exchange Data for a Specific Ticker Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/api-reference/quiver-client.md Retrieves off-exchange (OTC) short volume data for a specific stock ticker. The 'Date' column is converted to datetime only when a ticker is specified. ```python df = quiver_client.offexchange(ticker="AMC") ``` -------------------------------- ### Get Live Wall Street Bets Comment Aggregates Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/endpoints.md Retrieve aggregated Wall Street Bets comment data. Requires authentication and accepts ticker, frequency, and date range as query parameters. ```python wallstreetbetsComments(ticker="", freq="", date_from="", date_to="") ``` -------------------------------- ### Get Corporate Donors Source: https://github.com/quiver-quantitative/python-api/blob/main/README.md Retrieves data on corporate election donations. Can be filtered by ticker. ```APIDOC ## Get Corporate Donors ### Description Retrieves data on corporate election donations. Can be filtered by ticker. ### Method `quiver.corporate_donors(ticker)` ### Parameters - **ticker** (string) - Required - The stock ticker symbol (e.g., "CVX"). ``` -------------------------------- ### Initialize Quiver Client Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/README.md Instantiate the Quiver client by providing your API token obtained from the Quiver website. This client object is used to make subsequent API calls. ```python client = quiverquant.quiver("your_token_from_quiverquant") ``` -------------------------------- ### Get Insider Transactions Source: https://github.com/quiver-quantitative/python-api/blob/main/README.md Retrieves data on recent insider transactions. Can be filtered by ticker. ```APIDOC ## Get Insider Transactions ### Description Retrieves data on recent insider transactions. Can be filtered by ticker. ### Method `quiver.insiders(ticker=None)` ### Parameters - **ticker** (string) - Optional - The stock ticker symbol (e.g., "TSLA") to filter insider transactions for. ``` -------------------------------- ### Initialize Client with API Token from Environment Variable Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/configuration.md This snippet shows how to initialize the Quiver client by retrieving the API token from the QUIVER_API_TOKEN environment variable. It includes error handling if the variable is not set. ```python import os import quiverquant # Read token from environment if desired token = os.getenv('QUIVER_API_TOKEN') if not token: raise ValueError("QUIVER_API_TOKEN environment variable not set") quiver_client = quiverquant.quiver(token) ``` -------------------------------- ### Safely Get Data with Subscription Error Handling Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/usage-patterns.md Provides a function to safely call Quiver client methods, specifically handling and reporting 'Dataset not available' errors due to subscription limitations. Returns an empty DataFrame on error. ```python import pandas as pd def safe_get_data(client, method_name, **kwargs): """ Safely call a Quiver method, handling subscription errors. Args: client: Initialized quiver client method_name: Name of method to call **kwargs: Arguments to pass to method Returns: DataFrame if successful, empty DataFrame if subscription error """ try: method = getattr(client, method_name) return method(**kwargs) except NameError as e: print(f"Dataset not available: {e}") return pd.DataFrame() # Usage df = safe_get_data(client, 'wikipedia', ticker='AAPL') if not df.empty: print(f"Got {len(df)} Wikipedia records") else: print("Wikipedia dataset not available on this plan") ``` -------------------------------- ### Configure Pagination Parameters Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/configuration.md Use 'page_size' and 'page' arguments for methods supporting pagination to control the number of results per page and select the desired page. ```python df = quiver_client.news( page_size="20", # Results per page page="2" # Page number (1-indexed) ) ``` -------------------------------- ### Load Bulk Data and Measure Time Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/api-reference/data-types.md This snippet demonstrates how to load a large dataset and measure the time it takes. It's useful for identifying performance issues with bulk data retrieval. ```python import time start = time.time() df = client.congress_trading(recent=False) # Bulk data elapsed = time.time() - start print(f"Loaded {len(df)} rows in {elapsed:.2f}s") ``` -------------------------------- ### Get Lobbying Data Source: https://github.com/quiver-quantitative/python-api/blob/main/README.md Retrieves data on recent corporate lobbying activities. Can be filtered by ticker. ```APIDOC ## Get Lobbying Data ### Description Retrieves data on recent corporate lobbying activities. Can be filtered by ticker. ### Method `quiver.lobbying(ticker=None)` ### Parameters - **ticker** (string) - Optional - The stock ticker symbol (e.g., "AAPL") to filter lobbying data for. ``` -------------------------------- ### Get Wikipedia Page Views Source: https://github.com/quiver-quantitative/python-api/blob/main/README.md Retrieves data on Wikipedia page views for companies. Can be filtered by ticker. ```APIDOC ## Get Wikipedia Page Views ### Description Retrieves data on Wikipedia page views for companies. Can be filtered by ticker. ### Method `quiver.wikipedia(ticker=None)` ### Parameters - **ticker** (string) - Optional - The stock ticker symbol (e.g., "MSFT") to filter Wikipedia page views for. ``` -------------------------------- ### Instantiate Client and Fetch News Data Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/api-reference/data-types.md Demonstrates how to instantiate the Quiver client with an API token and fetch news data for a specific ticker. The returned data is a pandas.DataFrame, which can be inspected for its type and shape. ```python import quiverquant import pandas as pd client = quiverquant.quiver("TOKEN") df = client.news(ticker="AAPL") # df is a pandas.DataFrame print(type(df)) # print(df.shape) # (row_count, column_count) ``` -------------------------------- ### Document API Token Expectations Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/configuration.md Clearly document the expected API token, including its source (e.g., environment variable) and where to obtain it. Use type hints and docstrings for clarity. ```python def init_quiver(api_token: str = None) -> quiverquant.quiver: """ Initialize Quiver client. Args: api_token: Quiver API token from https://api.quiverquant.com If None, reads from QUIVER_API_TOKEN env var Returns: Initialized quiver client """ if api_token is None: api_token = os.getenv('QUIVER_API_TOKEN') if not api_token: raise ValueError("API token required") return quiverquant.quiver(api_token) ``` -------------------------------- ### Get SEC 13F Holdings Source: https://github.com/quiver-quantitative/python-api/blob/main/README.md Retrieves data on current SEC 13F holdings. Can be filtered by owner. ```APIDOC ## Get SEC 13F Holdings ### Description Retrieves data on current SEC 13F holdings. Can be filtered by owner. ### Method `quiver.sec13F(owner=None)` ### Parameters - **owner** (string) - Optional - The name of the fund or owner (e.g., "Situational Awareness LP") to filter 13F holdings for. ``` -------------------------------- ### Get Top Shareholders for a Company Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/api-reference/quiver-client.md Retrieves the top shareholders for a given stock ticker. Returns a pandas DataFrame. ```python df = quiver_client.top_shareholders(ticker="WMT") ``` -------------------------------- ### Get Senate Trades by Ticker Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/api-reference/quiver-client.md Retrieve recent trading activity by U.S. Senate members for a specific stock ticker. ```python # Get Senate trades for Microsoft df = quiver_client.senate_trading(ticker="MSFT") ``` -------------------------------- ### GET /live/sec13f Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/endpoints.md Retrieve SEC Form 13-F holdings. Allows filtering by ticker, date, owner, and reporting period. ```APIDOC ## GET /live/sec13f ### Description Retrieve SEC Form 13-F holdings data. This endpoint allows filtering by stock ticker, report date, institutional owner name, and reporting period. ### Method GET ### Endpoint `/live/sec13f` ### Parameters #### Query Parameters - **ticker** (string) - No - Stock ticker symbol. - **date** (string) - No - Report date. - **owner** (string) - No - Institutional owner name. - **period** (string) - No - Reporting period. ### Response #### Success Response (200) - **data** (array) - Contains 13-F holdings details. - **Ticker** (string) - **Owner** (string) - **Shares** (number) - **Value** (number) - **ReportPeriod** (ISO8601 datetime) - **Date** (ISO8601 datetime) #### Response Codes 200, 401, 403 ``` -------------------------------- ### Initialize Quiver Client with Error Handling Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/usage-patterns.md Initializes the Quiver client with explicit validation for the API token. Raises a ValueError for invalid or non-string tokens. ```python import quiverquant def init_client(token: str) -> quiverquant.quiver: """ Initialize Quiver client with validation. Args: token: API token from https://api.quiverquant.com Returns: Initialized quiver client Raises: ValueError: If token is invalid """ if not token or not isinstance(token, str): raise ValueError("Invalid token: must be non-empty string") return quiverquant.quiver(token) # Usage try: client = init_client(api_token) except ValueError as e: print(f"Initialization failed: {e}") ``` -------------------------------- ### Handle Subscription Errors in Python Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/errors.md Gracefully handle cases where a requested dataset is not available on the current subscription plan. Inform the user about upgrade options. ```python try: df = quiver_client.wikipedia() except NameError: print("Dataset not available on current plan. Visit https://api.quiverquant.com for upgrade options.") ``` -------------------------------- ### Get Top Shareholders for Apple Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/api-reference/quiver-client.md Retrieves the top shareholders for Apple Inc. using its ticker symbol. Returns a pandas DataFrame. ```python df = quiver_client.top_shareholders(ticker="AAPL") ``` -------------------------------- ### Get Paginated News Articles for a Specific Ticker Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/api-reference/quiver-client.md Retrieves news articles for a specific ticker with pagination. Returns a pandas DataFrame. ```python df = quiver_client.news(ticker="TSLA", page_size="20", page="1") ``` -------------------------------- ### Connect to API Source: https://github.com/quiver-quantitative/python-api/blob/main/README.md Establishes a connection to the Quiver API using a provided API token. ```APIDOC ## Connect to API ### Description Establishes a connection to the Quiver API using a provided API token. ### Method `quiverquant.quiver(TOKEN)` ### Parameters - **TOKEN** (string) - Required - Your unique API token. ``` -------------------------------- ### Compare Multiple Alternative Data Sources Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/usage-patterns.md Fetches and compares data from congressional trades, insider transactions, and WallStreetBets mentions for a given stock ticker. Useful for a multi-faceted market analysis. ```python ticker = "TSLA" # Get different types of data congress = client.congress_trading(ticker=ticker) insiders = client.insiders(ticker=ticker) wallstreetbets = client.wallstreetbets(ticker=ticker) print(f"Congressional trades: {len(congress)}") print(f"Insider transactions: {len(insiders)}") print(f"WSB mentions: {len(wallstreetbets)}") # Combined analysis all_data = { 'congress': congress, 'insiders': insiders, 'wsb': wallstreetbets } for source, df in all_data.items(): if not df.empty: print(f"\n{source}: {len(df)} records") ``` -------------------------------- ### Get News Articles for a Specific Ticker Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/api-reference/quiver-client.md Retrieves news articles filtered by a specific stock ticker. Returns a pandas DataFrame. ```python df = quiver_client.news(ticker="ORCL") ``` -------------------------------- ### Get All Recent Insider Transactions Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/api-reference/quiver-client.md Retrieves all recent insider trading and transactions data when no ticker is specified. Returns a pandas DataFrame. ```python df = quiver_client.insiders() ``` -------------------------------- ### Create Single Client Instance Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/configuration.md Instantiate the Quiver client once and reuse it throughout your application. Creating multiple client instances can lead to unnecessary memory consumption and reduced performance. ```python # Good: reuse the same client client = quiverquant.quiver(token) df1 = client.news() df2 = client.congress_trading() # Bad: create multiple clients (wastes memory) df1 = quiverquant.quiver(token).news() df2 = quiverquant.quiver(token).congress_trading() ``` -------------------------------- ### Get Recent Congressional Trades Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/api-reference/quiver-client.md Retrieve all recent trading activity by U.S. Congress members. This is the default behavior when no parameters are specified. ```python # Get all recent congressional trades df = quiver_client.congress_trading() ``` -------------------------------- ### Quiver Client Constructor Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/api-reference/quiver-client.md Initializes the Quiver API client with an authentication token. This client instance is then used to make subsequent API calls. ```APIDOC ## quiver(token) ### Description Initialize a Quiver API client with your authentication token. ### Parameters #### Path Parameters - **token** (str) - Required - API authentication token from Quiver Quantitative ### Example ```python import quiverquant # Initialize the client quiver_client = quiverquant.quiver("YOUR_API_TOKEN_HERE") ``` ``` -------------------------------- ### Fetch All Results with Pagination Workaround Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/api-reference/data-types.md Iteratively fetches all pages of results until an empty DataFrame is returned, then concatenates them. This is a workaround for the lack of automatic pagination. ```python all_data = [] page = 1 while True: df = client.news(page_size="100", page=str(page)) if df.empty: break all_data.append(df) page += 1 combined_df = pd.concat(all_data, ignore_index=True) ``` -------------------------------- ### GET /live/sec13fchanges Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/endpoints.md Retrieve changes to SEC Form 13-F positions. Supports filtering by ticker, date, owner, and reporting period. ```APIDOC ## GET /live/sec13fchanges ### Description Retrieve changes to SEC Form 13-F positions. This endpoint allows filtering by stock ticker, date, owner, and reporting period. ### Method GET ### Endpoint `/live/sec13fchanges` ### Parameters #### Query Parameters - **ticker** (string) - No - Stock ticker symbol. - **date** (string) - No - Report date. - **owner** (string) - No - Institutional owner name. - **period** (string) - No - Reporting period. ### Response #### Success Response (200) - **data** (array) - Contains 13-F position changes. - **Ticker** (string) - **Owner** (string) - **ShareChange** (number) - **ValueChange** (number) - **ReportPeriod** (ISO8601 datetime) - **Date** (ISO8601 datetime) #### Response Codes 200, 401, 403 ``` -------------------------------- ### Handle Null and Missing Data in Pandas Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/api-reference/data-types.md Demonstrates how to check for null values using isnull().sum(), fill nulls with fillna(), and drop rows with nulls using dropna(). Use these methods when working with DataFrames returned by the API. ```python df = client.congress_trading() # Check for null values print(df.isnull().sum()) # Fill nulls df['Amount'].fillna(0, inplace=True) # Drop rows with any nulls df.dropna(inplace=True) ``` -------------------------------- ### Validate Token Before Use Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/configuration.md Implement a function to test the validity of your API token by attempting a simple API call. This helps catch authentication issues early. ```python def test_connection(token): try: client = quiverquant.quiver(token) df = client.news() return True except Exception as e: print(f"Connection failed: {e}") return False ``` -------------------------------- ### GET /bulk/congresstrading Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/endpoints.md Retrieve bulk historical congressional trading data for all politicians and tickers. This endpoint is suitable for large-scale data retrieval. ```APIDOC ## GET /bulk/congresstrading ### Description Retrieve bulk historical congressional trading data for all politicians and tickers. This endpoint is suitable for large-scale data retrieval. ### Method GET ### Endpoint /bulk/congresstrading ### Response #### Success Response (200) - **Ticker** (string) - **Politician** (string) - **ReportDate** (ISO8601 datetime) - **TransactionDate** (ISO8601 datetime) - **Filed** (ISO8601 datetime) - **Traded** (ISO8601 datetime) - **Type** (string) - **Amount** (string) - **last_modified** (ISO8601 datetime) #### Error Response - **401** — Unauthorized (invalid/missing token) - **403** — Forbidden (subscription tier too low) ``` -------------------------------- ### WSB/Crypto Methods (Generic) Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/README.md Generic endpoint for WSB/Crypto data, supporting date filtering and frequency aggregation. ```APIDOC ## GET /wsb_crypto ### Description Retrieves data related to WallStreetBets and cryptocurrency discussions. This endpoint allows filtering by date and specifying the frequency of aggregation. ### Method GET ### Endpoint /wsb_crypto ### Parameters #### Query Parameters - **date_from** (str) - Optional - Start date for filtering (YYYY-MM-DD). - **date_to** (str) - Optional - End date for filtering (YYYY-MM-DD). - **freq** (str) - Optional - Frequency or aggregation level (e.g., 'daily', 'hourly'). ### Response #### Success Response (200) - **data** (DataFrame) - WSB/Crypto data, with date fields converted to pandas.Timestamp. #### Response Example ```json { "data": [ { "date": "2023-10-26", "asset": "BTC", "mentions": 200, "sentiment_score": 0.75 } ] } ``` ``` -------------------------------- ### GET /live/congresstrading Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/endpoints.md Retrieve recent congressional trading activity. This endpoint provides live data on trades made by members of Congress. ```APIDOC ## GET /live/congresstrading ### Description Retrieve recent congressional trading activity. This endpoint provides live data on trades made by members of Congress. ### Method GET ### Endpoint /live/congresstrading ### Parameters #### Query Parameters - **representative** (string) - Optional - Name of politician (URL-encoded) ### Request Headers - **Authorization** (string) - Required - Token {token} - **Accept** (string) - Required - application/json ### Response #### Success Response (200) - **Ticker** (string) - **Politician** (string) - **ReportDate** (ISO8601 datetime) - **TransactionDate** (ISO8601 datetime) - **Filed** (ISO8601 datetime) - **Traded** (ISO8601 datetime) - **Type** (string) - **Amount** (string) - **last_modified** (ISO8601 datetime) #### Error Response - **401** — Unauthorized (invalid/missing token) - **403** — Forbidden (subscription tier too low) - **400** — Bad request (invalid parameters) ``` -------------------------------- ### Fetch All News Data Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/README.md Retrieve all available news data by calling the `news()` method without any arguments. This is useful for fetching the entire dataset. ```python df = client.news() ``` -------------------------------- ### Get Congress Trading Data Source: https://github.com/quiver-quantitative/python-api/blob/main/README.md Retrieves data on recent trades by members of the U.S. Congress. Can be filtered by ticker or politician name. ```APIDOC ## Get Congress Trading Data ### Description Retrieves data on recent trades by members of the U.S. Congress. Can be filtered by ticker or politician name. ### Method `quiver.congress_trading(ticker_or_name=None, politician=False)` ### Parameters - **ticker_or_name** (string) - Optional - The stock ticker symbol (e.g., "TSLA") or the name of a politician (e.g., "Richard Burr"). - **politician** (boolean) - Optional - Set to `True` if `ticker_or_name` is a politician's name. ``` -------------------------------- ### Safely Access Optional Columns Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/api-reference/data-types.md Demonstrates how to safely access columns that may not be present in a DataFrame. Use 'in df.columns' for explicit checks or the .get() method for a default value. ```python df = client.congress_trading(ticker="AAPL") # Check if column exists before accessing if 'ReportDate' in df.columns: print(df['ReportDate'].min()) else: print("ReportDate not available") # Or use .get() pattern value = df.get('Amount', 'N/A') ``` -------------------------------- ### Quiver Client HTTP Headers Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/configuration.md This shows the internal HTTP headers constructed by the Quiver client during initialization. These headers include 'accept', 'X-CSRFToken', and 'Authorization'. They are applied to all requests and are immutable after the client is created. ```python self.headers = { 'accept': 'application/json', 'X-CSRFToken': 'TyTJwjuEC7VV7mOqZ622haRaaUr0x0Ng4nrwSRFKQs7vdoBcJlK9qjAS69ghzhFu', 'Authorization': 'Token ' + token } ``` -------------------------------- ### Get Insider Transactions for a Specific Ticker Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/api-reference/quiver-client.md Retrieves insider trading and transactions data for a specific stock ticker. Returns a pandas DataFrame. ```python df = quiver_client.insiders(ticker="TSLA") ``` -------------------------------- ### Handling Empty DataFrames Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/api-reference/data-types.md Illustrates the behavior of the API client when no data matches the query parameters. An empty pandas.DataFrame is returned, which can be checked using the .empty attribute. ```python df = client.congress_trading(ticker="INVALID_TICKER") print(df.empty) # True print(df.shape) # (0, 0) or (0, n) depending on response ``` -------------------------------- ### Configure Corporate Donors Filters Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/configuration.md Filter corporate donor data by company ticker, politician's BioGuide ID, election cycle, transaction type, and pagination. Ensure correct values for 'bioguide_id' and 'transaction_tp' if used. ```python df = quiver_client.corporate_donors( ticker="AAPL", # Company ticker bioguide_id="", # Politician's BioGuide ID cycle="2020", # Election cycle transaction_tp="", # Transaction type page_size="50", # Results per page page="1" # Page number ) ``` -------------------------------- ### GET /live/quivernews Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/endpoints.md Retrieve Quiver news articles. This endpoint fetches news articles, with options to filter by ticker, page, and page size. ```APIDOC ## GET /live/quivernews ### Description Retrieve Quiver news articles. This endpoint fetches news articles, with options to filter by ticker, page, and page size. ### Method GET ### Endpoint /live/quivernews ### Parameters #### Query Parameters - **ticker** (string) - No - Filter by stock ticker - **page** (string) - No - Page number (1-indexed) - **page_size** (string) - No - Results per page ### Response Schema ```json { "data": [ { "ticker": "string", "title": "string", "time": "ISO8601 datetime or Unix timestamp", "url": "string", "source": "string" } ] } ``` ### Response Codes 200, 401, 403, 400 ``` -------------------------------- ### Store API Token Securely Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/configuration.md Avoid hardcoding API tokens directly in your code. Instead, use environment variables to store sensitive credentials. Load them using a library like `dotenv` for local development. ```python # NOT this: client = quiverquant.quiver("hardcoded_token_123abc") # DO this: import os from dotenv import load_dotenv load_dotenv() token = os.getenv('QUIVER_API_TOKEN') if not token: raise ValueError("QUIVER_API_TOKEN not set in environment") client = quiverquant.quiver(token) ``` -------------------------------- ### Handle Subscription Error for Premium Datasets Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/usage-patterns.md Catch a NameError to gracefully handle cases where a premium dataset is accessed without an active subscription. Provides instructions on how to upgrade. ```python try: df = client.wikipedia(ticker="AAPL") except NameError as e: print("This dataset requires a premium subscription") print("Visit https://api.quiverquant.com to upgrade") ``` -------------------------------- ### Get Congressional Trades for a Specific Stock Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/usage-patterns.md Retrieves congressional trading data for a particular stock ticker. Useful for focusing on specific companies. ```python # Get congressional trades for Apple df = client.congress_trading(ticker="AAPL") print(f"Found {len(df)} trades for AAPL") ``` -------------------------------- ### Wall Street Bets Comment Aggregate Response Schema Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/endpoints.md Example JSON structure for aggregated Wall Street Bets comment data. ```json [ { "Ticker": "string", "Text": "string", "Time": "number (milliseconds since epoch)", "Author": "string" } ] ``` -------------------------------- ### Pagination Parameters Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/configuration.md These parameters are available on methods that support pagination, allowing you to control the number of results per page and select specific pages. ```APIDOC ## Pagination Parameters Available on methods that support pagination: `news()`, `executive_compensation()`, `corporate_donors()`, `wallstreetbetsComments()`, `wallstreetbetsCommentsFull()`, `cryptoComments()`, `cryptoCommentsHistorical()` ```python df = quiver_client.news( page_size="20", # Results per page page="2" # Page number (1-indexed) ) ``` ``` -------------------------------- ### Fetch SEC 13F Filings Source: https://github.com/quiver-quantitative/python-api/blob/main/README.md Retrieve data on recent hedge fund moves (13F filings) filtered by ticker (e.g., AMZN) or by fund owner. ```python #Get data on recent hedge fund moves in Amazon df13F_Amazon = quiver.sec13FChanges(ticker="AMZN") #Get data on holdings in Situational Awareness' portfolio df13F_fund = quiver.sec13F(owner="Situational Awareness LP") ``` -------------------------------- ### Get Historical Crypto Comments Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/api-reference/quiver-client.md Retrieves historical Reddit crypto community comment data. Supports filtering by ticker, frequency, and date range. ```python # Get all historical crypto comments df = quiver_client.cryptoCommentsHistorical() ``` ```python # Get historical comments for Ethereum df = quiver_client.cryptoCommentsHistorical(ticker="ETH") ``` ```python # Get historical comments with filters df = quiver_client.cryptoCommentsHistorical(ticker="BTC", date_from="2020-01-01", date_to="2020-12-31") ``` -------------------------------- ### Handling Missing Required Ticker Parameter Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/errors.md Demonstrates how a TypeError occurs when a required 'ticker' parameter is missing and how to fix it by providing the parameter. ```python # This raises TypeError df = quiver_client.top_shareholders() # TypeError: missing 1 required positional argument: 'ticker' ``` ```python # Provide the required ticker parameter df = quiver_client.top_shareholders(ticker="AAPL") ``` -------------------------------- ### Get Recent Crypto Comments Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/api-reference/quiver-client.md Retrieves recent aggregated Reddit crypto community comment data. Can filter by ticker, frequency, and date range. ```python # Get all recent crypto comments df = quiver_client.cryptoComments() ``` ```python # Get comments for Bitcoin df = quiver_client.cryptoComments(ticker="BTC") ``` ```python # Get crypto comments with date range df = quiver_client.cryptoComments(ticker="ETH", date_from="2021-01-01", date_to="2021-12-31") ``` -------------------------------- ### Compare Multiple Stocks for Insider Transactions Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/usage-patterns.md Analyze insider transactions across a list of tickers. This pattern is useful for comparing insider activity across related companies. ```python tickers = ["AAPL", "MSFT", "GOOGL"] results = {} for ticker in tickers: df = client.insiders(ticker=ticker) results[ticker] = len(df) print("Insider transactions by ticker:") for ticker, count in sorted(results.items(), key=lambda x: -x[1]): print(f" {ticker}: {count}") ``` -------------------------------- ### Get All Recent News Articles Source: https://github.com/quiver-quantitative/python-api/blob/main/_autodocs/api-reference/quiver-client.md Retrieves all recent news articles when no ticker, page size, or page number is specified. Returns a pandas DataFrame. ```python df = quiver_client.news() ```