Choosing the right API

The following guidelines will help you choose the right Nearby API to use for your app.

Nearby Connections

The Nearby Connections API allows apps to easily discover, connect to, and exchange data with nearby devices in real-time, regardless of network connectivity. It uses Bluetooth, Wi-Fi, and other technologies, and is designed to hide the complexity of these technologies so your app can focus on discovering and interacting with nearby devices easily.

You should choose the Nearby Connections API for your app when:

  • You want to discover nearby devices without requiring Internet connectivity and incurring the cost of a network round-trip on each operation.

  • You want to stream content or transmit arbitrary payloads or files between nearby devices.

  • You want to use the latest peer-to-peer technologies such as Wi-Fi Aware when available.

  • You only need to communicate between Android devices.

Nearby Messages

The Nearby Messages API allows apps to publish small messages that other devices can subscribe to and receive when nearby. The messages are transmitted through the cloud. Nearby devices are detected using Bluetooth and near-ultrasound audio.

The Nearby Messages API also allows apps to detect Bluetooth Low Energy beacons nearby and retrieve messages attached to those beacons using the Beacon Platform.

You should choose the Nearby Messages API for your app when:

  • You want to discover nearby devices while connected to the Internet.

  • You want to retrieve small payloads one-way from nearby devices. Nearby Messages is unsuitable for bidirectional communication between devices. If two way communication is required, use Nearby Connections.

  • You want to place approximate distance thresholds on the devices you detect, for example only detect devices that are in the same room.

  • You want to scan for Bluetooth Low Energy Beacons and retrieve beacon attachments registered with the Beacon Platform.

  • You want to communicate between Android and iOS devices.