Standorte
Standorte über client.locations auflisten, erstellen, aktualisieren, archivieren, suchen und abrufen.
Alle Standortmethoden sind unter client.locations verfügbar. Installieren Sie das SDK und konfigurieren Sie Ihren Schlüssel, bevor Sie diese verwenden; siehe Installation und Schnellstart.
Standort-IDs
Methoden mit dem Parameter location_id akzeptieren entweder eine numerische ID (16808) oder deren base64-kodierte Entsprechung ("TG9jYXRpb246MTY4MDg="). Das SDK kodiert numerische IDs automatisch, sodass beide Formen austauschbar sind:
# These are equivalentclient.locations.retrieve(16808)client.locations.retrieve("TG9jYXRpb246MTY4MDg=")locations.add
Erstellen Sie einen Standort mit einem einzigen Aufruf und übergeben Sie jedes Pflichtfeld als Schlüsselwortargument. Dies ist die empfohlene Vorgehensweise zum Erstellen von Standorten. Das SDK prüft die Anforderungen der API für die Erstellung clientseitig und löst vor jedem Netzwerkaufruf bei einem Verstoß ValidationError aus, sodass eine ungültige Payload sofort mit einer klaren Meldung abgewiesen wird.
client.locations.add( *, name: str, description: str, sub_category_id: int, country_iso: str, city: str | None = None, street: str | None = None, state_iso: str | None = None, postal_code: str | None = None, phone: str | None = None, website: str | None = None, store_id: str | None = None, hide_address: bool | None = None, business_hours: list[dict] | None = None, service_area: dict | None = None, place_action_links: list[dict] | None = None, enabled_site_ids: list[int] | None = None, additional_fields: dict | None = None,) -> APIObjectDie clientseitige Validierung prüft: name hat 2-150 Zeichen, description hat mindestens 200 Zeichen, sub_category_id und country_iso sind vorhanden und city ist vorhanden, sofern nicht hide_address=True gilt.
Der Rückgabewert ist die Payload der Erstellung: .location enthält den neuen Standort. Sie müssen niemals Erfolgsflags prüfen; das SDK löst ValidationError aus, wenn die API die Payload ablehnt.
result = client.locations.add( name="Acme Dental", description=( "Acme Dental is a family-owned dental practice offering general, " "cosmetic, and pediatric dentistry in the heart of New York. Our " "team provides cleanings, fillings, crowns, whitening, and same-day " "emergency care in a modern, comfortable office with weekend hours " "and easy online booking for new and returning patients." ), sub_category_id=1432, country_iso="US", city="New York", street="123 Jump Street", state_iso="NY", postal_code="10013", phone="6443859313", website="https://acmedental.example.com", store_id="NYC-001", place_action_links=[ {"placeActionType": "APPOINTMENT", "uri": "https://acmedental.example.com/book", "isPreferred": True}, ], enabled_site_ids=[1, 24, 87],)print("Created:", result.location.id, result.location.name)locations.list
Listen Sie Standorte mit cursorbasierter Paginierung auf. Gibt ein Objekt vom Typ SyncPage zurück.
client.locations.list( *, first: int | None = None, after: str | None = None, before: str | None = None, last: int | None = None,) -> SyncPage# First page of 25page = client.locations.list(first=25)for loc in page: print(loc.name, loc.city) # Next page manuallyif page.has_more: page2 = page.next_page() # Auto-paginate all locationsfor loc in client.locations.list(first=100).auto_paging_iter(): print(loc.name)locations.retrieve
Rufen Sie einen einzelnen Standort anhand seiner ID ab. Löst NotFoundError aus, wenn die ID nicht existiert.
client.locations.retrieve(location_id: str | int) -> APIObjectloc = client.locations.retrieve(16808)print(loc.name, loc.street, loc.city)locations.list_by_ids
Rufen Sie mehrere Standorte anhand einer Liste von IDs (numerisch oder base64-kodiert) mit einem einzigen Aufruf ab.
client.locations.list_by_ids(location_ids: list[str | int]) -> list[APIObject]locs = client.locations.list_by_ids([16808, 16809, "TG9jYXRpb246MTQwMjQ="])for loc in locs: print(loc.id, loc.name)locations.list_by_store_codes
Rufen Sie Standorte ab, die den angegebenen Filialcodes entsprechen.
client.locations.list_by_store_codes(store_codes: list[str]) -> list[APIObject]locs = client.locations.list_by_store_codes(["SF-001", "NYC-042"])for loc in locs: print(loc.storeId, loc.name)locations.search
Durchsuchen Sie Standorte anhand eines Suchbegriffs in Name, Adresse oder Filial-ID. Gibt ein Objekt vom Typ SyncPage zurück.
client.locations.search( query: str, *, fields: list[str] | None = None, first: int | None = None, after: str | None = None, before: str | None = None, last: int | None = None,) -> SyncPage# Search all fieldspage = client.locations.search("downtown dental", first=10) # Restrict to name onlypage = client.locations.search("Acme Dental", fields=["name"], first=10) for loc in page: print(loc.name, loc.city)locations.create
Erstellen Sie einen Standort aus einem unverarbeiteten Eingabe-Dictionary mit camelCase-Feldnamen. Verwenden Sie vorzugsweise locations.add für Schlüsselwortargumente und clientseitige Validierung; verwenden Sie create, wenn Sie bereits eine camelCase-Payload haben.
client.locations.create(input: dict) -> APIObjectVon der API vorgeschrieben: name, description (mindestens 200 Zeichen), subCategoryId, countryIso und city (für Länder, deren Adressierung eine Stadtangabe vorsieht).
result = client.locations.create({ "name": "Acme Dental Brooklyn", "description": ( "Acme Dental Brooklyn is a family-owned dental practice offering " "general, cosmetic, and pediatric dentistry. Our team provides " "cleanings, fillings, crowns, whitening, and same-day emergency " "care in a modern, comfortable office with weekend hours and easy " "online booking for new and returning patients across Brooklyn." ), "subCategoryId": 1432, "countryIso": "US", "city": "Brooklyn", "street": "88 Court St", "stateIso": "NY", "postalCode": "11201", "phone": "6443859314", "storeId": "NYC-002",})print("Created:", result.location.id)locations.update
Aktualisieren Sie einen Standort. Übergeben Sie id sowie alle zu ändernden Felder (camelCase). Der Wert von id kann numerisch oder base64-kodiert sein; das SDK kodiert ihn automatisch.
client.locations.update(input: dict) -> APIObjectresult = client.locations.update({ "id": 16808, "phone": "6443859399", "street": "125 Jump Street",})print("Updated:", result.location.id)locations.archive
Archivieren Sie einen oder mehrere Standorte.
client.locations.archive(location_ids: list[str | int]) -> APIObjectresult = client.locations.archive([16808, 16809])print(result.to_dict())locations.cancel_archive
Brechen Sie eine geplante Archivierung ab.
client.locations.cancel_archive( location_ids: list[str | int], selection_type: str, changed_by: str,) -> APIObjectclient.locations.cancel_archive( [16808], selection_type="manual", changed_by="admin@example.com",)Siehe auch
- Beiträge: Ankündigungen, Veranstaltungen und Angebote veröffentlichen
- Einträge: Synchronisierungsstatus pro Standort prüfen
- Bewertungen: Bewertungen auflisten und beantworten
- Analysen: Profilanalysen für Google, Bing und Facebook