@alpha-arcade/sdk 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -37,7 +37,7 @@ const client = new AlphaClient({
37
37
  });
38
38
 
39
39
  // 4. Fetch live markets (reads directly from chain)
40
- const markets = await client.getMarkets();
40
+ const markets = await client.getLiveMarkets();
41
41
  console.log(`Found ${markets.length} live markets`);
42
42
 
43
43
  // 5. Place a limit buy order on the first market
@@ -71,7 +71,7 @@ new AlphaClient(config: AlphaClientConfig)
71
71
  | `activeAddress` | `string` | Yes | Your Algorand address |
72
72
  | `matcherAppId` | `number` | Yes | Matcher contract app ID (mainnet: `3078581851`) |
73
73
  | `usdcAssetId` | `number` | Yes | USDC ASA ID (mainnet: `31566704`) |
74
- | `apiKey` | `string` | No | Alpha partners API key. If provided, `getMarkets()` uses the API for richer data (images, categories, volume). If omitted, markets are discovered on-chain. |
74
+ | `apiKey` | `string` | No | Alpha partners API key. If provided, `getLiveMarkets()` uses the API for richer data (images, categories, volume). If omitted, markets are discovered on-chain. |
75
75
  | `apiBaseUrl` | `string` | No | API base URL (default: `https://partners.alphaarcade.com/api`) |
76
76
  | `marketCreatorAddress` | `string` | No | Market creator address for on-chain discovery (defaults to Alpha Arcade mainnet) |
77
77
 
@@ -228,12 +228,12 @@ for (const order of orders) {
228
228
 
229
229
  Markets can be loaded **on-chain** (default, no API key) or via the **REST API** (richer data, requires API key).
230
230
 
231
- #### `getMarkets()` / `getMarket(marketId)`
231
+ #### `getLiveMarkets()` / `getMarket(marketId)`
232
232
 
233
233
  Smart defaults — uses the API if `apiKey` is set, otherwise reads from chain.
234
234
 
235
235
  ```typescript
236
- const markets = await client.getMarkets();
236
+ const markets = await client.getLiveMarkets();
237
237
  for (const m of markets) {
238
238
  console.log(`${m.title} — App ID: ${m.marketAppId}, source: ${m.source}`);
239
239
  }
@@ -250,12 +250,12 @@ const markets = await client.getMarketsOnChain();
250
250
  const market = await client.getMarketOnChain(3012345678);
251
251
  ```
252
252
 
253
- #### `getMarketsFromApi()` / `getMarketFromApi(marketId)`
253
+ #### `getLiveMarketsFromApi()` / `getMarketFromApi(marketId)`
254
254
 
255
255
  Always uses the REST API. Requires `apiKey`. Returns richer data: images, categories, volume, probabilities.
256
256
 
257
257
  ```typescript
258
- const markets = await client.getMarketsFromApi();
258
+ const markets = await client.getLiveMarketsFromApi();
259
259
  const market = await client.getMarketFromApi('uuid-here');
260
260
  ```
261
261
 
@@ -312,7 +312,7 @@ const setup = () => {
312
312
 
313
313
  const run = async () => {
314
314
  const client = setup();
315
- const markets = await client.getMarkets(); // Loads from chain, no API key needed
315
+ const markets = await client.getLiveMarkets(); // Loads from chain, no API key needed
316
316
 
317
317
  for (const market of markets) {
318
318
  const book = await client.getOrderbook(market.marketAppId);
package/dist/index.cjs CHANGED
@@ -2080,7 +2080,7 @@ var getMarketOnChain = async (config, marketAppId) => {
2080
2080
  return null;
2081
2081
  }
2082
2082
  };
2083
- var getMarketsFromApi = async (config) => {
2083
+ var getLiveMarketsFromApi = async (config) => {
2084
2084
  if (!config.apiKey) {
2085
2085
  throw new Error("apiKey is required for API-based market fetching. Use getMarketsOnChain() instead, or pass an apiKey.");
2086
2086
  }
@@ -2093,7 +2093,7 @@ var getMarketsFromApi = async (config) => {
2093
2093
  if (lastEvaluatedKey) {
2094
2094
  params.set("lastEvaluatedKey", lastEvaluatedKey);
2095
2095
  }
2096
- const url = `${baseUrl}/get-live-markets?${params.toString()}`;
2096
+ const url = `${baseUrl}/get-live-markets-cached?${params.toString()}`;
2097
2097
  const response = await fetch(url, { headers: { "x-api-key": config.apiKey } });
2098
2098
  if (!response.ok) {
2099
2099
  throw new Error(`Alpha API error: ${response.status} ${response.statusText}`);
@@ -2136,9 +2136,9 @@ var getMarketFromApi = async (config, marketId) => {
2136
2136
  }
2137
2137
  return market;
2138
2138
  };
2139
- var getMarkets = async (config) => {
2139
+ var getLiveMarkets = async (config) => {
2140
2140
  if (config.apiKey) {
2141
- return getMarketsFromApi(config);
2141
+ return getLiveMarketsFromApi(config);
2142
2142
  }
2143
2143
  return getMarketsOnChain(config);
2144
2144
  };
@@ -2304,8 +2304,8 @@ var AlphaClient = class {
2304
2304
  *
2305
2305
  * @returns Array of live markets
2306
2306
  */
2307
- async getMarkets() {
2308
- return getMarkets(this.config);
2307
+ async getLiveMarkets() {
2308
+ return getLiveMarkets(this.config);
2309
2309
  }
2310
2310
  /**
2311
2311
  * Fetches a single market by its ID.
@@ -2347,8 +2347,8 @@ var AlphaClient = class {
2347
2347
  *
2348
2348
  * @returns Array of live markets from the API
2349
2349
  */
2350
- async getMarketsFromApi() {
2351
- return getMarketsFromApi(this.config);
2350
+ async getLiveMarketsFromApi() {
2351
+ return getLiveMarketsFromApi(this.config);
2352
2352
  }
2353
2353
  /**
2354
2354
  * Fetches a single market by ID from the Alpha REST API (requires API key).
@@ -2369,10 +2369,10 @@ exports.calculateMatchingOrders = calculateMatchingOrders;
2369
2369
  exports.checkAssetOptIn = checkAssetOptIn;
2370
2370
  exports.decodeGlobalState = decodeGlobalState;
2371
2371
  exports.getEscrowGlobalState = getEscrowGlobalState;
2372
+ exports.getLiveMarketsFromApi = getLiveMarketsFromApi;
2372
2373
  exports.getMarketFromApi = getMarketFromApi;
2373
2374
  exports.getMarketGlobalState = getMarketGlobalState;
2374
2375
  exports.getMarketOnChain = getMarketOnChain;
2375
- exports.getMarketsFromApi = getMarketsFromApi;
2376
2376
  exports.getMarketsOnChain = getMarketsOnChain;
2377
2377
  //# sourceMappingURL=index.cjs.map
2378
2378
  //# sourceMappingURL=index.cjs.map