Skip to content

Commit 6e6826d

Browse files
committed
Merge branch 'kite3'
2 parents cea0774 + e2b8ee8 commit 6e6826d

File tree

4 files changed

+715
-210
lines changed

4 files changed

+715
-210
lines changed

CHANGELOG.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
New features
2+
=============
3+
- method: `getProfile`
4+
- method: `getOHLC`
5+
- method: `getLTP`
6+
- method: `getMFOrders`
7+
- method: `getMFHoldings`
8+
- method: `placeMFOrder`
9+
- method: `cancelMFOrder`
10+
- method: `getMFSIPS`
11+
- method: `placeMFSIP`
12+
- method: `modifyMFSIP`
13+
- method: `cancelMFSIP`
14+
- method: `getMFInstruments`
15+
- method: `exitOrder`
16+
- method: `renewAccessToken`
17+
- method: `invalidateRefreshToken`
18+
19+
API method name changes
20+
=======================
21+
22+
| v2 | v3 |
23+
| ------------------------- | ------------------------- |
24+
| requestAccessToken | generateSession |
25+
| invalidateToken | invalidateAccessToken |
26+
| setSessionHook | setSessionExpiryHook |
27+
| loginUrl | getLoginURL |
28+
| margins | getMargins |
29+
| orderPlace | placeOrder |
30+
| orderModify | modifyOrder |
31+
| orderCancel | cancelOrder |
32+
| orders | getOrders |
33+
| orders(order_id) | getOrderHistory |
34+
| trades | getTrades |
35+
| trades(order_id) | getOrderTrades |
36+
| holdings | getHoldings |
37+
| positions | getPositions |
38+
| productModify | convertPosition |
39+
| instruments | getInstruments |
40+
| historical | getHistoricalData |
41+
| triggerRange | getTriggerRange |
42+
43+
Params and other changes
44+
========================
45+
- `convertPosition` method takes all the params as array
46+
- `getHistoricalData` method takes all the params as array
47+
- [Changes in `generateSession` response structure](https://kite.trade/docs/connect/v3/user/#response-attributes)
48+
- [Changes in `getPositions` response structure](https://kite.trade/docs/connect/v3/portfolio/#response-attributes_1)
49+
- [Changes in `getQuote` response structure](https://kite.trade/docs/connect/v3/market-quotes/#retrieving-full-market-quotes)
50+
- [Changes in `placeOrder` params](https://kite.trade/docs/connect/v3/orders/#bracket-order-bo-parameters)
51+
- Changes in `getHistoricalData` params
52+
- All datetime string fields has been converted to `Date` object.
53+
- `getOrders`, `getOrderHistory`, `getTrades`, `getOrderTrades`, `getMFOrders` responses fields `order_timestamp`, `exchange_timestamp`, `fill_timestamp`
54+
- `getMFSIPS` fields `created`, `last_instalment`
55+
- `generateSession` field `login_time`
56+
- `getQuote` fields `timestamp`, `last_trade_time`
57+
- `getInstruments` field `expiry`
58+
- `getMFInstruments` field `last_price_date`

README.md

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
> **NOTICE (Jan 2018): Upgrade to Kite Connect 3.0**
2-
> This repository is being phased and will be replaced soon by Kite Connect v3. Use the [kite3](https://github.com/zerodhatech/phpkiteconnect/tree/kite3) branch instead. Read the [announcement](https://kite.trade/forum/discussion/2998/upgrade-to-kite-connect-3-0) on the forum.
3-
4-
# The Kite Connect API PHP client
1+
# The Kite Connect API PHP client - v3
52
The official PHP client for communicating with the [Kite Connect API](https://kite.trade).
63

74
Kite Connect is a set of REST-like APIs that expose many capabilities required to build a complete investment and trading platform. Execute orders in real time, manage user portfolio and more, with the simple HTTP API collection.
85

9-
[Rainmatter](http://rainmatter.com) (c) 2016. Licensed under the MIT License.
6+
[Zerodha Technology](http://zerodha.com) (c) 2018. Licensed under the MIT License.
107

118
## Documentation
12-
- [PHP client documentation](https://kite.trade/docs/phpkiteconnect/)
13-
- [Kite Connect HTTP API documentation](https://kite.trade/docs/connect/v1)
9+
- [PHP client documentation](https://kite.trade/docs/phpkiteconnect/v3)
10+
- [Kite Connect HTTP API documentation](https://kite.trade/docs/connect/v3)
1411

1512
## Installing
1613
Download `kiteconnect.php` and `include()` it in your application.
@@ -27,7 +24,7 @@ Download `kiteconnect.php` and `include()` it in your application.
2724
// after the auth flow redirect by redirecting the
2825
// user to $kite->login_url()
2926
try {
30-
$user = $kite->requestAccessToken("request_token_obtained", "your_api_secret");
27+
$user = $kite->generateSession("request_token_obtained", "your_api_secret");
3128

3229
echo "Authentication successful. \n";
3330
print_r($user);
@@ -42,24 +39,24 @@ Download `kiteconnect.php` and `include()` it in your application.
4239

4340
// Get the list of positions.
4441
echo "Positions: \n";
45-
print_r($kite->positions());
42+
print_r($kite->getPositions());
4643

4744
// Place order.
48-
$order_id = $kite->orderPlace([
45+
$order_id = $kite->placeOrder("regular", [
4946
"tradingsymbol" => "INFY",
5047
"exchange" => "NSE",
5148
"quantity" => 1,
5249
"transaction_type" => "BUY",
5350
"order_type" => "MARKET",
5451
"product" => "NRML"
55-
], "regular");
52+
])["order_id"];
5653

5754
echo "Order id is ".$order_id;
55+
?>
5856
```
5957

60-
Refer to the [PHP client documentation](https://kite.trade/docs/phpkiteconnect/) for the complete list of supported methods.
61-
58+
Refer to the [PHP client documentation](https://kite.trade/docs/phpkiteconnect/v3) for the complete list of supported methods.
6259

6360
## Changelog
64-
- 2016-07-05 Added `$parent_order_id` to orderModify() and orderCancel() for multi-legged orders.
61+
[Check CHANGELOG.md](CHANGELOG.md)
6562

examples/kiteconnect_sample.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
include dirname(__FILE__)."/kiteconnect.php";
3+
4+
// Initialise.
5+
$kite = new KiteConnect("your_api_key");
6+
7+
// Assuming you have obtained the `request_token`
8+
// after the auth flow redirect by redirecting the
9+
// user to $kite->login_url()
10+
try {
11+
$user = $kite->generateSession("request_token_obtained", "your_api_secret");
12+
13+
echo "Authentication successful. \n";
14+
print_r($user);
15+
16+
$kite->setAccessToken($user->access_token);
17+
} catch(Exception $e) {
18+
echo "Authentication failed: ".$e->getMessage();
19+
throw $e;
20+
}
21+
22+
echo $user->user_id." has logged in";
23+
24+
// Get the list of positions.
25+
echo "Positions: \n";
26+
print_r($kite->getPositions());
27+
28+
// Get the list of holdings.
29+
echo "Holdings: \n";
30+
print_r($kite->getHoldings());
31+
32+
// Retrieve quote and market depth for list of instruments.
33+
echo "Quote: \n";
34+
print_r($kite->getQuote(["NSE:INFY", "NSE:SBIN"]));
35+
36+
// Place order.
37+
$order_id = $kite->placeOrder("regular", [
38+
"tradingsymbol" => "INFY",
39+
"exchange" => "NSE",
40+
"quantity" => 1,
41+
"transaction_type" => "BUY",
42+
"order_type" => "MARKET",
43+
"product" => "NRML"
44+
])["order_id"];
45+
46+
echo "Order id is ".$order_id;
47+
?>

0 commit comments

Comments
 (0)