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/.
- Java 17 or newer
- Maven or Gradle for your application project
The library artifact coordinates are:
markets.alpaca:alpaca-java:VERSION
repositories {
mavenCentral()
}
dependencies {
implementation("markets.alpaca:alpaca-java:VERSION")
}<dependency>
<groupId>markets.alpaca</groupId>
<artifactId>alpaca-java</artifactId>
<version>VERSION</version>
</dependency>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.
- Getting started — installation, credentials, and examples
- API reference — classes, methods, and generated REST models
- Migration guides — compatibility and upgrade guidance, including SSE
0.2.0 - Runnable examples — local Trading, Market Data, Broker, and pagination workflows
- LLM usage guide — guidance for coding assistants
- Documentation development — local Docusaurus setup
- Contributing guide — issues, pull requests, and release instructions
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 absentFor 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.
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.
- 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.
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.