nova-poshta-api-sdk-laravel maintained by dotsplatform
Description
Laravel package for the Nova Poshta classic API 2.0 - https://developers.novaposhta.ua/
Author
Last update
2026/11/27 21:23
(dev-master)
License
Downloads
1
Nova Poshta API SDK for Laravel
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 withbuild(null)and return public data. - Nova Poshta answers every call with HTTP 200. A response with
"success": falsethrowsDots\NovaPoshta\Client\Exceptions\NovaPoshtaApiExceptionwithgetErrorCodes(),getErrors(),getWarnings(). Codes live inClient\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