Skip to content

Api_Keys API Reference

Endpoints

Create Api Key

Synchronous API Call

kalshi_py.api.api_keys.create_api_key.sync(*, client: Union[AuthenticatedClient, Client], body: ModelUserCreateApiKeyRequest) -> Optional[ModelUserCreateApiKeyResponse]

Create API Key

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.

Parameters:

Name Type Description Default
body ModelUserCreateApiKeyRequest
required

Raises:

Type Description
UnexpectedStatus

If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.

TimeoutException

If the request takes longer than Client.timeout.

Returns:

Type Description
Optional[ModelUserCreateApiKeyResponse]

ModelUserCreateApiKeyResponse

Source code in kalshi_py/api/api_keys/create_api_key.py
def sync(
    *,
    client: Union[AuthenticatedClient, Client],
    body: ModelUserCreateApiKeyRequest,
) -> Optional[ModelUserCreateApiKeyResponse]:
    """Create API Key

      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.

    Args:
        body (ModelUserCreateApiKeyRequest):

    Raises:
        errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
        httpx.TimeoutException: If the request takes longer than Client.timeout.

    Returns:
        ModelUserCreateApiKeyResponse
    """

    return sync_detailed(
        client=client,
        body=body,
    ).parsed

Asynchronous API Call

kalshi_py.api.api_keys.create_api_key.asyncio(*, client: Union[AuthenticatedClient, Client], body: ModelUserCreateApiKeyRequest) -> Optional[ModelUserCreateApiKeyResponse] async

Create API Key

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.

Parameters:

Name Type Description Default
body ModelUserCreateApiKeyRequest
required

Raises:

Type Description
UnexpectedStatus

If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.

TimeoutException

If the request takes longer than Client.timeout.

Returns:

Type Description
Optional[ModelUserCreateApiKeyResponse]

ModelUserCreateApiKeyResponse

Source code in kalshi_py/api/api_keys/create_api_key.py
async def asyncio(
    *,
    client: Union[AuthenticatedClient, Client],
    body: ModelUserCreateApiKeyRequest,
) -> Optional[ModelUserCreateApiKeyResponse]:
    """Create API Key

      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.

    Args:
        body (ModelUserCreateApiKeyRequest):

    Raises:
        errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
        httpx.TimeoutException: If the request takes longer than Client.timeout.

    Returns:
        ModelUserCreateApiKeyResponse
    """

    return (
        await asyncio_detailed(
            client=client,
            body=body,
        )
    ).parsed

Synchronous Detailed Response

kalshi_py.api.api_keys.create_api_key.sync_detailed(*, client: Union[AuthenticatedClient, Client], body: ModelUserCreateApiKeyRequest) -> Response[ModelUserCreateApiKeyResponse]

Create API Key

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.

Parameters:

Name Type Description Default
body ModelUserCreateApiKeyRequest
required

Raises:

Type Description
UnexpectedStatus

If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.

TimeoutException

If the request takes longer than Client.timeout.

Returns:

Type Description
Response[ModelUserCreateApiKeyResponse]

Response[ModelUserCreateApiKeyResponse]

Source code in kalshi_py/api/api_keys/create_api_key.py
def sync_detailed(
    *,
    client: Union[AuthenticatedClient, Client],
    body: ModelUserCreateApiKeyRequest,
) -> Response[ModelUserCreateApiKeyResponse]:
    """Create API Key

      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.

    Args:
        body (ModelUserCreateApiKeyRequest):

    Raises:
        errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
        httpx.TimeoutException: If the request takes longer than Client.timeout.

    Returns:
        Response[ModelUserCreateApiKeyResponse]
    """

    kwargs = _get_kwargs(
        body=body,
    )

    response = client.get_httpx_client().request(
        **kwargs,
    )

    return _build_response(client=client, response=response)

Asynchronous Detailed Response

kalshi_py.api.api_keys.create_api_key.asyncio_detailed(*, client: Union[AuthenticatedClient, Client], body: ModelUserCreateApiKeyRequest) -> Response[ModelUserCreateApiKeyResponse] async

Create API Key

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.

Parameters:

