Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Sahi

Use Broker Configuration and Login to save these credentials in OpenAlgo and connect the broker. The .env examples below remain supported; .env keys for the selected broker take precedence over database-saved keys.

Sahi is an Indian online stock trading platform. Its Direct API lets you place and manage orders, read your positions, holdings and funds, and stream live market data, which makes it a good fit for algorithmic trading through OpenAlgo.

Sahi signs you in with an API key and secret, not an OAuth login. There is no redirect URL to register with Sahi, no TOTP and nothing to type when you log in: OpenAlgo exchanges your saved key and secret for the day's access token.

Generating API Key and API Secret

  1. Open Sahi web, click your profile avatar (bottom left) and choose API Dashboard.

  1. Click Create API key. Complete two-factor verification if asked.

  2. Enter a Name you will recognise later, for example OpenAlgo.

  3. Choose the Access: pick Full access (orders and market data) and key type TOTP. A Market data key cannot place orders.

  1. Click Create API key.

  2. Copy the API key (starts with pk_) and the API secret (starts with sahi_sk_). The secret is shown only once.

  3. Tick I have saved my credentials and click Done.

Approve the key every trading day. After 6:00 AM IST the key shows Expired in the API Dashboard. Click Approve on it before you log in to OpenAlgo; until you do, Sahi will not issue a token and the OpenAlgo login fails with a message asking you to approve the key. A key created today is already approved. Sahi's access tokens also expire at 6:00 AM IST, so log in to OpenAlgo once each trading day.

Then store the key and secret in your .env file, and add sahi to VALID_BROKERS if it is not already listed. The REDIRECT_URL is not registered anywhere at Sahi; OpenAlgo uses it only to know which broker you use.

Last updated