Countercyclical Docs
  • Welcome to Countercyclical
  • Guides
    • Terminology
    • Platforms
    • Integrations
      • Airbyte
      • Google Drive
      • Google Sheets
      • Zapier
  • Fundamentals
    • Workspaces
    • Navigation
      • Command Palette
      • Exploration & Recents
      • List vs. Grid View
      • Quick Actions
    • Search
      • Filters
      • Companies
        • Charts
      • Economic Data
      • Model Syncing
    • Investments
      • Tabs
        • Overview
        • Analysis
        • Valuations
      • Actions
      • Comments
      • Invitations and Sharing
        • Share
      • Quick Versioning
    • Valuations
      • Sensitivity Analysis
      • Assumptions
    • Memos
      • Sources
    • Teams
    • Pipelines
    • Profile
    • Settings
      • Account
        • General
          • Connected Accounts
            • Google Sheets
            • Google Drive
        • Preferences
        • Notifications
        • Sessions
        • Account Security
        • Plans
      • Workspace
        • General
        • Advanced
          • Access
          • Identity
          • Appearance
          • Usage
          • Developers
        • Permissions
        • Integrations
        • Workspace Security
          • SAML SSO
          • Audit Logs
        • About
  • Use Cases
    • For Analysts
    • For Research Teams
    • For Organizations
    • For Education
  • Developers
    • Getting Started
    • Authentication
    • Rate Limiting
    • Versioning
    • Endpoints
      • Investments
      • Valuations
      • Memos
      • Teams
      • Assumptions
      • Pipelines
    • Webhooks
  • Extras
    • Security
    • Billing
    • Imports
      • Formatting Guide for Imports
    • Exports
      • Export User Data
    • Enrichment Data
    • Troubleshooting
  • Links
    • Website
    • Dashboard
    • Request a Demo
    • LinkedIn
    • Twitter / X
    • Dribbble
Powered by GitBook
On this page
  • Overview
  • Generating an API Key
  • Best Practice: Rolling your API Keys
  • Example
  1. Developers

Authentication

Learn how to authenticate with Countercyclical's API.

PreviousGetting StartedNextRate Limiting

Last updated 6 months ago

Overview

All calls to the Countercyclical API require authorization using a query parameter called apiKey in the API call. Here's what an example call might look like:

https://api.countercyclical.io/v1/investments?apiKey=ck_prod_dxjgVIbY...

Each API key is associated to a member with in workspace. As such, users can only work with items within that workspace (along with what's available on their plan).

Generating an API Key

Users can find their API tokens by going to .

Each key you generate should look something like the following:

ck_prod_dxjgVIbY...

Be sure to take note of what your generated token is before closing the dialog as you will not be able to view it afterwards.

We recommend storing this value as an environment variable.

Best Practice: Rolling your API Keys

It's a good practice to roll your API keys once in a while for security purposes.

While we do not currently support "rerolling" the same API key, we recommend users generate a new API key with the same permissions they might otherwise have.

To make this easier, you can select from the dropdown menu on the right-hand side of any one of your API keys and select the "Roll as New Key" option.

Example

Here's an example of what a call to get a member's Investments might look like:

import axios, { AxiosResponse } from 'axios';
import { NextFunction, Request, Response, Router } from 'express';

const router = Router();

const apiKey = process.env.COUNTERCYCLICAL_API_KEY;

const countercyclicalAxiosInstance = axios.create({
    baseURL: 'https://api.countercyclical.io',
    params: {
        apiKey: apiKey,
    },
});

router.get('/v1/investments', async (req: Request, res: Response, next: NextFunction) => {
    try {
        await countercyclicalAxiosInstance
            .get('/v1/investments', { params: { limit: 6 } })
            .then((apiResponse: AxiosResponse) => {
                if (apiResponse.status === 200) {
                    return res.send(apiResponse.data);
                }
            });
    } catch (error) {
        console.error(error);
    }
});
Settings -> Workspace -> Advanced -> Developers -> API Keys