Skip to content

Commit 281ba24

Browse files
MarketDataAppgithub-actions[bot]
authored andcommitted
docs: sync from documentation@55d35fe34473617fb1009ba844cffec94a57f0bc
1 parent e927b95 commit 281ba24

25 files changed

Lines changed: 1928 additions & 0 deletions

docs/.sync-manifest.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Auto-generated by MarketDataApp/documentation/scripts/export-sdk-docs.js.
2+
# These files are owned by the docs sync workflow — do not edit them by hand.
3+
# Editing this manifest will not break anything; the workflow rebuilds it each run.
4+
.sync-manifest.txt
5+
README.md
6+
authentication.md
7+
client.md
8+
funds/README.md
9+
funds/candles.md
10+
installation.md
11+
markets/README.md
12+
markets/status.md
13+
options/README.md
14+
options/chain.md
15+
options/expirations.md
16+
options/lookup.md
17+
options/quotes.md
18+
settings.md
19+
stocks/README.md
20+
stocks/candles.md
21+
stocks/earnings.md
22+
stocks/news.md
23+
stocks/prices.md
24+
stocks/quotes.md
25+
utilities/README.md
26+
utilities/headers.md
27+
utilities/status.md
28+
utilities/user.md

docs/README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Java SDK
2+
3+
Welcome to the Market Data Java SDK documentation. This SDK lets you integrate Market Data services into any JVM application. It ships typed, records-based responses, sync **and** async (`CompletableFuture`) variants for every endpoint, automatic retries and rate-limit tracking, and a sealed exception hierarchy you can branch on exhaustively.
4+
5+
The SDK is written in Java (JDK 17+) with no Kotlin runtime dependency, but it is designed to be **idiomatic from Kotlin too**: nullability is annotated (no platform types), the client is `AutoCloseable` (so `use {}` works), and async methods return `CompletableFuture`, which Kotlin interops with directly.
6+
7+
## Quick Start
8+
9+
### Java
10+
11+
```java
12+
import com.marketdata.sdk.MarketDataClient;
13+
import com.marketdata.sdk.stocks.StockQuoteRequest;
14+
15+
// The no-arg constructor reads MARKETDATA_TOKEN from the environment (or a .env file)
16+
// and validates it on startup. The client is AutoCloseable.
17+
try (MarketDataClient client = new MarketDataClient()) {
18+
19+
// A single quote — quote(...) returns a list; a single symbol is row 0.
20+
var quote = client.stocks().quote(StockQuoteRequest.of("AAPL")).values().get(0);
21+
System.out.println(quote.symbol() + " last=" + quote.last());
22+
}
23+
```
24+
25+
### Kotlin
26+
27+
```kotlin
28+
import com.marketdata.sdk.MarketDataClient
29+
import com.marketdata.sdk.stocks.StockQuoteRequest
30+
31+
// `use {}` closes the client when the block ends — the Kotlin equivalent of try-with-resources.
32+
MarketDataClient().use { client ->
33+
val quote = client.stocks().quote(StockQuoteRequest.of("AAPL")).values()[0]
34+
println("${quote.symbol()} last=${quote.last()}")
35+
}
36+
```
37+
38+
## Open Source
39+
40+
The SDK is open source and available on GitHub. Feel free to contribute to the project, report bugs, or request new features.
41+
42+
- [Java SDK on GitHub](https://github.com/MarketDataApp/sdk-java/)
43+
44+
## Documentation
45+
46+
The best source for documentation on the SDK is right here. This documentation is the most up-to-date and accurate source of information on the SDK.
47+
48+
## Using the SDK
49+
50+
This SDK is designed to help you get up and running with Market Data's APIs as quickly as possible, providing all the tools you need to access real-time stock and options prices, historical data, and much more.
51+
52+
### Getting Started
53+
54+
1. [Install the SDK](./installation.md) into a Gradle or Maven project.
55+
2. Set up your [authentication token](./authentication.md) to access the API.
56+
3. Learn about the [client](./client.md) and how to make your first API requests.
57+
4. Configure [Settings](./settings.md) to customize output format, date format, and other universal parameters.
58+
5. Explore the available endpoints for [stocks](./stocks/README.md), [options](./options/README.md), [funds](./funds/README.md), [markets](./markets/README.md), and [utilities](./utilities/README.md).
59+
60+
### Support
61+
62+
- If you have any questions or need further assistance, please don't hesitate to open a ticket at our [helpdesk](https://www.marketdata.app/dashboard/).
63+
- If you find a bug you may also [open an issue in our GitHub repository](https://github.com/MarketDataApp/sdk-java/issues). Please only open issues if you find a bug. Use our helpdesk for general questions or implementation assistance.

docs/authentication.md

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# Authentication
2+
3+
The Market Data API uses a **Bearer Token** for authentication. The token is required for almost every request. Your token should have been e-mailed to you when you first signed up for an account. If you do not have a token or have lost your sign-up email, request a new token from the [Market Data Dashboard](https://www.marketdata.app/dashboard/).
4+
5+
There are three ways to set your token when using the Java SDK:
6+
7+
1. Set it from an environment variable _(recommended for production)_
8+
2. Load it from a `.env` file _(recommended for local development)_
9+
3. Pass it directly when creating the [client](./client.md)
10+
11+
On startup, the SDK looks for the `MARKETDATA_TOKEN` environment variable. If found, it uses that token for all requests. The SDK also loads a `.env` file automatically from the working directory if one is present.
12+
13+
> [!TIP]
14+
> When your code is running in a production environment, we recommend using an environment variable to ensure your token is not stored with your code. This is the most secure way to set your token.
15+
16+
## How To Set Up The Environment Variable
17+
18+
### Set The Environment Variable In The Console
19+
20+
### Mac / Linux
21+
22+
This command sets the environment variable for the current session only. If you open a new terminal or restart your computer, it will not persist.
23+
24+
```bash
25+
export MARKETDATA_TOKEN="your_api_token"
26+
```
27+
28+
#### Make The Variable Persistent
29+
30+
Add the `export` line to your shell's profile script (`~/.zshrc`, `~/.bashrc`, `~/.bash_profile`, etc.), then restart your terminal or run `source ~/.zshrc` (adjusting for your shell).
31+
32+
### Windows
33+
34+
`setx` sets the variable permanently, but it is not available in the current Command Prompt session — open a new one after running it.
35+
36+
```bash
37+
setx MARKETDATA_TOKEN "your_api_token"
38+
```
39+
40+
### Using a .env File
41+
42+
The SDK automatically loads a `.env` file from your working directory at startup. Create a file named `.env` in your project root:
43+
44+
```env title=".env"
45+
MARKETDATA_TOKEN=your_api_token
46+
```
47+
48+
> [!WARNING]
49+
> Add `.env` to your `.gitignore` so the token is not committed to source control.
50+
51+
### Make A Test Request
52+
53+
Verify your authentication is working by making a test request against `SPY` (or any symbol that requires authentication). Do **not** use `AAPL` to test authentication — `AAPL` is a free test symbol and returns data even when you are not authenticated.
54+
55+
### Java
56+
57+
```java
58+
import com.marketdata.sdk.MarketDataClient;
59+
import com.marketdata.sdk.stocks.StockQuoteRequest;
60+
import com.marketdata.sdk.exception.AuthenticationError;
61+
62+
// No need to pass a token here — the SDK reads MARKETDATA_TOKEN automatically.
63+
try (MarketDataClient client = new MarketDataClient()) {
64+
var quote = client.stocks().quote(StockQuoteRequest.of("SPY")).values().get(0);
65+
System.out.println(quote.symbol() + " last=" + quote.last());
66+
} catch (AuthenticationError e) {
67+
System.out.println("Authentication failed: " + e.getMessage());
68+
}
69+
```
70+
71+
### Kotlin
72+
73+
```kotlin
74+
import com.marketdata.sdk.MarketDataClient
75+
import com.marketdata.sdk.stocks.StockQuoteRequest
76+
import com.marketdata.sdk.exception.AuthenticationError
77+
78+
MarketDataClient().use { client ->
79+
try {
80+
val quote = client.stocks().quote(StockQuoteRequest.of("SPY")).values()[0]
81+
println("${quote.symbol()} last=${quote.last()}")
82+
} catch (e: AuthenticationError) {
83+
println("Authentication failed: ${e.message}")
84+
}
85+
}
86+
```
87+
88+
## Passing the Token Directly
89+
90+
If you prefer to pass the token explicitly (not recommended for production code), use the four-argument constructor `(apiKey, baseUrl, apiVersion, validateOnStartup)`. Pass `null` for any slot you want resolved from the cascade or left at its default.
91+
92+
### Java
93+
94+
```java
95+
import com.marketdata.sdk.MarketDataClient;
96+
97+
try (MarketDataClient client =
98+
new MarketDataClient("your_token_here", null, null, true)) {
99+
// ... make requests
100+
}
101+
```
102+
103+
### Kotlin
104+
105+
```kotlin
106+
import com.marketdata.sdk.MarketDataClient
107+
108+
MarketDataClient("your_token_here", null, null, true).use { client ->
109+
// ... make requests
110+
}
111+
```
112+
113+
> [!NOTE]
114+
> **Demo mode**
115+
>
116+
> If no token is found anywhere in the cascade, the SDK runs in **demo mode** — startup validation is skipped and you can call the free, public endpoints (such as `AAPL` quotes and `utilities().status()`).
117+
118+
## Next Steps
119+
120+
After successful authentication, read the overview of how the [client](./client.md) works, then configure [Settings](./settings.md) to customize output format, date format, and other universal parameters.

0 commit comments

Comments
 (0)