PHPackages                             sashalenz/dinstar-api - 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. sashalenz/dinstar-api

ActiveLibrary[API Development](/categories/api)

sashalenz/dinstar-api
=====================

Laravel client for the Dinstar GSM Gateway HTTP API

1.0.0(2mo ago)016MITPHPPHP ^8.3|^8.4|^8.5

Since Apr 1Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/sashalenz/dinstar-api)[ Packagist](https://packagist.org/packages/sashalenz/dinstar-api)[ Docs](https://github.com/sashalenz/dinstar-api)[ RSS](/packages/sashalenz-dinstar-api/feed)WikiDiscussions main Synced today

READMEChangelog (4)Dependencies (16)Versions (5)Used By (0)

Dinstar GSM Gateway API for Laravel
===================================

[](#dinstar-gsm-gateway-api-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/d75890c423e50f41648da31a6c846baa843d4692b2c105725005734663a15db1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73617368616c656e7a2f64696e737461722d6170692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sashalenz/dinstar-api)[![Total Downloads](https://camo.githubusercontent.com/6e5139e0dad288996ca7647f57691ecd123efa7fdca5827001d6693c75adc69b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73617368616c656e7a2f64696e737461722d6170692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sashalenz/dinstar-api)

A Laravel client for the **Dinstar GSM Gateway HTTP API** (the "new API", firmware ≥ 1102). Implements every endpoint described in the official [`Dinstar GSM Gateway HTTP API`](https://www.dinstar.com/) document (v202011): SMS, USSD, port management, CDR, STK, device status, and the push-event payloads that the gateway can send back to your application.

Requirements
------------

[](#requirements)

PackageVersionPHP`^8.3 | ^8.4 | ^8.5`Laravel`^11.0 | ^12.0 | ^13.0`Installation
------------

[](#installation)

```
composer require sashalenz/dinstar-api
```

Publish the configuration file:

```
php artisan vendor:publish --tag="dinstar-api-config"
```

Then add the gateway credentials to your `.env`:

```
DINSTAR_API_URL=https://192.168.1.10
DINSTAR_API_USERNAME=admin
DINSTAR_API_PASSWORD=admin

# Optional
DINSTAR_API_TIMEOUT=10
DINSTAR_API_RETRY_TIMES=3
DINSTAR_API_RETRY_SLEEP=100
DINSTAR_API_VERIFY_SSL=false
```

Most Dinstar units ship with a self-signed certificate, so `DINSTAR_API_VERIFY_SSL`defaults to `false`. Set it to `true` if you have installed a valid certificate.

> Make sure the **new-version API** is enabled on the gateway: *Mobile Configuration → Basic Configuration → API*.

Usage
-----

[](#usage)

The service is registered as a singleton and is exposed through the `DinstarApi` facade and the `Sashalenz\DinstarApi\DinstarApi` class.

```
use Sashalenz\DinstarApi\Facades\DinstarApi;

$response = DinstarApi::sendSms('Hello!', [['number' => '+380501234567']]);
$response->get('task_id'); // 7
```

Every method returns an `Illuminate\Support\Collection` containing the raw JSON response from the gateway. Gateway-side errors raise `Sashalenz\DinstarApi\Exceptions\DinstarException`.

### Talking to multiple gateways

[](#talking-to-multiple-gateways)

```
DinstarApi::for('https://10.0.0.5', 'admin', 'secret')
    ->sendSms('Hi', [['number' => '+380501234567']]);
```

---

API reference
-------------

[](#api-reference)

### SMS

[](#sms)

```
use Sashalenz\DinstarApi\Enums\SmsEncoding;

DinstarApi::sendSms(
    text: '#param#',
    recipients: [
        ['number' => '+380501234567', 'text_param' => ['Bob'], 'user_id' => 1],
        ['number' => '+380939876543', 'text_param' => ['Alice'], 'user_id' => 2],
    ],
    ports: [2, 3],                 // optional
    encoding: SmsEncoding::UNICODE, // or SmsEncoding::GSM_7BIT
    requestStatusReport: true,
);
```

Other SMS endpoints:

```
DinstarApi::querySmsResult(userIds: [1, 2]);
DinstarApi::querySmsDeliverStatus(numbers: ['+380501234567']);
DinstarApi::querySmsInQueue();
DinstarApi::queryIncomingSms(flag: \Sashalenz\DinstarApi\Enums\IncomingSmsFlag::ALL);
DinstarApi::stopSms(taskId: 7);
```

### USSD

[](#ussd)

```
use Sashalenz\DinstarApi\Enums\UssdCommand;

DinstarApi::sendUssd(ports: [1, 2], text: '*125#');
DinstarApi::sendUssd(ports: [1], text: '', command: UssdCommand::CANCEL);
DinstarApi::queryUssdReply([1, 2]);
```

### Port / SIM management

[](#port--sim-management)

```
use Sashalenz\DinstarApi\Enums\PortAction;
use Sashalenz\DinstarApi\Enums\PortInfoType;

DinstarApi::getPortInfo(
    infoTypes: [PortInfoType::TYPE, PortInfoType::IMEI, PortInfoType::SIGNAL],
    ports: [1, 2, 3],
);

DinstarApi::setPortInfo(port: 1, action: PortAction::POWER, param: 'off');
DinstarApi::setPortInfo(port: 1, action: PortAction::RESET);
DinstarApi::setPortInfo(port: 1, action: PortAction::SLOT, param: '2');
```

### Call forwarding

[](#call-forwarding)

```
use Sashalenz\DinstarApi\Enums\CallForwardType;

DinstarApi::setCallForward(8, CallForwardType::UNCONDITIONAL, '15013828917');
DinstarApi::checkCallForward(8);
DinstarApi::getCallForward(8);
```

### CDR

[](#cdr)

```
DinstarApi::getCdr(
    ports: [2, 3],
    timeAfter: '2024-01-01 00:00:00',
    timeBefore: now(),
);
```

### STK

[](#stk)

```
use Sashalenz\DinstarApi\Enums\StkAction;

DinstarApi::getStkView(0);
DinstarApi::stkGo(port: 7, item: 1);
DinstarApi::stkGo(port: 7, action: StkAction::CANCEL);
DinstarApi::getStkCurrFrameIndex(0);
```

### Device status

[](#device-status)

```
DinstarApi::getStatus(); // ['performance']
```

---

Notification channel
--------------------

[](#notification-channel)

The package ships a Laravel notification channel — `DinstarSmsChannel` — so you can dispatch SMS through the gateway with the regular notification pipeline (queues, events, on-demand notifications, all of it).

Add the channel to your notification's `via()` and implement `toDinstarSms()`:

```
use Illuminate\Notifications\Notification;
use Sashalenz\DinstarApi\Notifications\DinstarSmsChannel;
use Sashalenz\DinstarApi\Notifications\DinstarSmsMessage;

class OrderShipped extends Notification
{
    public function via(object $notifiable): array
    {
        return [DinstarSmsChannel::class]; // or 'dinstar-sms'
    }

    public function toDinstarSms(object $notifiable): DinstarSmsMessage
    {
        return DinstarSmsMessage::create('Your order has shipped!')
            ->ports([1, 2])         // optional
            ->withoutDeliveryReport() // optional
            ->userId($this->order->id); // optional
    }
}
```

`toDinstarSms()` may also return a plain string for the simplest case:

```
public function toDinstarSms(object $notifiable): string
{
    return 'Your code is 12345';
}
```

Tell Laravel where to route the SMS by adding `routeNotificationForDinstarSms`to the notifiable model — return either a string or an array of phone numbers:

```
class User extends Authenticatable
{
    use Notifiable;

    public function routeNotificationForDinstarSms($notification)
    {
        return $this->phone;
    }
}
```

On-demand notifications work the same:

```
Notification::route('dinstar-sms', '+380501234567')
    ->notify(new OrderShipped($order));
```

---

Push events
-----------

[](#push-events)

The gateway can be configured to push events (incoming SMS, sending results, delivery receipts, USSD replies, register status, CDR, device events, exceptions) to your application. Use `PushEvent` to parse them in a single controller:

```
use Sashalenz\DinstarApi\PushEvent;

Route::post('/dinstar/push', function (Request $request) {
    $event = PushEvent::fromPayload($request->getContent());

    match (true) {
        $event->isIncomingSms()    => IncomingSms::ingest($event->sn, $event->data),
        $event->isSmsResult()      => SmsResult::ingest($event->sn, $event->data),
        $event->isDeliverStatus()  => DeliverStatus::ingest($event->sn, $event->data),
        $event->isCdr()            => Cdr::ingest($event->sn, $event->data),
        default                    => null,
    };

    return response()->noContent();
});
```

---

Error handling
--------------

[](#error-handling)

```
use Sashalenz\DinstarApi\Exceptions\DinstarException;

try {
    DinstarApi::sendSms('Hi', [['number' => '+380501234567']]);
} catch (DinstarException $e) {
    // $e->getCode()    -> the gateway error_code (550, 413, 500, …)
    // $e->endpoint     -> the API path that failed
    // $e->payload      -> the full decoded response (when available)
}
```

The package recognises the documented error codes (`200`, `202`, `400`, `404`, `413`, `500`, `550`) and includes a human-readable description in the exception message.

Testing
-------

[](#testing)

```
composer test
```

The test suite uses [Pest](https://pestphp.com/) and Laravel's `Http::fake()` to stub gateway responses, so it runs without any network access.

Code style
----------

[](#code-style)

```
composer format
```

Changelog
---------

[](#changelog)

See [CHANGELOG](CHANGELOG.md).

Credits
-------

[](#credits)

- [Oleksandr Petrovskyi](https://github.com/sashalenz)

License
-------

[](#license)

The MIT License (MIT). See [LICENSE](LICENSE.md).

###  Health Score

45

—

FairBetter than 91% of packages

Maintenance87

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity69

Established project with proven stability

 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 ~496 days

Total

4

Last Release

64d ago

Major Versions

0.1.0 → 1.0.02026-04-29

PHP version history (2 changes)0.0.1PHP ^8.1

1.0.0PHP ^8.3|^8.4|^8.5

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/13202688?v=4)[Oleksandr Petrovskyi](/maintainers/sashalenz)[@sashalenz](https://github.com/sashalenz)

---

Top Contributors

[![sashalenz](https://avatars.githubusercontent.com/u/13202688?v=4)](https://github.com/sashalenz "sashalenz (5 commits)")

---

Tags

laravelsmsgatewaygsmussdsashalenzdinstar-apidinstar

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/sashalenz-dinstar-api/health.svg)

```
[![Health](https://phpackages.com/badges/sashalenz-dinstar-api/health.svg)](https://phpackages.com/packages/sashalenz-dinstar-api)
```

###  Alternatives

[defstudio/telegraph

A laravel facade to interact with Telegram Bots

816333.3k3](/packages/defstudio-telegraph)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5021.9k](/packages/simplestats-io-laravel-client)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

77022.3M150](/packages/laravel-mcp)[harris21/laravel-fuse

Circuit breaker for Laravel queue jobs. Protect your workers from cascading failures.

44855.7k](/packages/harris21-laravel-fuse)[api-platform/laravel

API Platform support for Laravel

58170.8k14](/packages/api-platform-laravel)

PHPackages © 2026

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