# Search & Autocomplete

Ermöglicht eine schrittweise Suche nach einzelnen Elementen (z. B. Name, Strasse) mit der Möglichkeit, die Suchergebnisse sukzessive zu verfeinern.

## Authentifizierung mit API-Key

&#x20;Für den Zugriff auf die API wird ein API-Key benötigt.

{% stepper %}
{% step %}

### API-Key erhalten

Der API-Key wird nach erfolgreichem [Onboarding](https://www.multisource.ch/autocomplete-start) von uns bereitgestellt.
{% endstep %}

{% step %}

### API-Key im Request verwenden

Der API-Key muss bei jedem Request im Header übermittelt werden.

Beispiel:&#x20;

{% code overflow="wrap" %}

```http
curl 'https://api.multisource.ch/v2/Search/AutoComplete?source=kbb&value=swisscom%20directories' \
  --header 'Auth-Key: <API-KEY>'
```

{% endcode %}
{% endstep %}
{% endstepper %}

## Fulltext

Dieser Endpoint ist für umfassende Suchanfragen ausgelegt, bei denen mehrere Begriffe oder ein Volltextdurchlauf erforderlich sind.

1. `type`: Suchmodus
   1. `Exact`: Suche nach einem exakten Einzelwort.
   2. `Like`: Linksbündige Suche, die ab dem Beginn eines Einzelwortes erfolgt und Teilwörter im gesamten Wort berücksichtigt.
   3. `Phonetic`: Suche mit phonetischem Abgleich, um ähnliche Begriffe zu finden.
2. `source`: Datenquelle, in der gesucht wird. Verfügbare Optionen:
   1. `etc` - search.ch Privateinträge
   2. `etb` - search.ch Firmeneinträge
3. `resultThreshold`: Mindestanzahl an Ergebnissen, die angezeigt werden sollen.
4. `resultMaximum`: Maximale Anzahl an Ergebnissen, die zurückgegeben werden.
5. `includeCount`: Gibt an, ob die Gesamtanzahl der Treffer in der Antwort enthalten sein soll (`true`/`false`).
6. `includeData`: Gibt an, ob Detailinformationen zu den Treffern ausgegeben werden sollen (`true`/`false`).
7. `search`: Suchbegriff oder Suchphrase.

## POST /Search/Fulltext

>

```json
{"openapi":"3.0.1","info":{"title":"multisource•api ","version":"v2"},"tags":[{"name":"Search"}],"servers":[{"url":"https://api.multisource.ch/v2","description":"Production - v2"},{"url":"https://api.multisource.ch","description":"Production"},{"url":"https://apitep.multisource.ch","description":"Pre-Production Testing"}],"security":[{"auth-key":[]}],"components":{"securitySchemes":{"auth-key":{"type":"apiKey","description":"API Key required for authorized endpoints","name":"auth-key","in":"header"}},"schemas":{"InputSearchOfstring":{"type":"object","properties":{"type":{"$ref":"#/components/schemas/SearchType"},"likeType":{"$ref":"#/components/schemas/LikeType"},"source":{"type":"string"},"resultThreshold":{"type":"integer","format":"int32"},"resultMaximum":{"type":"integer","format":"int32"},"includeCount":{"type":"boolean"},"includeData":{"type":"boolean"},"termOperation":{"$ref":"#/components/schemas/OperationType"},"search":{"type":"string"}}},"SearchType":{"enum":["0 = Exact","1 = Like","2 = Phonetic","3 = PhoneticLike"],"type":"integer"},"LikeType":{"enum":["0 = StartsWith","1 = EndsWith","2 = Contains","3 = StartOrEndWith"],"type":"integer"},"OperationType":{"enum":["0 = And","1 = Or"],"type":"integer"},"SearchOutputOfListOfOutputDataSearch":{"type":"object","properties":{"hitCount":{"type":"integer","format":"int32"},"resultCount":{"type":"integer","format":"int32"},"data":{"type":"array","items":{"$ref":"#/components/schemas/OutputDataSearch"}}}},"OutputDataSearch":{"type":"object","properties":{"dwhId":{"type":"string","nullable":true},"companyname":{"type":"string","nullable":true},"firstname":{"type":"string","nullable":true},"name":{"type":"string","nullable":true},"street":{"type":"string","nullable":true},"houseNumber":{"type":"string","nullable":true},"zip":{"type":"string","nullable":true},"location":{"type":"string","nullable":true},"category":{"type":"object","additionalProperties":{"type":"string"},"nullable":true},"email":{"type":"string"},"url":{"type":"string"},"phoneNumbers":{"type":"array","items":{"type":"string"},"nullable":true},"mobileNumbers":{"type":"array","items":{"type":"string"},"nullable":true}}}}},"paths":{"/Search/Fulltext":{"post":{"tags":["Search"],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InputSearchOfstring"}},"text/json":{"schema":{"$ref":"#/components/schemas/InputSearchOfstring"}},"application/*+json":{"schema":{"$ref":"#/components/schemas/InputSearchOfstring"}}},"required":true},"responses":{"200":{"description":"OK","content":{"text/plain":{"schema":{"$ref":"#/components/schemas/SearchOutputOfListOfOutputDataSearch"}},"application/json":{"schema":{"$ref":"#/components/schemas/SearchOutputOfListOfOutputDataSearch"}},"text/json":{"schema":{"$ref":"#/components/schemas/SearchOutputOfListOfOutputDataSearch"}}}}}}}}}
```

### Response Felder

#### Root-Level Felder

<table><thead><tr><th width="145">Feld</th><th width="88">Typ</th><th width="290">Beschreibung</th><th>Beispiel</th></tr></thead><tbody><tr><td><code>hitCount</code></td><td>integer</td><td>Gesamtanzahl der Treffer in der Datenbank für die angefragte Telefonnummer</td><td><code>1</code></td></tr><tr><td><code>resultCount</code></td><td>integer</td><td>Anzahl der tatsächlich zurückgegebenen Einträge im <code>data</code>-Array</td><td><code>1</code></td></tr><tr><td><code>data</code></td><td>array</td><td>Array mit den gefundenen Verzeichniseinträgen</td><td>siehe Eintragsfelder unten</td></tr></tbody></table>

#### Eintrags-Felder

<table><thead><tr><th width="145">Feld</th><th width="88">Typ</th><th width="290">Beschreibung</th><th>Beispiel</th></tr></thead><tbody><tr><td><code>companyname</code></td><td>string</td><td>Firmenname bei Unternehmenseinträgen</td><td><code>Swisscom Directories AG</code></td></tr><tr><td><code>firstname</code></td><td>string</td><td>Vorname bei Privatpersonen</td><td><code>Lara</code></td></tr><tr><td><code>name</code></td><td>string</td><td>Nachname bei Privatpersonen</td><td><code>Graf</code></td></tr><tr><td><code>street</code></td><td>string</td><td>Strassenname</td><td><code>Förrlibuckstrasse</code></td></tr><tr><td><code>houseNumber</code></td><td>string</td><td>Hausnummer</td><td><code>62</code></td></tr><tr><td><code>zip</code></td><td>string</td><td>Postleitzahl (PLZ)</td><td><code>8005</code></td></tr><tr><td><code>location</code></td><td>string</td><td>Ortsname</td><td><code>Zürich</code></td></tr><tr><td><code>category</code></td><td>string</td><td><p>Kategorie / Branche</p><p>(mehrsprachig: DE, FR, IT, EN)</p></td><td><p><code>"de": "Pizzakurier",</code></p><p><code>"en": "Pizza delivery",</code></p><p><code>"it": "Pizza consegne a domicilio",</code></p><p><code>"fr": Pizza livraison à domicile"</code></p></td></tr><tr><td><code>email</code></td><td>string</td><td>E-Mail</td><td><code>info@abc.com</code></td></tr><tr><td><code>url</code></td><td>string</td><td>Website</td><td><code>www.multisource.ch</code></td></tr><tr><td><code>phoneNumbers</code></td><td>array</td><td>Array mit einer oder mehreren Festnetznummern</td><td><p><code>[</code></p><p><code>“*0800 123 456",</code></p><p><code>"*058 123 45 67"</code></p><p><code>]</code> </p></td></tr><tr><td><code>mobileNumbers</code></td><td>array</td><td>Array mit einer oder mehreren Mobilnummern</td><td><p><code>[</code></p><p><code>“*079  123 45 67"</code></p><p><code>]</code></p></td></tr></tbody></table>

## Autocomplete

Eignet sich für einfache, feldbasierte Suchen mit Live-Vervollständigung – ideal wenn Nutzer einzelne Elemente wie Name oder Strasse schrittweise eingeben und die Ergebnisse in Echtzeit verfeinern möchten.

## GET /Search/AutoComplete

>

```json
{"openapi":"3.0.1","info":{"title":"multisource•api ","version":"v2"},"tags":[{"name":"Search"}],"servers":[{"url":"https://api.multisource.ch/v2","description":"Production - v2"},{"url":"https://api.multisource.ch","description":"Production"},{"url":"https://apitep.multisource.ch","description":"Pre-Production Testing"}],"security":[{"auth-key":[]}],"components":{"securitySchemes":{"auth-key":{"type":"apiKey","description":"API Key required for authorized endpoints","name":"auth-key","in":"header"}},"schemas":{"SearchType2":{"type":"integer","default":1},"SearchOutputOfListOfOutputAddress":{"type":"object","properties":{"hitCount":{"type":"integer","format":"int32"},"resultCount":{"type":"integer","format":"int32"},"data":{"type":"array","items":{"$ref":"#/components/schemas/OutputAddress"}}}},"OutputAddress":{"type":"object","properties":{"companyname":{"type":"string","nullable":true},"firstname":{"type":"string","nullable":true},"name":{"type":"string","nullable":true},"street":{"type":"string","nullable":true},"houseNumber":{"type":"string","nullable":true},"zip":{"type":"string","nullable":true},"location":{"type":"string","nullable":true}}}}},"paths":{"/Search/AutoComplete":{"get":{"tags":["Search"],"parameters":[{"name":"source","in":"query","schema":{"type":"string"}},{"name":"value","in":"query","schema":{"type":"string"}},{"name":"type","in":"query","schema":{"$ref":"#/components/schemas/SearchType2"}}],"responses":{"200":{"description":"OK","content":{"text/plain":{"schema":{"$ref":"#/components/schemas/SearchOutputOfListOfOutputAddress"}},"application/json":{"schema":{"$ref":"#/components/schemas/SearchOutputOfListOfOutputAddress"}},"text/json":{"schema":{"$ref":"#/components/schemas/SearchOutputOfListOfOutputAddress"}}}}}}}}}
```
