Skip to main content
This guide will walk you through the complete lifecycle of placing and managing orders on Kalshi.

Prerequisites

Before you begin, you’ll need:
  • A Kalshi account with API access configured
  • Python with the requests and cryptography libraries installed
  • Your authentication functions set up (see our authentication guide)
This guide assumes you have the authentication code from our authentication guide, including the get() function for making authenticated requests.

Step 1: Find an Open Market

First, let’s find an open market to trade on.

Step 2: Place a Buy Order

Now let’s place an order to buy 1 YES contract for 1 cent (limit order). We’ll use a client_order_id to deduplicate orders - this allows you to identify duplicate orders before receiving the server-generated order_id in the response.

Complete Example Script

Here’s a complete script that creates your first order:

Important Notes

Client Order ID

The client_order_id field is optional, but strongly recommended for order deduplication:
  • Generate a unique ID (like UUID4) for each order before submission when you want idempotent retries
  • If network issues occur, you can resubmit with the same client_order_id
  • The API will reject duplicate submissions with the same client_order_id, preventing accidental double orders
  • Store this ID locally to track orders before receiving the server’s order_id

Error Handling

Common errors and how to handle them:
  • 401 Unauthorized: Check your API keys and signature generation
  • 400 Bad Request: Verify your order parameters (price must be 1-99 cents)
  • 409 Conflict: Order with this client_order_id already exists
  • 429 Too Many Requests: You’ve hit the rate limit - slow down your requests

Next Steps

Now that you’ve created your first order, you can:
  • Store the returned order_id and client_order_id for local tracking
  • Amend your order price or quantity using POST /portfolio/events/orders/{order_id}/amend
  • Cancel orders using DELETE /portfolio/events/orders/{order_id}
  • Implement WebSocket connections for real-time updates
  • Build automated trading strategies
For more information, check out: