[この記事は Aditya Tendulkar, Product Manager, Google My Business による Geo Developers Blog の記事 "Introducing the Google My Business API" を元に翻訳・加筆したものです。詳しくは元記事をご覧ください。]

米国時間 12 月 15 日、Google は Google My Business API(英語)をリリースしました。Google My Business は、Google の検索ユーザーと世界中の企業とをつなぐ上で有効な手段です。この API により、大企業やサードパーティが Google My Business プラットフォームに統合することが容易になり、より簡単な方法で最新情報を Google 検索および Google マップに公開できるようになります。例えば、クリスマスや年末年始といった特別な期間の営業時間を設定し、その設定内容をすべての営業拠点・店舗に反映させることが容易にできます。

Google My Business API では次のことが可能になります。

  • 店舗名、住所、電話番号、カテゴリー、営業時間などさまざまな情報を設定しながらロケーションを作成 
  • 特別営業時間(祝祭日や特別なイベントなど営業時間が普段と異なる場合の設定)を管理 
  • ビジネス ロケーションに閉業・閉店のマークを設定 
  • 営業用の写真を管理 
  • ロケーションおよびビジネスのアカウントにてマネージャーを一覧表示、招待、削除 
  • ロケーションの更新・重複・一時停止状況を確認 
  • ロケーションを名前、カテゴリー、ラベルで検索/フィルタリング 
  • 地点と半径、または Place ID を指定してそのビジネスのサービス提供エリアを設定 
  • 新しいロケーションを作成して特別営業時間を設定する 

Java コードのサンプルを紹介します。

public static Location createLocation(String accountName) throws Exception {
  Location location = new Location();

  // Street address
  Address address = new Address();
  List addressLines = Arrays.asList("740 Valencia Street");
  address.setAddressLines(addressLines);
  address.setLocality("San Francisco");
  address.setAdministrativeArea("CA");
  address.setCountry("US");
  address.setPostalCode("94110");
  location.setAddress(address);

  // Business hours
  BusinessHours businessHours = new BusinessHours();
  List periods = new ArrayList<>();
  List days = Arrays.asList("Monday", "Tuesday", "Wednesday", "Thursday", "Friday");
  for (String day : days) {
    TimePeriod period = new TimePeriod();
    period.setOpenDay(day);
    period.setOpenTime("11:00");
    period.setCloseTime("20:00");
    period.setCloseDay(day);
    periods.add(period);
  }
  businessHours.setPeriods(periods);
  location.setBusinessHours(businessHours);

  // Special hours
    Date christmasEve = new Date().setYear(2015).setMonth(12).setDay(24);
    Date christmasDay = new Date().setYear(2015).setMonth(12).setDay(25);
    List periods = new ArrayList<>();
    periods.add(new SpecialHourPeriod()
        .setStartDate(christmasEve)
        .setOpenTime("11:00")
        .setCloseTime("20:00")
        .setEndDate(christmasEve));
    periods.add(new SpecialHourPeriod()
        .setStartDate(christmasDay)
        .setIsClosed(true));
   SpecialHours specialHours = new SpecialHours()
        .setSpecialHourPeriods(periods);

  location.setSpecialHours(specialHours);

  location.setLocationName("Dandelion Chocolate");
  location.setStoreCode("DC1");
  location.setPrimaryPhone("415 349-0942");
  location.setPrimaryCategory(new Category().setCategoryId("gcid:chocolate_shop"));
  location.setWebsiteUrl("https://www.dandelionchocolate.com/");

  // Create Location
  CreateLocationRequest createLocationRequest = new CreateLocationRequest();
  // RequestId is a unique id for each location created
  createLocationRequest.setRequestId(“1a84939c-ab7d-4581-8930-ee35af6fefac”);
  createLocationRequest.setLocation(location);
  createLocationRequest.setLanguageCode("en-US");
  Mybusiness.Accounts.Locations.Create createLocation =
      mybusiness.accounts().locations().create(accountName, createLocationRequest);

  Location createdLocation = createLocation.execute();

  System.out.printf("Created Location:\n%s", createdLocation.toPrettyString());
 
  return createdLocation;
}
以上の特別営業時間が Google My Business に(英語)設定されると、次の図のように、ホリデーシーズンの営業時間に表示が切り替わります。(英語)。



Google My Business API の詳細およびアクセスの申請方法については、こちらのデベロッパー向けのページ(英語)をご覧ください。

ご質問やご意見などがありましたら、Google My Business API フォーラムにて API チームにご連絡ください。

Posted by 丸山 智康 (Tomoyasu Maruyama) - Google Maps Solution Architect, Google Maps API for Work