Skip to main content

Alpaca

Alpaca is a developer-first financial API platform that provides commission-free stock, options, and crypto trading capabilities alongside real-time and historical market data. Designed for algorithmic traders, fintech developers, and financial applications, Alpaca offers a REST API for programmatic order management, portfolio tracking, and market data access across U.S. equities, options contracts, and cryptocurrency assets. The platform supports both paper (simulated) and live trading environments, making it easy to test strategies before deploying them in production.

Alpaca icon

Power end-to-end data operations for your Alpaca API with Nexla. Our bi-directional Alpaca connector is purpose-built for Alpaca, making it simple to ingest data, sync it across systems, and deliver it anywhere — all with no coding required. Nexla turns API-sourced data into ready-to-use, reusable data products and makes it easy to send data to Alpaca or any other destination. With comprehensive monitoring, lineage tracking, and access controls, Nexla keeps your Alpaca workflows fast, secure, and fully governed.

Features

Type: API

SourceDestination

  • Seamless API Integration: Connect to any endpoint as source or destination without coding, with automatic data product creation
  • Visual Composition & Chaining: Build complex integrations using visual templates, chain API calls, and compose workflows with data validation and filtering
  • API Proxy: Expose curated slices of your data securely with a secure and customizable API proxy that validates and transforms data on the fly
  • Request optimization with intelligent batching, retry, and caching to minimize API calls and costs

Prerequisites

Before creating an Alpaca credential in Nexla, you need an active Alpaca account and a set of API keys for the appropriate environment (paper trading or live trading).

Create an Alpaca Account

If you do not already have an Alpaca account, follow these steps to create one:

  1. Navigate to alpaca.markets and click Get Started or Sign Up.

  2. Enter your name, email address, and password, then submit the form.

  3. Check your email inbox for a verification message from Alpaca and click the confirmation link to activate your account.

  4. Log in to your new account and complete any additional identity verification steps required by Alpaca.

Generate API Keys

Alpaca provides separate API keys for its paper trading (simulated) environment and its live trading (production) environment. Generate the keys for the environment you intend to use with Nexla.

  1. Log in to your Alpaca account at app.alpaca.markets.

  2. In the top-left corner of the dashboard, confirm that the correct account type is selected — Paper Trading for a simulated environment or the live account for production.

  3. On the Home tab, locate the API Keys section and click Generate New Keys (or Regenerate if keys already exist).

  4. Copy both the API Key ID and the Secret Key immediately and store them in a secure location. The Secret Key is only displayed once — it cannot be retrieved after you close or navigate away from this screen.

Important

Store your Secret Key securely at the time of generation. Alpaca does not allow you to view the Secret Key again after it has been shown. If the key is lost, you must regenerate a new key pair.

Paper trading keys and live trading keys are distinct credentials associated with different API endpoints. Use paper trading keys when connecting to https://paper-api.alpaca.markets and live trading keys when connecting to https://api.alpaca.markets. Using the wrong key pair for the environment will result in authentication errors.

For complete information about API key management, refer to the Alpaca Authentication documentation.

Authenticate

Credentials required

FieldRequiredSecretDescription
EnvironmentYesNoSelect Paper Trading (testing) or Live Trading environment. Allowed values: Paper Trading (Test) (Paper trading environment for testing); Live Trading (Live trading with real money)
API Key IDYesNoYour Alpaca API Key ID from the dashboard
API Secret KeyYesYesYour Alpaca API Secret Key from the dashboard

Create a credential in Nexla

  1. After selecting the data source/destination type, click the Add Credential tile to open the Add New Credential overlay.

  2. Enter a name for the credential in the Credential Name field and a short, meaningful description in the Credential Description field.

  3. In the Environment field, select Paper Trading (Test) or Live Trading, matching the environment for which your API keys were generated.

    Alpaca uses API key authentication. Each request to the Alpaca API is authenticated by passing your API Key ID and Secret Key as HTTP headers. Nexla handles this header injection automatically once the credential is saved.

  4. Enter your Alpaca API Key ID in the API Key field. This is the alphanumeric identifier generated on the Alpaca dashboard (for example, PKXXXXXXXXXXXXXXXX for paper accounts or AKXXXXXXXXXXXXXXXX for live accounts).

  5. Enter your Alpaca Secret Key in the Secret Key field. This value was displayed once when the key pair was generated. Nexla encrypts this value at rest after the credential is saved.

    Ensure that the API Key ID and Secret Key correspond to the same environment (paper or live). Mixing keys from different environments will result in authentication failures.

  6. Click the Save button at the bottom of the overlay. The newly added credential will now appear in a tile on the Authenticate screen during data source/destination creation.

