Enum Class AlpacaStreamEnvironment

java.lang.Object
java.lang.Enum<AlpacaStreamEnvironment>
markets.alpaca.client.ws.AlpacaStreamEnvironment
All Implemented Interfaces:
Serializable, Comparable<AlpacaStreamEnvironment>, Constable

public enum AlpacaStreamEnvironment extends Enum<AlpacaStreamEnvironment>
Selects between the Alpaca production and sandbox WebSocket endpoints.

Which environment should I use?

  • Trading/data credentials (APCA_TRADING_KEY_ID / APCA_TRADING_SECRET_KEY): authenticate against PRODUCTION. Trading API keys are scoped to the live data stream and work for all four stream types.
  • Broker-sandbox credentials: use SANDBOX for stock streams. Crypto and news streams are production-only and do not have a sandbox endpoint.

The trading stream uses its own production/paper distinction via TradingEnvironment.

  • Enum Constant Details

    • PRODUCTION

      public static final AlpacaStreamEnvironment PRODUCTION
      stream.data.alpaca.markets — live market data (all stream types).
    • SANDBOX

      public static final AlpacaStreamEnvironment SANDBOX
      stream.data.sandbox.alpaca.markets — stock streams only.

      Requires broker-sandbox credentials, not paper-trading credentials. Crypto and news streams have no sandbox endpoint; use PRODUCTION for those.

  • Method Details

    • values

      public static AlpacaStreamEnvironment[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static AlpacaStreamEnvironment valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • baseUrl

      public String baseUrl()
      Returns the base WebSocket URL for this environment (no trailing slash).