UNPKG

kalshi-typescript

Version:
373 lines (329 loc) 21.2 kB
/* tslint:disable */ /* eslint-disable */ /** * Kalshi Trade API Manual Endpoints * Manually defined OpenAPI spec for endpoints being migrated to spec-first approach * * The version of the OpenAPI document: 3.11.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ import type { Configuration } from '../configuration'; import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios'; import globalAxios from 'axios'; // URLSearchParams not necessarily used // @ts-ignore import { URL, URLSearchParams } from 'url'; // Some imports not used depending on template conditions // @ts-ignore import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from '../common'; // @ts-ignore import { BASE_PATH, COLLECTION_FORMATS, type RequestArgs, BaseAPI, RequiredError } from '../base'; // @ts-ignore import type { CreateApiKeyRequest } from '../models'; // @ts-ignore import type { CreateApiKeyResponse } from '../models'; // @ts-ignore import type { GenerateApiKeyRequest } from '../models'; // @ts-ignore import type { GenerateApiKeyResponse } from '../models'; // @ts-ignore import type { GetApiKeysResponse } from '../models'; /** * ApiKeysApi - axios parameter creator */ export const ApiKeysApiAxiosParamCreator = function (configuration?: Configuration) { return { /** * Endpoint for creating 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. * @summary Create API Key * @param {CreateApiKeyRequest} createApiKeyRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ createApiKey: async (createApiKeyRequest: CreateApiKeyRequest, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => { // verify required parameter 'createApiKeyRequest' is not null or undefined assertParamExists('createApiKey', 'createApiKeyRequest', createApiKeyRequest) const localVarPath = `/api_keys`; // use dummy base URL string because the URL constructor only accepts absolute URLs. const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); let baseOptions; if (configuration) { baseOptions = configuration.baseOptions; } const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; // authentication kalshiAccessSignature required await setApiKeyToObject(localVarHeaderParameter, "KALSHI-ACCESS-SIGNATURE", configuration) // authentication kalshiAccessKey required await setApiKeyToObject(localVarHeaderParameter, "KALSHI-ACCESS-KEY", configuration) // authentication kalshiAccessTimestamp required await setApiKeyToObject(localVarHeaderParameter, "KALSHI-ACCESS-TIMESTAMP", configuration) localVarHeaderParameter['Content-Type'] = 'application/json'; setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; localVarRequestOptions.data = serializeDataIfNeeded(createApiKeyRequest, localVarRequestOptions, configuration) return { url: toPathString(localVarUrlObj), options: localVarRequestOptions, }; }, /** * Endpoint for deleting 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. * @summary Delete API Key * @param {string} apiKey API key ID to delete * @param {*} [options] Override http request option. * @throws {RequiredError} */ deleteApiKey: async (apiKey: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => { // verify required parameter 'apiKey' is not null or undefined assertParamExists('deleteApiKey', 'apiKey', apiKey) const localVarPath = `/api_keys/{api_key}` .replace(`{${"api_key"}}`, encodeURIComponent(String(apiKey))); // use dummy base URL string because the URL constructor only accepts absolute URLs. const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); let baseOptions; if (configuration) { baseOptions = configuration.baseOptions; } const localVarRequestOptions = { method: 'DELETE', ...baseOptions, ...options}; const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; // authentication kalshiAccessSignature required await setApiKeyToObject(localVarHeaderParameter, "KALSHI-ACCESS-SIGNATURE", configuration) // authentication kalshiAccessKey required await setApiKeyToObject(localVarHeaderParameter, "KALSHI-ACCESS-KEY", configuration) // authentication kalshiAccessTimestamp required await setApiKeyToObject(localVarHeaderParameter, "KALSHI-ACCESS-TIMESTAMP", configuration) setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; return { url: toPathString(localVarUrlObj), options: localVarRequestOptions, }; }, /** * Endpoint for generating 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. * @summary Generate API Key * @param {GenerateApiKeyRequest} generateApiKeyRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ generateApiKey: async (generateApiKeyRequest: GenerateApiKeyRequest, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => { // verify required parameter 'generateApiKeyRequest' is not null or undefined assertParamExists('generateApiKey', 'generateApiKeyRequest', generateApiKeyRequest) const localVarPath = `/api_keys/generate`; // use dummy base URL string because the URL constructor only accepts absolute URLs. const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); let baseOptions; if (configuration) { baseOptions = configuration.baseOptions; } const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; // authentication kalshiAccessSignature required await setApiKeyToObject(localVarHeaderParameter, "KALSHI-ACCESS-SIGNATURE", configuration) // authentication kalshiAccessKey required await setApiKeyToObject(localVarHeaderParameter, "KALSHI-ACCESS-KEY", configuration) // authentication kalshiAccessTimestamp required await setApiKeyToObject(localVarHeaderParameter, "KALSHI-ACCESS-TIMESTAMP", configuration) localVarHeaderParameter['Content-Type'] = 'application/json'; setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; localVarRequestOptions.data = serializeDataIfNeeded(generateApiKeyRequest, localVarRequestOptions, configuration) return { url: toPathString(localVarUrlObj), options: localVarRequestOptions, }; }, /** * Endpoint for retrieving 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. * @summary Get API Keys * @param {*} [options] Override http request option. * @throws {RequiredError} */ getApiKeys: async (options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => { const localVarPath = `/api_keys`; // use dummy base URL string because the URL constructor only accepts absolute URLs. const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); let baseOptions; if (configuration) { baseOptions = configuration.baseOptions; } const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; // authentication kalshiAccessSignature required await setApiKeyToObject(localVarHeaderParameter, "KALSHI-ACCESS-SIGNATURE", configuration) // authentication kalshiAccessKey required await setApiKeyToObject(localVarHeaderParameter, "KALSHI-ACCESS-KEY", configuration) // authentication kalshiAccessTimestamp required await setApiKeyToObject(localVarHeaderParameter, "KALSHI-ACCESS-TIMESTAMP", configuration) setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; return { url: toPathString(localVarUrlObj), options: localVarRequestOptions, }; }, } }; /** * ApiKeysApi - functional programming interface */ export const ApiKeysApiFp = function(configuration?: Configuration) { const localVarAxiosParamCreator = ApiKeysApiAxiosParamCreator(configuration) return { /** * Endpoint for creating 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. * @summary Create API Key * @param {CreateApiKeyRequest} createApiKeyRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ async createApiKey(createApiKeyRequest: CreateApiKeyRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<CreateApiKeyResponse>> { const localVarAxiosArgs = await localVarAxiosParamCreator.createApiKey(createApiKeyRequest, options); const localVarOperationServerIndex = configuration?.serverIndex ?? 0; const localVarOperationServerBasePath: string | undefined = undefined; return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); }, /** * Endpoint for deleting 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. * @summary Delete API Key * @param {string} apiKey API key ID to delete * @param {*} [options] Override http request option. * @throws {RequiredError} */ async deleteApiKey(apiKey: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> { const localVarAxiosArgs = await localVarAxiosParamCreator.deleteApiKey(apiKey, options); const localVarOperationServerIndex = configuration?.serverIndex ?? 0; const localVarOperationServerBasePath: string | undefined = undefined; return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); }, /** * Endpoint for generating 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. * @summary Generate API Key * @param {GenerateApiKeyRequest} generateApiKeyRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ async generateApiKey(generateApiKeyRequest: GenerateApiKeyRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<GenerateApiKeyResponse>> { const localVarAxiosArgs = await localVarAxiosParamCreator.generateApiKey(generateApiKeyRequest, options); const localVarOperationServerIndex = configuration?.serverIndex ?? 0; const localVarOperationServerBasePath: string | undefined = undefined; return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); }, /** * Endpoint for retrieving 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. * @summary Get API Keys * @param {*} [options] Override http request option. * @throws {RequiredError} */ async getApiKeys(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<GetApiKeysResponse>> { const localVarAxiosArgs = await localVarAxiosParamCreator.getApiKeys(options); const localVarOperationServerIndex = configuration?.serverIndex ?? 0; const localVarOperationServerBasePath: string | undefined = undefined; return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); }, } }; /** * ApiKeysApi - factory interface */ export const ApiKeysApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { const localVarFp = ApiKeysApiFp(configuration) return { /** * Endpoint for creating 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. * @summary Create API Key * @param {CreateApiKeyRequest} createApiKeyRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ createApiKey(createApiKeyRequest: CreateApiKeyRequest, options?: RawAxiosRequestConfig): AxiosPromise<CreateApiKeyResponse> { return localVarFp.createApiKey(createApiKeyRequest, options).then((request) => request(axios, basePath)); }, /** * Endpoint for deleting 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. * @summary Delete API Key * @param {string} apiKey API key ID to delete * @param {*} [options] Override http request option. * @throws {RequiredError} */ deleteApiKey(apiKey: string, options?: RawAxiosRequestConfig): AxiosPromise<void> { return localVarFp.deleteApiKey(apiKey, options).then((request) => request(axios, basePath)); }, /** * Endpoint for generating 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. * @summary Generate API Key * @param {GenerateApiKeyRequest} generateApiKeyRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ generateApiKey(generateApiKeyRequest: GenerateApiKeyRequest, options?: RawAxiosRequestConfig): AxiosPromise<GenerateApiKeyResponse> { return localVarFp.generateApiKey(generateApiKeyRequest, options).then((request) => request(axios, basePath)); }, /** * Endpoint for retrieving 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. * @summary Get API Keys * @param {*} [options] Override http request option. * @throws {RequiredError} */ getApiKeys(options?: RawAxiosRequestConfig): AxiosPromise<GetApiKeysResponse> { return localVarFp.getApiKeys(options).then((request) => request(axios, basePath)); }, }; }; /** * ApiKeysApi - object-oriented interface */ export class ApiKeysApi extends BaseAPI { /** * Endpoint for creating 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. * @summary Create API Key * @param {CreateApiKeyRequest} createApiKeyRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ public createApiKey(createApiKeyRequest: CreateApiKeyRequest, options?: RawAxiosRequestConfig) { return ApiKeysApiFp(this.configuration).createApiKey(createApiKeyRequest, options).then((request) => request(this.axios, this.basePath)); } /** * Endpoint for deleting 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. * @summary Delete API Key * @param {string} apiKey API key ID to delete * @param {*} [options] Override http request option. * @throws {RequiredError} */ public deleteApiKey(apiKey: string, options?: RawAxiosRequestConfig) { return ApiKeysApiFp(this.configuration).deleteApiKey(apiKey, options).then((request) => request(this.axios, this.basePath)); } /** * Endpoint for generating 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. * @summary Generate API Key * @param {GenerateApiKeyRequest} generateApiKeyRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ public generateApiKey(generateApiKeyRequest: GenerateApiKeyRequest, options?: RawAxiosRequestConfig) { return ApiKeysApiFp(this.configuration).generateApiKey(generateApiKeyRequest, options).then((request) => request(this.axios, this.basePath)); } /** * Endpoint for retrieving 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. * @summary Get API Keys * @param {*} [options] Override http request option. * @throws {RequiredError} */ public getApiKeys(options?: RawAxiosRequestConfig) { return ApiKeysApiFp(this.configuration).getApiKeys(options).then((request) => request(this.axios, this.basePath)); } }