Use as a data source

To create a new data flow, navigate to the Integrate section, and click the New Data Flow button. Select the Alpaca connector tile, then select the credential that will be used to connect to the Alpaca instance, and click Next; or, create a new Alpaca credential for use in this flow.

Endpoint templates

Nexla provides pre-built templates that can be used to rapidly configure data sources to ingest data from common Alpaca endpoints. Select the endpoint from which this source will fetch data from the Endpoint pulldown menu. Available endpoint templates are listed in the expandable boxes below.

Get Account Information

Retrieve account details including account ID, status, buying power, portfolio value, and account configuration flags.

  • Endpoint: GET https://api.alpaca.markets/v2/account
  • Data path: $

All parameters are optional; omitting filters returns all available records.

List Orders

Retrieve a list of orders with optional status, date range, and symbol filters.

  • Endpoint: GET https://api.alpaca.markets/v2/orders?status={parameter}&after={parameter}&until={parameter}
  • Data path: $[*]
  • Status (Optional): Filter orders by status. Accepted values: 'open', 'closed', 'all'.
  • After Date (Optional): Return orders after this date (ISO 8601 format).
  • Until Date (Optional): Return orders until this date (ISO 8601 format).

All parameters are optional; omitting filters returns all available records.

List Positions

Retrieve all open positions in the account including unrealized profit/loss and market value.

  • Endpoint: GET https://api.alpaca.markets/v2/positions
  • Data path: $[*]

All parameters are optional; omitting filters returns all available records.

List Assets

Retrieve tradable assets with status, exchange, and asset class filters.

  • Endpoint: GET https://api.alpaca.markets/v2/assets?status={parameter}&asset_class={parameter}
  • Data path: $[*]
  • Status (Optional): Filter assets by status. Accepted values: 'active', 'inactive'.
  • Asset Class (Optional): Filter by asset class. Accepted values: 'us_equity', 'crypto'.

All parameters are optional; omitting filters returns all available records.

Get Portfolio History

Retrieve historical portfolio value and profit/loss over a specified time period.

  • Endpoint: GET https://api.alpaca.markets/v2/account/portfolio/history?period={parameter}&timeframe={parameter}
  • Data path: $
  • Period (Optional): The duration of the portfolio history. Accepted values: '1D', '1W', '1M', '3M'.
  • Timeframe (Optional): The resolution of time window. Accepted values: '1Min', '5Min', '15Min', '1H'.

All parameters are optional; omitting filters returns all available records.

List Watchlists

Retrieve all watchlists for the account.

  • Endpoint: GET https://api.alpaca.markets/v2/watchlists
  • Data path: $[*]

All parameters are optional; omitting filters returns all available records.

List Account Activities

Retrieve account activity records including trades, dividends, and other account events.

  • Endpoint: GET https://api.alpaca.markets/v2/account/activities/{parameter}?after={parameter}&until={parameter}
  • Data path: $[*]
  • Activity Type (Optional): Filter by activity type (e.g., FILL, DIV, JNLC).
  • After Date (Optional): Return activities after this date (ISO 8601 format).
  • Until Date (Optional): Return activities until this date (ISO 8601 format).

All parameters are optional; omitting filters returns all available records.

Get Market Clock

Retrieve the current market clock including whether the market is open, next open/close times.

  • Endpoint: GET https://api.alpaca.markets/v2/clock
  • Data path: $

All parameters are optional; omitting filters returns all available records.

Once the selected endpoint template has been configured, click the Test button to the right of the endpoint selection menu to retrieve a sample of the data that will be fetched. Sample data will be displayed in the Endpoint Test Result panel on the right, allowing you to verify that the source is configured correctly before saving.

Manual configuration

Alpaca data sources can also be manually configured to ingest data from any valid Alpaca REST API endpoint, including endpoints not covered by the pre-built templates, chained API calls to fetch data from multiple endpoints, or sources that require custom request parameters. Select the Advanced tab at the top of the configuration screen, and follow the instructions in Connect to Any API to configure the API method (typically GET for Alpaca), endpoint URL, date/time and lookup macros, path to data, metadata, and request headers.

Alpaca uses two separate base URL domains depending on your environment: https://api.alpaca.markets/v2/ for live trading endpoints and https://data.alpaca.markets/v2/ for market data endpoints, with https://paper-api.alpaca.markets/v2/ for all paper trading (simulated) endpoints. Ensure that you use the correct base URL for your environment—using a live trading API key with the paper trading endpoint (or vice versa) will result in authentication errors. Common endpoint examples include https://api.alpaca.markets/v2/account (account details), https://api.alpaca.markets/v2/positions (open positions), https://api.alpaca.markets/v2/orders?status=all (orders filtered by status), and https://data.alpaca.markets/v2/stocks/{symbol}/bars (historical OHLCV bar data for a stock symbol). For complete endpoint reference documentation, visit the Alpaca API documentation.

