Skip to content

About

The Official Java SDK for Alpaca API

Resources

Code of conduct

Contributing

Security policy

Stars

4 stars

Watchers

0 watching

Forks

Latest commit

 

History

168 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

alpaca-java

Build Maven Central Java 17+ License GitHub Issues Forum Slack

Java client for Alpaca Markets APIs.

REST clients are generated at build time from Alpaca OpenAPI specs. WebSocket clients and the Trading, Broker, and Market Data corporate-actions SSE clients are handwritten and committed in src/main/java/markets/alpaca/client/.

Requirements

  • Java 17 or newer
  • Maven or Gradle for your application project

Installation

The library artifact coordinates are:

markets.alpaca:alpaca-java:VERSION

Gradle

repositories {
    mavenCentral()
}

dependencies {
    implementation("markets.alpaca:alpaca-java:VERSION")
}

Maven

<dependency>
  <groupId>markets.alpaca</groupId>
  <artifactId>alpaca-java</artifactId>
  <version>VERSION</version>
</dependency>

Quick start

Set Trading API credentials in your environment:

export APCA_TRADING_KEY_ID=PK...
export APCA_TRADING_SECRET_KEY=...

Then create a paper-trading client:

import markets.alpaca.client.AlpacaClient;
import markets.alpaca.client.AlpacaCredentials;
import markets.alpaca.client.TradingApiEnvironment;

var credentials = AlpacaCredentials.fromTradingApiEnvironmentVariables();
var client = AlpacaClient.builder(credentials)
    .tradingEnvironment(TradingApiEnvironment.PAPER)
    .build();

Use AlpacaClient for common Trading and Market Data workflows. Use AlpacaClientFactory when you need a specific generated REST client, WebSocket stream, or Trading, Market Data, or Broker SSE client.

Documentation

Build from source

Normal builds use the committed OpenAPI pins under specs/ with no live fetch. Generated REST sources are committed under src/main/java/markets/alpaca/client/openapi/. See GENERATION.md.

./gradlew build                  # generate, compile, and test
./gradlew generateApis           # generate clients for IDE setup
./gradlew check                  # full local verification
./gradlew integrationTest        # live tests; skips when credentials are absent

For the complete task list and local spec configuration, see AGENTS.md. For integration-test credentials see TESTING.md, and for release procedures see RELEASING.md.

Snapshots

Every successful current push to main publishes the current -SNAPSHOT version to Central Snapshots. Scope the snapshot repository to this module:

repositories {
    mavenCentral()
    maven {
        url = uri("https://central.sonatype.com/repository/maven-snapshots/")
        mavenContent { snapshotsOnly() }
        content { includeModule("markets.alpaca", "alpaca-java") }
    }
}

dependencies {
    implementation("markets.alpaca:alpaca-java:0.2.0-SNAPSHOT")
}

For release consumption, use Maven Central as shown in the Getting Started guide.

Support

  • Library / SDK issues: Bugs, feature requests, or questions specific to this SDK → GitHub Issues.
  • Security vulnerabilities: Do not report them publicly. Follow the private reporting process in our Security Policy.
  • Alpaca API bugs: Bugs in the Alpaca API itself, its OpenAPI specs, or its documentation → alpacahq/alpaca-api.
  • Community: API feature requests, general questions, and dashboard bugs → Alpaca Community Forum or Slack.
  • Account help: Questions about your account, funding, or orders → Support request.
  • Outages: Service status and incident updates → Status page.

Contributing

Read the contributing guide for the pull-request workflow, Code of Conduct, security reporting, and contribution policy. Before changing the SDK, also read AGENTS.md for generated-code boundaries, local OpenAPI spec configuration, testing, and publishing safeguards.

About

The Official Java SDK for Alpaca API

Resources

Code of conduct

Contributing

Security policy

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages