wowworks/dadata-suggestions

Integration with Dadata suggestions API.

Installs: 53

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 3

pkg:composer/wowworks/dadata-suggestions

v1.0.0 2026-02-03 08:19 UTC

This package is not auto-updated.

Last update: 2026-02-04 07:24:15 UTC


README

Integration with Dadata suggestions API.

License Code Coverage Badge

Installation

This extension is available at packagist.org and can be installed via composer by following command:

composer require glendemon/dadata-suggestions

Configuration

You can customize debug panel behavior with this options:

  • token - private api token [required].
  • url - path to suggestions api [optional].
  • client - GuzzleHttp\Client [optional].

Example:

$service = new \DadataSuggestions\DadataSuggestionsService();
$service->setUrl('https://suggestions.dadata.ru/suggestions/api/4_1/rs/suggest/');
$service->setToken('...');
    public function testSuggestAddressFlat()
    {
        $service = $this->getService();
        $response = $service->suggestAddress('мск балтийская 6к1 5');
        foreach ($response->getSuggestions() as $suggestion) {
            $this->assertEquals('г Москва, ул Балтийская, д 6 к 1, кв 5', $suggestion->getValue());
            $this->assertEquals('г Москва, ул Балтийская, д 6 к 1, кв 5', $suggestion->getUnrestrictedValue());
            $data = $suggestion->getData();
            $this->assertInstanceOf(\DadataSuggestions\Data\Address::class, $data);
            $this->assertEquals('Россия', $data->country);
            $this->assertEquals('Москва', $data->city);
            $this->assertEquals('ул Балтийская', $data->street_with_type);
            $this->assertEquals('6', $data->house);
            $this->assertEquals('1', $data->block);
            $this->assertEquals('5', $data->flat);
        }
    }
    
    /**
     * @return \DadataSuggestions\DadataSuggestionsService
     */
    protected function getService()
    {
        $service = new \DadataSuggestions\DadataSuggestionsService();
        $service->setToken('...');
        return $service;
    }

Links

API documentation