Alpaca market data endpoints accept start and end query parameters that can be populated with date/time macros; date parameters typically use ISO 8601 format (e.g., 2024-01-01T00:00:00Z), so use the Date Format for Date/Time Macro setting to ensure macros are formatted correctly for the Alpaca API. Market data responses nest the relevant data array under a key such as bars, trades, or quotes—for example, for the historical bars endpoint (/v2/stocks/{symbol}/bars), enter $.bars[*] in the Set Path to Data in Response field to treat each bar as a separate record, and use the Path to Metadata in Response field to attach response-level values such as next_page_token and symbol to each record. You do not need to include the APCA-API-KEY-ID or APCA-API-SECRET-KEY authentication headers in the Request Headers field—these are handled automatically by Nexla based on your saved Alpaca credential.

Once all of the relevant settings have been configured, click the Create button in the upper right corner of the screen to save and create the new Alpaca data source. Nexla will now begin ingesting data from the configured endpoint and will organize any data that it finds into one or more Nexsets.

Use as a destination

Click the + icon on the Nexset that will be sent to the Alpaca destination, and select the Send to Destination option from the menu. Select the Alpaca connector from the list of available destination connectors, then select the credential that will be used to connect to the Alpaca account, and click Next; or, create a new Alpaca credential for use in this flow.

Manual configuration

Alpaca destinations are manually configured to send data to any valid Alpaca REST API endpoint. This is useful for programmatically placing orders, cancelling orders, updating watchlists, or interacting with any other writable Alpaca endpoint. Follow the instructions in Connect to Any API to configure the API method, data format, endpoint URL, request headers, attribute exclusions, record batching, and response webhooks. Common methods for Alpaca write operations include:

  • POST: For creating new resources such as orders (/v2/orders), watchlist entries, or other objects
  • PATCH: For partially updating existing resources such as replacing an open order
  • DELETE: For cancelling orders or removing watchlist entries

For most Alpaca write endpoints, select JSON as the content format, as the Alpaca REST API accepts and returns data in JSON format. Alpaca uses two separate base URL domains depending on your environment—https://api.alpaca.markets/v2/ for live account operations and https://paper-api.alpaca.markets/v2/ for all paper trading (simulated) operations. Common destination endpoint examples include:

  • https://api.alpaca.markets/v2/orders — Submit new stock, options, or crypto orders (POST)
  • https://paper-api.alpaca.markets/v2/orders — Submit orders in the paper trading environment (POST)
  • https://api.alpaca.markets/v2/orders/{order_id} — Replace or cancel an existing order (PATCH or DELETE)

Ensure that the API key in your Alpaca credential corresponds to the correct environment. Live trading keys will not work with the paper trading base URL and vice versa. For complete endpoint reference documentation, see the Alpaca Trading API documentation.

You do not need to include the APCA-API-KEY-ID or APCA-API-SECRET-KEY authentication headers in the Request Headers field. These are injected automatically by Nexla using your saved Alpaca credential.

When submitting orders to the Alpaca API, include only the fields required by the target endpoint. The Alpaca Orders API requires fields such as symbol, qty or notional, side, type, and time_in_force. Use Exclude Attributes to remove any fields in your Nexset that should not be sent to Alpaca. For a complete list of required and optional order fields, refer to the Alpaca Create an Order documentation.

Most Alpaca write endpoints (such as the Orders API) accept a single object per request rather than arrays. For these endpoints, set the Batch Size to 1 to ensure each record is sent as a separate API call. Check the Alpaca API documentation for each endpoint to confirm whether batch submission is supported.

You can also configure Nexla to automatically send the response received from the Alpaca API after each call to a new Nexla webhook data source, which allows you to capture and process order confirmations, error messages, or other response data returned by Alpaca—for example, order IDs, order status, filled quantities, and timestamps returned after each order submission. To enable this option, check the box next to Would you like to process the API response as a Nexla Webhook source?.

Important

When testing against a live trading endpoint, test payloads may result in actual orders being placed in your Alpaca account. Use the paper trading endpoint (https://paper-api.alpaca.markets/v2/orders) for testing to avoid unintended trades in a live account.

Save & activate

Once all endpoint settings have been configured, click the Done button in the upper right corner of the screen to save and create the destination. To send the data to the Alpaca API, open the destination resource menu, and select Activate.

The Nexset data will not be sent to Alpaca until the destination is activated. Destinations can be activated immediately or at a later time, providing full control over data movement.