Name Type Description Default
body ModelUserCreateApiKeyRequest
required

Raises:

Type Description
UnexpectedStatus

If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.

TimeoutException

If the request takes longer than Client.timeout.

Returns:

Type Description
Response[ModelUserCreateApiKeyResponse]

Response[ModelUserCreateApiKeyResponse]

Source code in kalshi_py/api/api_keys/create_api_key.py
async def asyncio_detailed(
    *,
    client: Union[AuthenticatedClient, Client],
    body: ModelUserCreateApiKeyRequest,
) -> Response[ModelUserCreateApiKeyResponse]:
    """Create API Key

      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.

    Args:
        body (ModelUserCreateApiKeyRequest):

    Raises:
        errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
        httpx.TimeoutException: If the request takes longer than Client.timeout.

    Returns:
        Response[ModelUserCreateApiKeyResponse]
    """

    kwargs = _get_kwargs(
        body=body,
    )

    response = await client.get_async_httpx_client().request(**kwargs)

    return _build_response(client=client, response=response)

Delete Api Key

Synchronous Detailed Response

kalshi_py.api.api_keys.delete_api_key.sync_detailed(api_key: str, *, client: Union[AuthenticatedClient, Client]) -> Response[Any]

Delete API Key

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.

Parameters:

Name Type Description Default
api_key str

API key ID to delete

required

Raises:

Type Description
UnexpectedStatus

If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.

TimeoutException

If the request takes longer than Client.timeout.

Returns:

Type Description
Response[Any]

Response[Any]

Source code in kalshi_py/api/api_keys/delete_api_key.py
def sync_detailed(
    api_key: str,
    *,
    client: Union[AuthenticatedClient, Client],
) -> Response[Any]:
    """Delete API Key

      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.

    Args:
        api_key (str): API key ID to delete

    Raises:
        errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
        httpx.TimeoutException: If the request takes longer than Client.timeout.

    Returns:
        Response[Any]
    """

    kwargs = _get_kwargs(
        api_key=api_key,
    )

    response = client.get_httpx_client().request(
        **kwargs,
    )

    return _build_response(client=client, response=response)

Asynchronous Detailed Response

kalshi_py.api.api_keys.delete_api_key.asyncio_detailed(api_key: str, *, client: Union[AuthenticatedClient, Client]) -> Response[Any] async

Delete API Key

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.

Parameters:

Name Type Description Default
api_key str

API key ID to delete

required

Raises:

Type Description
UnexpectedStatus

If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.

TimeoutException

If the request takes longer than Client.timeout.

Returns:

Type Description
Response[Any]

Response[Any]

Source code in kalshi_py/api/api_keys/delete_api_key.py
async def asyncio_detailed(
    api_key: str,
    *,
    client: Union[AuthenticatedClient, Client],
) -> Response[Any]:
    """Delete API Key

      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.

    Args:
        api_key (str): API key ID to delete

    Raises:
        errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
        httpx.TimeoutException: If the request takes longer than Client.timeout.

    Returns:
        Response[Any]
    """

    kwargs = _get_kwargs(
        api_key=api_key,
    )

    response = await client.get_async_httpx_client().request(**kwargs)

    return _build_response(client=client, response=response)

Generate Api Key

Synchronous API Call

kalshi_py.api.api_keys.generate_api_key.sync(*, client: Union[AuthenticatedClient, Client], body: ModelUserGenerateApiKeyRequest) -> Optional[ModelUserGenerateApiKeyResponse]

Generate API Key

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.

Parameters:

Name Type Description Default
body ModelUserGenerateApiKeyRequest
required

Raises:

Type Description
UnexpectedStatus

If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.

TimeoutException

If the request takes longer than Client.timeout.

Returns:

Type Description
Optional[ModelUserGenerateApiKeyResponse]

ModelUserGenerateApiKeyResponse

Source code in kalshi_py/api/api_keys/generate_api_key.py
def sync(
    *,
    client: Union[AuthenticatedClient, Client],
    body: ModelUserGenerateApiKeyRequest,
) -> Optional[ModelUserGenerateApiKeyResponse]:
    """Generate API Key

      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.

    Args:
        body (ModelUserGenerateApiKeyRequest):

    Raises:
        errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
        httpx.TimeoutException: If the request takes longer than Client.timeout.

    Returns:
        ModelUserGenerateApiKeyResponse
    """

    return sync_detailed(
        client=client,
        body=body,
    ).parsed

