All URIs are relative to https://api.elections.kalshi.com/trade-api/v2
MethodHTTP requestDescription
createApiKeyPOST /api_keysCreate API Key
deleteApiKeyDELETE /api_keys/Delete API Key
generateApiKeyPOST /api_keys/generateGenerate API Key
getApiKeysGET /api_keysGet API Keys

createApiKey

CreateApiKeyResponse createApiKey(createApiKeyRequest)
Create a new API key with a user-provided public key. This endpoint allows users with Premier or Market Maker API usage levels to create API keys by providing their own RSA public key. The platform will use this public key to verify signatures on API requests.

Example

import {
    ApiKeysApi,
    Configuration,
    CreateApiKeyRequest
} from '@kalshi/trading-api';

const configuration = new Configuration();
const apiInstance = new ApiKeysApi(configuration);

let createApiKeyRequest: CreateApiKeyRequest; //

const { status, data } = await apiInstance.createApiKey(
    createApiKeyRequest
);

Parameters

NameTypeDescriptionNotes
createApiKeyRequestCreateApiKeyRequest

Return type

CreateApiKeyResponse

Authorization

bearerAuth

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
201API key created successfully-
400Bad request - invalid input-
401Unauthorized - authentication required-
403Forbidden - insufficient permissions-
500Internal server error-
[Back to top] [Back to API list] [Back to Model list] [Back to README]

deleteApiKey

deleteApiKey()
Delete an existing API key. This endpoint permanently deletes an API key. Once deleted, the key can no longer be used for authentication. This action cannot be undone.

Example

import {
    ApiKeysApi,
    Configuration
} from '@kalshi/trading-api';

const configuration = new Configuration();
const apiInstance = new ApiKeysApi(configuration);

let apiKey: string; //API key ID to delete (default to undefined)

const { status, data } = await apiInstance.deleteApiKey(
    apiKey
);

Parameters

NameTypeDescriptionNotes
apiKey[string]API key ID to deletedefaults to undefined

Return type

void (empty response body)

Authorization

bearerAuth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
204API key successfully deleted-
400Bad request - invalid input-
401Unauthorized - authentication required-
404Resource not found-
500Internal server error-
[Back to top] [Back to API list] [Back to Model list] [Back to README]

generateApiKey

GenerateApiKeyResponse generateApiKey(generateApiKeyRequest)
Generate a new API key with an automatically created key pair. This endpoint generates both a public and private RSA key pair. The public key is stored on the platform, while the private key is returned to the user and must be stored securely. The private key cannot be retrieved again.

Example

import {
    ApiKeysApi,
    Configuration,
    GenerateApiKeyRequest
} from '@kalshi/trading-api';

const configuration = new Configuration();
const apiInstance = new ApiKeysApi(configuration);

let generateApiKeyRequest: GenerateApiKeyRequest; //

const { status, data } = await apiInstance.generateApiKey(
    generateApiKeyRequest
);

Parameters

NameTypeDescriptionNotes
generateApiKeyRequestGenerateApiKeyRequest

Return type

GenerateApiKeyResponse

Authorization

bearerAuth

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
201API key generated successfully-
400Bad request - invalid input-
401Unauthorized - authentication required-
500Internal server error-
[Back to top] [Back to API list] [Back to Model list] [Back to README]

getApiKeys

GetApiKeysResponse getApiKeys()
Retrieve all API keys associated with the authenticated user. API keys allow programmatic access to the platform without requiring username/password authentication. Each key has a unique identifier and name.

Example

import {
    ApiKeysApi,
    Configuration
} from '@kalshi/trading-api';

const configuration = new Configuration();
const apiInstance = new ApiKeysApi(configuration);

const { status, data } = await apiInstance.getApiKeys();

Parameters

This endpoint does not have any parameters.

Return type

GetApiKeysResponse

Authorization

bearerAuth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List of API keys retrieved successfully-
401Unauthorized - authentication required-
500Internal server error-
[Back to top] [Back to API list] [Back to Model list] [Back to README]