PHPackages                             gopalindians/groww-php-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. gopalindians/groww-php-sdk

ActiveLibrary[API Development](/categories/api)

gopalindians/groww-php-sdk
==========================

PHP SDK for Groww Trading API

1.1.0(1y ago)23MITPHPPHP &gt;=7.4CI passing

Since Mar 30Pushed 1y ago1 watchersCompare

[ Source](https://github.com/gopalindians/groww-php-sdk)[ Packagist](https://packagist.org/packages/gopalindians/groww-php-sdk)[ Docs](https://github.com/gopalindians/groww-php-sdk)[ RSS](/packages/gopalindians-groww-php-sdk/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (4)Versions (3)Used By (0)

Groww PHP API SDK
=================

[](#groww-php-api-sdk)

[![Latest Stable Version](https://camo.githubusercontent.com/cc2b42584bfc55d063ceb0d99437bc3f091f41fc6002d16a94d45bf98a15a934/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f676f70616c696e6469616e732f67726f77772d7068702d73646b2e737667)](https://packagist.org/packages/gopalindians/groww-php-sdk)[![Total Downloads](https://camo.githubusercontent.com/024f5ef5fb3234411ed1b37afecec1ed7cc098c3910a053053e4a6090d28ea47/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f676f70616c696e6469616e732f67726f77772d7068702d73646b2e737667)](https://packagist.org/packages/gopalindians/groww-php-sdk)[![License](https://camo.githubusercontent.com/70d3839527c77fdff6698e21b09097133ceec84b6a90e87727d4715e86e693a7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f676f70616c696e6469616e732f67726f77772d7068702d73646b2e737667)](https://packagist.org/packages/gopalindians/groww-php-sdk)[![PHP Version](https://camo.githubusercontent.com/644fb1f405919bae4239f9a49ca6c6a3ca75197e0c07bc6c5e4539f098261e3d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f676f70616c696e6469616e732f67726f77772d7068702d73646b2e737667)](https://packagist.org/packages/gopalindians/groww-php-sdk)[![GitHub stars](https://camo.githubusercontent.com/74fddc59fce5ee7e777e6dfe17ce5d66ed09e4d73b46e0591e81b3df6da3253c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f676f70616c696e6469616e732f67726f77772d7068702d73646b2e737667)](https://github.com/gopalindians/groww-php-sdk/stargazers)[![GitHub issues](https://camo.githubusercontent.com/d14f3ef18816ee8ff36f459d460a4f2d22a70f11e9cc16d67ab253e6b60b594d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f676f70616c696e6469616e732f67726f77772d7068702d73646b2e737667)](https://github.com/gopalindians/groww-php-sdk/issues)[![Tests](https://github.com/gopalindians/groww-php-sdk/actions/workflows/php.yml/badge.svg)](https://github.com/gopalindians/groww-php-sdk/actions/workflows/php.yml)

A PHP SDK for interacting with the Groww Trading API.

Installation
------------

[](#installation)

Install via Composer:

```
composer require gopalindians/groww-php-sdk
```

Usage
-----

[](#usage)

### Authentication

[](#authentication)

```
use Groww\API\Client;

// Initialize the client with your API key
$groww = new Client('your_api_key_here');

// Optional: Enable logging
$groww->setLogging(true, function($level, $message, $context) {
    // Custom logging implementation
    error_log("[$level] $message " . json_encode($context));
});
```

### Trading

[](#trading)

#### Place a new order

[](#place-a-new-order)

```
try {
    $orderData = [
        'validity' => 'DAY',
        'exchange' => 'NSE',
        'transaction_type' => 'BUY',
        'order_type' => 'MARKET',
        'price' => 0,
        'product' => 'CNC',
        'quantity' => 1,
        'segment' => 'CASH',
        'trading_symbol' => 'IDEA'
    ];

    $result = $groww->orders()->create($orderData);
    print_r($result);
} catch (Groww\API\Exceptions\GrowwApiException $e) {
    echo "Error: " . $e->getMessage() . " (Code: " . $e->getErrorCode() . ")";
}
```

#### Get order details

[](#get-order-details)

```
try {
    $orderDetails = $groww->orders()->details('GMK39038RDT490CCVRO');
    print_r($orderDetails);
} catch (Groww\API\Exceptions\GrowwApiException $e) {
    echo "Error: " . $e->getMessage() . " (Code: " . $e->getErrorCode() . ")";
}
```

#### Cancel an order

[](#cancel-an-order)

```
try {
    $result = $groww->orders()->cancel('GMK39038RDT490CCVRO');
    print_r($result);
} catch (Groww\API\Exceptions\GrowwApiException $e) {
    echo "Error: " . $e->getMessage() . " (Code: " . $e->getErrorCode() . ")";
}
```

### Portfolio Management

[](#portfolio-management)

#### Get holdings

[](#get-holdings)

```
try {
    $holdings = $groww->portfolio()->holdings();
    print_r($holdings);
} catch (Groww\API\Exceptions\GrowwApiException $e) {
    echo "Error: " . $e->getMessage() . " (Code: " . $e->getErrorCode() . ")";
}
```

#### Get positions

[](#get-positions)

```
try {
    $positions = $groww->portfolio()->positions();
    print_r($positions);
} catch (Groww\API\Exceptions\GrowwApiException $e) {
    echo "Error: " . $e->getMessage() . " (Code: " . $e->getErrorCode() . ")";
}
```

### Market Data

[](#market-data)

#### Search for instruments

[](#search-for-instruments)

```
try {
    $searchResults = $groww->instruments()->search('RELIANCE');
    print_r($searchResults);
} catch (Groww\API\Exceptions\GrowwApiException $e) {
    echo "Error: " . $e->getMessage() . " (Code: " . $e->getErrorCode() . ")";
}
```

#### Get live quotes

[](#get-live-quotes)

```
try {
    $quotes = $groww->liveData()->quotes(['RELIANCE', 'IDEA']);
    print_r($quotes);
} catch (Groww\API\Exceptions\GrowwApiException $e) {
    echo "Error: " . $e->getMessage() . " (Code: " . $e->getErrorCode() . ")";
}
```

#### Get historical data

[](#get-historical-data)

```
try {
    $candleData = $groww->historicalData()->candles(
        'RELIANCE',
        '1d',
        '2023-01-01',
        '2023-01-31'
    );
    print_r($candleData);
} catch (Groww\API\Exceptions\GrowwApiException $e) {
    echo "Error: " . $e->getMessage() . " (Code: " . $e->getErrorCode() . ")";
}
```

### Margin Information

[](#margin-information)

```
try {
    $availableMargin = $groww->margin()->available();
    print_r($availableMargin);
} catch (Groww\API\Exceptions\GrowwApiException $e) {
    echo "Error: " . $e->getMessage() . " (Code: " . $e->getErrorCode() . ")";
}
```

Error Handling
--------------

[](#error-handling)

The SDK throws `GrowwApiException` when an error occurs. You can catch this exception to handle errors gracefully:

```
try {
    // API operations
} catch (Groww\API\Exceptions\GrowwRateLimitException $e) {
    // Handle rate limiting specifically
    echo "Rate limit exceeded. Try again after " . $e->getWaitTime() . " seconds.\n";
    sleep($e->getWaitTime());

    // Retry the request
} catch (Groww\API\Exceptions\GrowwApiException $e) {
    echo "Error message: " . $e->getMessage() . "\n";
    echo "Error code: " . $e->getErrorCode() . "\n";

    // Handle different error codes
    switch ($e->getErrorCode()) {
        case 'GA001':
            echo "Bad request - check your parameters\n";
            break;
        case 'GA005':
            echo "Authentication error - check your API key\n";
            break;
        default:
            echo "Unknown error occurred\n";
            break;
    }
}
```

Security Features
-----------------

[](#security-features)

This SDK implements several security best practices:

1. **Input Validation**: All inputs are validated before being sent to the API.
2. **TLS/SSL Verification**: HTTPS connections are enforced by default.
3. **Rate Limiting Protection**: Built-in rate limiting with exponential backoff.
4. **Parameter Sanitization**: All parameters are sanitized to prevent injection attacks.
5. **Sensitive Data Protection**: API keys and other sensitive data are redacted in logs.
6. **Error Handling**: Comprehensive error handling for security-related issues.

### Secure Logging

[](#secure-logging)

The SDK includes a secure logging system that redacts sensitive information:

```
// Enable logging with a custom logger
$groww->setLogging(true, function($level, $message, $context) {
    // Custom logging implementation
    // All sensitive data is automatically redacted
});
```

Testing
-------

[](#testing)

The SDK comes with a comprehensive test suite. To run the tests:

1. Install development dependencies:

```
composer install --dev
```

2. Run PHPUnit:

```
./vendor/bin/phpunit
```

### Continuous Integration

[](#continuous-integration)

This project uses GitHub Actions for continuous integration. Every time code is pushed to the `main` or `master` branch, or when a pull request is created against these branches, the test suite is automatically executed on multiple PHP versions (7.4, 8.0, and 8.1).

The CI pipeline:

1. Sets up the PHP environment
2. Installs dependencies via Composer
3. Runs the PHPUnit test suite

You can check the workflow configuration in the `.github/workflows/php-tests.yml` file.

### Writing Your Own Tests

[](#writing-your-own-tests)

You can use the existing test suite as a reference for writing your own tests. The SDK provides mock responses and helpers to make testing easier:

```
use Groww\API\Tests\TestCase;
use Groww\API\Client;
use GuzzleHttp\Handler\MockHandler;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Psr7\Response;
use GuzzleHttp\Client as HttpClient;

class YourTest extends TestCase
{
    public function testYourMethod()
    {
        // Create a mock response
        $mockResponse = $this->createSuccessResponse(['data' => 'value']);

        // Set up mock handler
        $mock = new MockHandler([
            new Response(200, [], json_encode($mockResponse))
        ]);

        $handlerStack = HandlerStack::create($mock);
        $httpClient = new HttpClient(['handler' => $handlerStack]);

        // Create client with mock
        $client = new Client($this->getTestApiKey());
        $client->setHttpClient($httpClient);

        // Test your code
        $result = $client->get('/endpoint');

        // Assert results
        $this->assertEquals($mockResponse, $result);
    }
}
```

API Documentation
-----------------

[](#api-documentation)

For the full API reference, visit the Groww API documentation at:

License
-------

[](#license)

MIT

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance46

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

406d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/db5d05d820dcff11750c95bbc7f80e6554ff619e9ebede8fafab2fbf0b013a72?d=identicon)[gopalindians](/maintainers/gopalindians)

---

Top Contributors

[![gopalindians](https://avatars.githubusercontent.com/u/1937433?v=4)](https://github.com/gopalindians "gopalindians (16 commits)")

---

Tags

apiapi-clientgrowwphpsdkstock-marketapisdkfinancetradingstocksinvestmentgrowwalgo-tradingstock-marketstock-brokerstock-market-apistock-market-sdkstock-market-brokerstock-market-tradingstock-market-investmentstock-market-algo-trading

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/gopalindians-groww-php-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/gopalindians-groww-php-sdk/health.svg)](https://phpackages.com/packages/gopalindians-groww-php-sdk)
```

###  Alternatives

[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k7.6M74](/packages/openai-php-laravel)[hubspot/api-client

Hubspot API client

23414.2M16](/packages/hubspot-api-client)[mailchimp/transactional

458.9M16](/packages/mailchimp-transactional)[resend/resend-php

Resend PHP library.

564.7M21](/packages/resend-resend-php)[checkout/checkout-sdk-php

Checkout.com SDK for PHP

553.3M7](/packages/checkout-checkout-sdk-php)[mozex/anthropic-laravel

Anthropic PHP for Laravel is a supercharged PHP API client that allows you to interact with the Anthropic API

71226.4k1](/packages/mozex-anthropic-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