Asynchronous API Call

kalshi_py.api.api_keys.generate_api_key.asyncio(*, client: Union[AuthenticatedClient, Client], body: ModelUserGenerateApiKeyRequest) -> Optional[ModelUserGenerateApiKeyResponse] async

Generate API Key

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.

Parameters:

Name Type Description Default
body ModelUserGenerateApiKeyRequest
required

Raises:

Type Description
UnexpectedStatus

If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.

TimeoutException

If the request takes longer than Client.timeout.

Returns:

Type Description
Optional[ModelUserGenerateApiKeyResponse]

ModelUserGenerateApiKeyResponse

Source code in kalshi_py/api/api_keys/generate_api_key.py
async def asyncio(
    *,
    client: Union[AuthenticatedClient, Client],
    body: ModelUserGenerateApiKeyRequest,
) -> Optional[ModelUserGenerateApiKeyResponse]:
    """Generate API Key

      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.

    Args:
        body (ModelUserGenerateApiKeyRequest):

    Raises:
        errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
        httpx.TimeoutException: If the request takes longer than Client.timeout.

    Returns:
        ModelUserGenerateApiKeyResponse
    """

    return (
        await asyncio_detailed(
            client=client,
            body=body,
        )
    ).parsed

Synchronous Detailed Response

kalshi_py.api.api_keys.generate_api_key.sync_detailed(*, client: Union[AuthenticatedClient, Client], body: ModelUserGenerateApiKeyRequest) -> Response[ModelUserGenerateApiKeyResponse]

Generate API Key

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.

Parameters:

Name Type Description Default
body ModelUserGenerateApiKeyRequest
required

Raises:

Type Description
UnexpectedStatus

If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.

TimeoutException

If the request takes longer than Client.timeout.

Returns:

Type Description
Response[ModelUserGenerateApiKeyResponse]

Response[ModelUserGenerateApiKeyResponse]

Source code in kalshi_py/api/api_keys/generate_api_key.py
def sync_detailed(
    *,
    client: Union[AuthenticatedClient, Client],
    body: ModelUserGenerateApiKeyRequest,
) -> Response[ModelUserGenerateApiKeyResponse]:
    """Generate API Key

      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.

    Args:
        body (ModelUserGenerateApiKeyRequest):

    Raises:
        errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
        httpx.TimeoutException: If the request takes longer than Client.timeout.

    Returns:
        Response[ModelUserGenerateApiKeyResponse]
    """

    kwargs = _get_kwargs(
        body=body,
    )

    response = client.get_httpx_client().request(
        **kwargs,
    )

    return _build_response(client=client, response=response)

Asynchronous Detailed Response

kalshi_py.api.api_keys.generate_api_key.asyncio_detailed(*, client: Union[AuthenticatedClient, Client], body: ModelUserGenerateApiKeyRequest) -> Response[ModelUserGenerateApiKeyResponse] async

Generate API Key

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.

Parameters:

Name Type Description Default
body ModelUserGenerateApiKeyRequest
required

Raises:

Type Description
UnexpectedStatus

If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.

TimeoutException

If the request takes longer than Client.timeout.

Returns:

Type Description
Response[ModelUserGenerateApiKeyResponse]

Response[ModelUserGenerateApiKeyResponse]

Source code in kalshi_py/api/api_keys/generate_api_key.py
async def asyncio_detailed(
    *,
    client: Union[AuthenticatedClient, Client],
    body: ModelUserGenerateApiKeyRequest,
) -> Response[ModelUserGenerateApiKeyResponse]:
    """Generate API Key

      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.

    Args:
        body (ModelUserGenerateApiKeyRequest):

    Raises:
        errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
        httpx.TimeoutException: If the request takes longer than Client.timeout.

    Returns:
        Response[ModelUserGenerateApiKeyResponse]
    """

    kwargs = _get_kwargs(
        body=body,
    )

    response = await client.get_async_httpx_client().request(**kwargs)

    return _build_response(client=client, response=response)

