Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Samples are grouped by API area. Each `.md` file contains one or more Python sni
| [**margins/**](margins/) | Margin details. |
| [**charges/**](charges/) | Brokerage details. |
| [**mutual-funds-api/**](mutual-funds-api/) | Mutual fund holdings, orders, order details, and SIPs. |
| [**payments-api/**](payments-api/) | Payin and payout history. |
| [**news/**](news/) | News articles by instrument keys, positions, or holdings. |
| [**trade-profit-and-loss/**](trade-profit-and-loss/) | P&L report, report metadata, trade charges. |
| [**strategies/**](strategies/) | Ready-to-run options strategy examples for Nifty 50 (bullish, bearish, neutral, others). |
Expand Down
11 changes: 11 additions & 0 deletions examples/payments-api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Payments API – Example code

Links to all payments-related examples in the `code/` folder.

## 1. Get Payin History

- 1.1 [Get payin history](code/get-payin-history.md#get-payin-history)

## 2. Get Payout History

- 2.1 [Get payout history](code/get-payout-history.md#get-payout-history)
17 changes: 17 additions & 0 deletions examples/payments-api/code/get-payin-history.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## Get Payin History

```python
import upstox_client
from upstox_client.rest import ApiException

configuration = upstox_client.Configuration()
configuration.access_token = '{your_access_token}'

api_instance = upstox_client.UserApi(upstox_client.ApiClient(configuration))

try:
api_response = api_instance.get_payin_history()
print(api_response)
except ApiException as e:
print("Exception when calling UserApi->get_payin_history: %s\n" % e)
```
17 changes: 17 additions & 0 deletions examples/payments-api/code/get-payout-history.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## Get Payout History

```python
import upstox_client
from upstox_client.rest import ApiException

configuration = upstox_client.Configuration()
configuration.access_token = '{your_access_token}'

api_instance = upstox_client.UserApi(upstox_client.ApiClient(configuration))

try:
api_response = api_instance.get_payout_history()
print(api_response)
except ApiException as e:
print("Exception when calling UserApi->get_payout_history: %s\n" % e)
```
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
long_description = (this_directory / "README.md").read_text()

NAME = "upstox-python-sdk"
VERSION = "2.24.0"
VERSION = "2.25.0"
# To install the library, run the following
#
# python setup.py install
Expand Down
56 changes: 56 additions & 0 deletions test/sdk_tests/sanity.py
Original file line number Diff line number Diff line change
Expand Up @@ -1036,6 +1036,62 @@ def is_within_market_hours():
if mf_sips_resp is None:
print("error: GetMutualFundSipsResponse instantiation failed")

# ========================================
# PAYMENTS API TESTS
# ========================================

api_instance = upstox_client.UserApi(upstox_client.ApiClient(configuration))

try:
api_response = api_instance.get_payin_history()
if api_response.status != "success":
print("error in get_payin_history")
except ApiException as e:
print("Exception when calling UserApi->get_payin_history: %s\n" % e)

api_instance = upstox_client.UserApi(upstox_client.ApiClient(configuration))

try:
api_response = api_instance.get_payout_history()
if api_response.status != "success":
print("error in get_payout_history")
except ApiException as e:
print("Exception when calling UserApi->get_payout_history: %s\n" % e)

# Model instantiation smoke tests for PaymentHistoryData and PaymentHistoryResponse
payment_data = upstox_client.PaymentHistoryData()
if payment_data is None:
print("error: PaymentHistoryData instantiation failed")

payment_data_with_fields = upstox_client.PaymentHistoryData(
amount=1000.0,
mode="NEFT",
status="SUCCESS",
reason=None,
last_updated_at="2026-05-04T10:00:00Z",
bank_name="Test Bank",
transaction_id="TXN123456",
total_charges=0.0,
charges_category="PAYIN"
)
if payment_data_with_fields.amount != 1000.0:
print("error: PaymentHistoryData amount field not set correctly")
if payment_data_with_fields.mode != "NEFT":
print("error: PaymentHistoryData mode field not set correctly")
if payment_data_with_fields.transaction_id != "TXN123456":
print("error: PaymentHistoryData transaction_id field not set correctly")

payment_response = upstox_client.PaymentHistoryResponse()
if payment_response is None:
print("error: PaymentHistoryResponse instantiation failed")

payment_response_with_data = upstox_client.PaymentHistoryResponse(
status="success",
data=[payment_data_with_fields]
)
if payment_response_with_data.status != "success":
print("error: PaymentHistoryResponse status field not set correctly")

login_api_instance = upstox_client.LoginApi(upstox_client.ApiClient(configuration))
try:
# Logout
Expand Down
14 changes: 8 additions & 6 deletions upstox_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
# flake8: noqa

"""
Upstox Developer API
OpenAPI definition

Build your App on the Upstox platform ![Banner](https://api.upstox.com/api-docs/images/banner.jpg "banner") # Introduction Upstox API is a set of rest APIs that provide data required to build a complete investment and trading platform. Execute orders in real time, manage user portfolio, stream live market data (using Websocket), and more, with the easy to understand API collection. All requests are over HTTPS and the requests are sent with the content-type 'application/json'. Developers have the option of choosing the response type as JSON or CSV for a few API calls. To be able to use these APIs you need to create an App in the Developer Console and generate your **apiKey** and **apiSecret**. You can use a redirect URL which will be called after the login flow. If you are a **trader**, you can directly create apps from Upstox mobile app or the desktop platform itself from **Apps** sections inside the **Account** Tab. Head over to <a href="http://account.upstox.com/developer/apps" target="_blank">account.upstox.com/developer/apps</a>.</br> If you are a **business** looking to integrate Upstox APIs, reach out to us and we will get a custom app created for you in no time. It is highly recommended that you do not embed the **apiSecret** in your frontend app. Create a remote backend which does the handshake on behalf of the frontend app. Marking the apiSecret in the frontend app will make your app vulnerable to threats and potential issues. # noqa: E501

OpenAPI spec version: v2
No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) # noqa: E501

OpenAPI spec version: v0

Generated by: https://github.com/swagger-api/swagger-codegen.git
"""

Expand Down Expand Up @@ -52,12 +52,12 @@
from upstox_client.models.cancel_or_exit_multi_order_response import CancelOrExitMultiOrderResponse
from upstox_client.models.cancel_or_exit_order_error_data import CancelOrExitOrderErrorData
from upstox_client.models.cancel_order_data import CancelOrderData
from upstox_client.models.cancel_order_response import CancelOrderResponse
from upstox_client.models.cancel_order_v3_response import CancelOrderV3Response
from upstox_client.models.cash_available_to_trade import CashAvailableToTrade
from upstox_client.models.cash_breakdown import CashBreakdown
from upstox_client.models.cash_margin_used import CashMarginUsed
from upstox_client.models.cash_unavailable_to_trade import CashUnavailableToTrade
from upstox_client.models.cancel_order_response import CancelOrderResponse
from upstox_client.models.cancel_order_v3_response import CancelOrderV3Response
from upstox_client.models.convert_position_data import ConvertPositionData
from upstox_client.models.convert_position_request import ConvertPositionRequest
from upstox_client.models.convert_position_response import ConvertPositionResponse
Expand Down Expand Up @@ -167,6 +167,8 @@
from upstox_client.models.order_metadata import OrderMetadata
from upstox_client.models.other_taxes import OtherTaxes
from upstox_client.models.pagination import Pagination
from upstox_client.models.payment_history_data import PaymentHistoryData
from upstox_client.models.payment_history_response import PaymentHistoryResponse
from upstox_client.models.place_order_data import PlaceOrderData
from upstox_client.models.place_order_request import PlaceOrderRequest
from upstox_client.models.place_order_response import PlaceOrderResponse
Expand Down
Loading
Loading