Search by

dotsplatform / nova-poshta-api-sdk-laravel

dotsplatfolrm

Laravel package for the Nova Poshta classic API 2.0 - https://developers.novaposhta.ua/

Package info

github.com/dotsplatform/nova-poshta-api-sdk-laravel

pkg:composer/dotsplatform/nova-poshta-api-sdk-laravel

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.0 2026-11-27 20:23 UTC

This package is auto-updated.

Last update: 2026-11-28 10:59:04 UTC


README

Thin Saloon connector for the Nova Poshta classic API 2.0 (https://api.novaposhta.ua/v2.0/json/).

Usage

use Dots\NovaPoshta\Client\NovaPoshtaConnectorBuilder;
use Dots\NovaPoshta\Client\Requests\Address\DTO\SearchSettlementsDTO;

$connector = app(NovaPoshtaConnectorBuilder::class)->build($merchantApiKey);

$settlements = $connector->searchSettlements(SearchSettlementsDTO::fromArray([
    'cityName' => 'київ',
]));
  • The API key belongs to the sender (merchant) counterparty, so the connector is built per key. Directory methods (searchSettlements, getWarehouses, searchSettlementStreets, getWarehouseTypes, getDocumentPrice, getDocumentDeliveryDate) also work with build(null) and return public data.
  • Nova Poshta answers every call with HTTP 200. A response with "success": false throws Dots\NovaPoshta\Client\Exceptions\NovaPoshtaApiException with getErrorCodes(), getErrors(), getWarnings(). Codes live in Client\Entities\NovaPoshtaErrorCode.
  • getStatusDocuments() accepts at most 100 documents (GetStatusDocumentsRequest::MAX_DOCUMENTS_PER_REQUEST).
  • The API has no sandbox. deleteInternetDocuments() removes a waybill while it has not been handed over.

Configuration

config/nova-poshta-api-sdk.php:

Key Env Default
base_url NOVA_POSHTA_API_BASE_URL https://api.novaposhta.ua/v2.0/json/
timeout_seconds NOVA_POSHTA_API_TIMEOUT_SECONDS 15

Testing in consumers

Dots\NovaPoshta\Mock\NovaPoshtaResponseMocker adds responses to the global Saloon MockClient (several requests can be mocked in one test). Call MockClient::destroyGlobal() in tearDown().

NovaPoshtaResponseMocker::mockSaveInternetDocument(['IntDocNumber' => '20450123456789']);
NovaPoshtaResponseMocker::mockError(SaveInternetDocumentRequest::class, ['20000900746'], ['Phone is invalid']);

Development

composer install
composer init-pre-commit
vendor/bin/phpunit
vendor/bin/phpstan analyse --memory-limit=2G