Get Api Keys

Synchronous API Call

kalshi_py.api.api_keys.get_api_keys.sync(*, client: Union[AuthenticatedClient, Client]) -> Optional[ModelUserGetApiKeysResponse]

Get API Keys

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.

Raises:

Type Description
UnexpectedStatus

If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.

TimeoutException

If the request takes longer than Client.timeout.

Returns:

Type Description
Optional[ModelUserGetApiKeysResponse]

ModelUserGetApiKeysResponse

Source code in kalshi_py/api/api_keys/get_api_keys.py
def sync(
    *,
    client: Union[AuthenticatedClient, Client],
) -> Optional[ModelUserGetApiKeysResponse]:
    """Get API Keys

      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.

    Raises:
        errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
        httpx.TimeoutException: If the request takes longer than Client.timeout.

    Returns:
        ModelUserGetApiKeysResponse
    """

    return sync_detailed(
        client=client,
    ).parsed

Asynchronous API Call

kalshi_py.api.api_keys.get_api_keys.asyncio(*, client: Union[AuthenticatedClient, Client]) -> Optional[ModelUserGetApiKeysResponse] async

Get API Keys

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.

Raises:

Type Description
UnexpectedStatus

If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.

TimeoutException

If the request takes longer than Client.timeout.

Returns:

Type Description
Optional[ModelUserGetApiKeysResponse]

ModelUserGetApiKeysResponse

Source code in kalshi_py/api/api_keys/get_api_keys.py
async def asyncio(
    *,
    client: Union[AuthenticatedClient, Client],
) -> Optional[ModelUserGetApiKeysResponse]:
    """Get API Keys

      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.

    Raises:
        errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
        httpx.TimeoutException: If the request takes longer than Client.timeout.

    Returns:
        ModelUserGetApiKeysResponse
    """

    return (
        await asyncio_detailed(
            client=client,
        )
    ).parsed

Synchronous Detailed Response

kalshi_py.api.api_keys.get_api_keys.sync_detailed(*, client: Union[AuthenticatedClient, Client]) -> Response[ModelUserGetApiKeysResponse]

Get API Keys

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.

Raises:

Type Description
UnexpectedStatus

If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.

TimeoutException

If the request takes longer than Client.timeout.

Returns:

Type Description
Response[ModelUserGetApiKeysResponse]

Response[ModelUserGetApiKeysResponse]

Source code in kalshi_py/api/api_keys/get_api_keys.py
def sync_detailed(
    *,
    client: Union[AuthenticatedClient, Client],
) -> Response[ModelUserGetApiKeysResponse]:
    """Get API Keys

      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.

    Raises:
        errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
        httpx.TimeoutException: If the request takes longer than Client.timeout.

    Returns:
        Response[ModelUserGetApiKeysResponse]
    """

    kwargs = _get_kwargs()

    response = client.get_httpx_client().request(
        **kwargs,
    )

    return _build_response(client=client, response=response)

Asynchronous Detailed Response

kalshi_py.api.api_keys.get_api_keys.asyncio_detailed(*, client: Union[AuthenticatedClient, Client]) -> Response[ModelUserGetApiKeysResponse] async

Get API Keys

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.

Raises:

Type Description
UnexpectedStatus

If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.

TimeoutException

If the request takes longer than Client.timeout.

Returns:

Type Description
Response[ModelUserGetApiKeysResponse]

Response[ModelUserGetApiKeysResponse]

Source code in kalshi_py/api/api_keys/get_api_keys.py
async def asyncio_detailed(
    *,
    client: Union[AuthenticatedClient, Client],
) -> Response[ModelUserGetApiKeysResponse]:
    """Get API Keys

      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.

    Raises:
        errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
        httpx.TimeoutException: If the request takes longer than Client.timeout.

    Returns:
        Response[ModelUserGetApiKeysResponse]
    """

    kwargs = _get_kwargs()

    response = await client.get_async_httpx_client().request(**kwargs)

    return _build_response(client=client, response=response)