The official PHP client for communicating with the Upstox API.
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.
- API version: v2
- Build package: io.swagger.codegen.v3.generators.php.PhpClientCodegen
This PHP package is automatically generated by the Swagger Codegen project:
PHP 7.4 and later
Run composer require upstox/upstox-php-sdk
to install the SDK from Packagist.
Download the latest release and run composer install
Download the files and include autoload.php
:
require_once('/path/to/UpstoxClient/vendor/autoload.php');
To run the unit tests:
composer install
./vendor/bin/phpunit
Please follow the installation procedure and then run the following:
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure OAuth2 access token for authorization: OAUTH2
$config = Upstox\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
$apiInstance = new Upstox\Client\Api\ChargeApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$instrument_token = "instrument_token_example"; // string | Key of the instrument
$quantity = 56; // int | Quantity with which the order is to be placed
$product = "product_example"; // string | Product with which the order is to be placed
$transaction_type = "transaction_type_example"; // string | Indicates whether its a BUY or SELL order
$price = 3.4; // float | Price with which the order is to be placed
$api_version = "api_version_example"; // string | API Version Header
try {
$result = $apiInstance->getBrokerage($instrument_token, $quantity, $product, $transaction_type, $price, $api_version);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling ChargeApi->getBrokerage: ', $e->getMessage(), PHP_EOL;
}
?>
All URIs are relative to https://api-v2.upstox.com
Class | Method | HTTP request | Description |
---|---|---|---|
ChargeApi | getBrokerage | GET /charges/brokerage | Brokerage details |
HistoryApi | getHistoricalCandleData | GET /historical-candle/{instrumentKey}/{interval}/{to_date} | Historical candle data |
HistoryApi | getHistoricalCandleData1 | GET /historical-candle/{instrumentKey}/{interval}/{to_date}/{from_date} | Historical candle data |
HistoryApi | getIntraDayCandleData | GET /historical-candle/intraday/{instrumentKey}/{interval} | Intra day candle data |
LoginApi | authorize | GET /login/authorization/dialog | Authorize API |
LoginApi | logout | DELETE /logout | Logout |
LoginApi | token | POST /login/authorization/token | Get token API |
MarketQuoteApi | getFullMarketQuote | GET /market-quote/quotes | Market quotes and instruments - Full market quotes |
MarketQuoteApi | getMarketQuoteOHLC | GET /market-quote/ohlc | Market quotes and instruments - OHLC quotes |
MarketQuoteApi | ltp | GET /market-quote/ltp | Market quotes and instruments - LTP quotes. |
OrderApi | cancelOrder | DELETE /order/cancel | Cancel order |
OrderApi | getOrderBook | GET /order/retrieve-all | Get order book |
OrderApi | getOrderDetails | GET /order/history | Get order details |
OrderApi | getTradeHistory | GET /order/trades/get-trades-for-day | Get trades |
OrderApi | getTradesByOrder | GET /order/trades | Get trades for order |
OrderApi | modifyOrder | PUT /order/modify | Modify order |
OrderApi | placeOrder | POST /order/place | Place order |
PortfolioApi | convertPositions | PUT /portfolio/convert-position | Convert Positions |
PortfolioApi | getHoldings | GET /portfolio/long-term-holdings | Get Holdings |
PortfolioApi | getPositions | GET /portfolio/short-term-positions | Get Positions |
TradeProfitAndLossApi | getProfitAndLossCharges | GET /trade/profit-loss/charges | Get profit and loss on trades |
TradeProfitAndLossApi | getTradeWiseProfitAndLossData | GET /trade/profit-loss/data | Get Trade-wise Profit and Loss Report Data |
TradeProfitAndLossApi | getTradeWiseProfitAndLossMetaData | GET /trade/profit-loss/metadata | Get profit and loss meta data on trades |
UserApi | getProfile | GET /user/profile | Get profile |
UserApi | getUserFundMargin | GET /user/get-funds-and-margin | Get User Fund And Margin |
WebsocketApi | getMarketDataFeed | GET /feed/market-data-feed | Market Data Feed |
WebsocketApi | getMarketDataFeedAuthorize | GET /feed/market-data-feed/authorize | Market Data Feed Authorize |
WebsocketApi | getPortfolioStreamFeed | GET /feed/portfolio-stream-feed | Portfolio Stream Feed |
WebsocketApi | getPortfolioStreamFeedAuthorize | GET /feed/portfolio-stream-feed/authorize | Portfolio Stream Feed Authorize |
- ApiGatewayErrorResponse
- BrokerageData
- BrokerageTaxes
- BrokerageWrapperData
- CancelOrderData
- CancelOrderResponse
- ConvertPositionData
- ConvertPositionRequest
- ConvertPositionResponse
- Depth
- DepthMap
- DpPlan
- GetBrokerageResponse
- GetFullMarketQuoteResponse
- GetHistoricalCandleResponse
- GetHoldingsResponse
- GetIntraDayCandleResponse
- GetMarketQuoteLastTradedPriceResponse
- GetMarketQuoteOHLCResponse
- GetOrderBookResponse
- GetOrderResponse
- GetPositionResponse
- GetProfileResponse
- GetProfitAndLossChargesResponse
- GetTradeResponse
- GetTradeWiseProfitAndLossDataResponse
- GetTradeWiseProfitAndLossMetaDataResponse
- GetUserFundMarginResponse
- HistoricalCandleData
- HoldingsData
- IntraDayCandleData
- LogoutResponse
- MarketQuoteOHLC
- MarketQuoteSymbol
- MarketQuoteSymbolLtp
- ModifyOrderData
- ModifyOrderRequest
- ModifyOrderResponse
- OAuthClientException
- OAuthClientExceptionCause
- OAuthClientExceptionCauseStackTrace
- OAuthClientExceptionCauseSuppressed
- Ohlc
- OrderBookData
- OrderData
- OtherTaxes
- PlaceOrderData
- PlaceOrderRequest
- PlaceOrderResponse
- PositionData
- Problem
- ProfileData
- ProfitAndLossChargesData
- ProfitAndLossChargesTaxes
- ProfitAndLossChargesWrapperData
- ProfitAndLossMetaData
- ProfitAndLossMetaDataWrapper
- ProfitAndLossOtherChargesTaxes
- TokenRequest
- TokenResponse
- TradeData
- TradeWiseMetaData
- TradeWiseProfitAndLossData
- UserFundMarginData
- WebsocketAuthRedirectResponse
- WebsocketAuthRedirectResponseData