@axionquant/sdk 1.0.2 → 1.0.4

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/dist/index.d.ts CHANGED
@@ -1,68 +1,87 @@
1
1
  import { ApiResponse } from './models';
2
- export declare class Axion {
3
- private client;
4
- private apiKey?;
5
- constructor(apiKey?: string);
6
- private _request;
7
- searchCredit(query: string): Promise<ApiResponse>;
8
- getCreditRatings(entityId: string): Promise<ApiResponse>;
9
- getEsgData(ticker: string): Promise<ApiResponse>;
10
- getEtfFundData(ticker: string): Promise<ApiResponse>;
11
- getEtfHoldings(ticker: string): Promise<ApiResponse>;
12
- getEtfExposure(ticker: string): Promise<ApiResponse>;
13
- getSupplyChainCustomers(ticker: string): Promise<ApiResponse>;
14
- getSupplyChainPeers(ticker: string): Promise<ApiResponse>;
15
- getSupplyChainSuppliers(ticker: string): Promise<ApiResponse>;
16
- getStockTickers(params?: {
2
+ declare class BaseAPI {
3
+ protected client: Axion;
4
+ constructor(client: Axion);
5
+ protected _request(method: string, path: string, params?: Record<string, any>, data?: Record<string, any>, authRequired?: boolean): Promise<ApiResponse>;
6
+ }
7
+ declare class CreditAPI extends BaseAPI {
8
+ search(query: string): Promise<ApiResponse>;
9
+ ratings(entityId: string): Promise<ApiResponse>;
10
+ }
11
+ declare class ESGAPI extends BaseAPI {
12
+ data(ticker: string): Promise<ApiResponse>;
13
+ }
14
+ declare class ETFAPI extends BaseAPI {
15
+ fund(ticker: string): Promise<ApiResponse>;
16
+ holdings(ticker: string): Promise<ApiResponse>;
17
+ exposure(ticker: string): Promise<ApiResponse>;
18
+ }
19
+ declare class SupplyChainAPI extends BaseAPI {
20
+ customers(ticker: string): Promise<ApiResponse>;
21
+ peers(ticker: string): Promise<ApiResponse>;
22
+ suppliers(ticker: string): Promise<ApiResponse>;
23
+ }
24
+ declare class StocksAPI extends BaseAPI {
25
+ tickers(params?: {
17
26
  country?: string;
18
27
  exchange?: string;
19
28
  }): Promise<ApiResponse>;
20
- getStockTickerBySymbol(ticker: string): Promise<ApiResponse>;
21
- getStockPrices(ticker: string, params?: {
29
+ ticker(ticker: string): Promise<ApiResponse>;
30
+ prices(ticker: string, params?: {
22
31
  from?: string;
23
32
  to?: string;
24
33
  frame?: string;
25
34
  }): Promise<ApiResponse>;
26
- getCryptoTickers(params?: {
35
+ }
36
+ declare class CryptoAPI extends BaseAPI {
37
+ tickers(params?: {
27
38
  type?: string;
28
39
  }): Promise<ApiResponse>;
29
- getCryptoTickerBySymbol(ticker: string): Promise<ApiResponse>;
30
- getCryptoPrices(ticker: string, params?: {
40
+ ticker(ticker: string): Promise<ApiResponse>;
41
+ prices(ticker: string, params?: {
31
42
  from?: string;
32
43
  to?: string;
33
44
  frame?: string;
34
45
  }): Promise<ApiResponse>;
35
- getForexTickers(params?: {
46
+ }
47
+ declare class ForexAPI extends BaseAPI {
48
+ tickers(params?: {
36
49
  country?: string;
37
50
  exchange?: string;
38
51
  }): Promise<ApiResponse>;
39
- getForexTickerBySymbol(ticker: string): Promise<ApiResponse>;
40
- getForexPrices(ticker: string, params?: {
52
+ ticker(ticker: string): Promise<ApiResponse>;
53
+ prices(ticker: string, params?: {
41
54
  from?: string;
42
55
  to?: string;
43
56
  frame?: string;
44
57
  }): Promise<ApiResponse>;
45
- getFuturesTickers(params?: {
58
+ }
59
+ declare class FuturesAPI extends BaseAPI {
60
+ tickers(params?: {
46
61
  exchange?: string;
47
62
  }): Promise<ApiResponse>;
48
- getFuturesTickerBySymbol(ticker: string): Promise<ApiResponse>;
49
- getFuturesPrices(ticker: string, params?: {
63
+ ticker(ticker: string): Promise<ApiResponse>;
64
+ prices(ticker: string, params?: {
50
65
  from?: string;
51
66
  to?: string;
52
67
  frame?: string;
53
68
  }): Promise<ApiResponse>;
54
- getIndexTickers(params?: {
69
+ }
70
+ declare class IndicesAPI extends BaseAPI {
71
+ tickers(params?: {
55
72
  exchange?: string;
56
73
  }): Promise<ApiResponse>;
57
- getIndexTickerBySymbol(ticker: string): Promise<ApiResponse>;
58
- getIndexPrices(ticker: string, params?: {
74
+ ticker(ticker: string): Promise<ApiResponse>;
75
+ prices(ticker: string, params?: {
59
76
  from?: string;
60
77
  to?: string;
61
78
  frame?: string;
62
79
  }): Promise<ApiResponse>;
63
- searchEcon(query: string): Promise<ApiResponse>;
64
- getEconDataset(seriesId: string): Promise<ApiResponse>;
65
- getEconCalendar(params?: {
80
+ }
81
+ declare class EconAPI extends BaseAPI {
82
+ search(query: string): Promise<ApiResponse>;
83
+ dataset(seriesId: string): Promise<ApiResponse>;
84
+ calendar(params?: {
66
85
  from?: string;
67
86
  to?: string;
68
87
  country?: string;
@@ -70,92 +89,58 @@ export declare class Axion {
70
89
  currency?: string;
71
90
  category?: string;
72
91
  }): Promise<ApiResponse>;
73
- /**
74
- * Get asset profile information for a stock
75
- */
76
- getStockAsset(ticker: string): Promise<ApiResponse>;
77
- /**
78
- * Get recommendation trend for a stock
79
- */
80
- getStockRecommendation(ticker: string): Promise<ApiResponse>;
81
- /**
82
- * Get cash flow statement history for a stock
83
- */
84
- getStockCashflow(ticker: string): Promise<ApiResponse>;
85
- /**
86
- * Get index trend estimates for a stock
87
- */
88
- getStockTrendIndex(ticker: string): Promise<ApiResponse>;
89
- /**
90
- * Get key statistics for a stock
91
- */
92
- getStockStatistics(ticker: string): Promise<ApiResponse>;
93
- /**
94
- * Get income statement history for a stock
95
- */
96
- getStockIncome(ticker: string): Promise<ApiResponse>;
97
- /**
98
- * Get fund ownership data for a stock
99
- */
100
- getStockFund(ticker: string): Promise<ApiResponse>;
101
- /**
102
- * Get summary detail for a stock
103
- */
104
- getStockSummary(ticker: string): Promise<ApiResponse>;
105
- /**
106
- * Get insider holders for a stock
107
- */
108
- getStockInsiders(ticker: string): Promise<ApiResponse>;
109
- /**
110
- * Get calendar events for a stock
111
- */
112
- getStockCalendar(ticker: string): Promise<ApiResponse>;
113
- /**
114
- * Get balance sheet history for a stock
115
- */
116
- getStockBalancesheet(ticker: string): Promise<ApiResponse>;
117
- /**
118
- * Get earnings trend estimates for a stock
119
- */
120
- getStockTrendEarnings(ticker: string): Promise<ApiResponse>;
121
- /**
122
- * Get institution ownership for a stock
123
- */
124
- getStockInstitution(ticker: string): Promise<ApiResponse>;
125
- /**
126
- * Get major holders breakdown for a stock
127
- */
128
- getStockOwnership(ticker: string): Promise<ApiResponse>;
129
- /**
130
- * Get earnings history for a stock
131
- */
132
- getStockEarnings(ticker: string): Promise<ApiResponse>;
133
- /**
134
- * Get summary profile information for a stock
135
- */
136
- getStockInfo(ticker: string): Promise<ApiResponse>;
137
- /**
138
- * Get net share purchase activity for a stock
139
- */
140
- getStockActivity(ticker: string): Promise<ApiResponse>;
141
- /**
142
- * Get insider transactions for a stock
143
- */
144
- getStockTransactions(ticker: string): Promise<ApiResponse>;
145
- /**
146
- * Get financial data for a stock
147
- */
148
- getStockFinancials(ticker: string): Promise<ApiResponse>;
149
- /**
150
- * Get web traffic data for a company
151
- */
152
- getStockTraffic(ticker: string): Promise<ApiResponse>;
153
- getNews(): Promise<ApiResponse>;
154
- getCompanyNews(ticker: string): Promise<ApiResponse>;
155
- getCountryNews(country: string): Promise<ApiResponse>;
156
- getCategoryNews(category: string): Promise<ApiResponse>;
157
- getSentimentAll(ticker: string): Promise<ApiResponse>;
158
- getSentimentSocial(ticker: string): Promise<ApiResponse>;
159
- getSentimentNews(ticker: string): Promise<ApiResponse>;
160
- getSentimentAnalyst(ticker: string): Promise<ApiResponse>;
161
92
  }
93
+ declare class NewsAPI extends BaseAPI {
94
+ general(): Promise<ApiResponse>;
95
+ company(ticker: string): Promise<ApiResponse>;
96
+ country(country: string): Promise<ApiResponse>;
97
+ category(category: string): Promise<ApiResponse>;
98
+ }
99
+ declare class SentimentAPI extends BaseAPI {
100
+ all(ticker: string): Promise<ApiResponse>;
101
+ social(ticker: string): Promise<ApiResponse>;
102
+ news(ticker: string): Promise<ApiResponse>;
103
+ analyst(ticker: string): Promise<ApiResponse>;
104
+ }
105
+ declare class ProfilesAPI extends BaseAPI {
106
+ asset(ticker: string): Promise<ApiResponse>;
107
+ recommendation(ticker: string): Promise<ApiResponse>;
108
+ cashflow(ticker: string): Promise<ApiResponse>;
109
+ indexTrend(ticker: string): Promise<ApiResponse>;
110
+ statistics(ticker: string): Promise<ApiResponse>;
111
+ income(ticker: string): Promise<ApiResponse>;
112
+ fund(ticker: string): Promise<ApiResponse>;
113
+ summary(ticker: string): Promise<ApiResponse>;
114
+ insiders(ticker: string): Promise<ApiResponse>;
115
+ calendar(ticker: string): Promise<ApiResponse>;
116
+ balancesheet(ticker: string): Promise<ApiResponse>;
117
+ earningsTrend(ticker: string): Promise<ApiResponse>;
118
+ institutionOwnership(ticker: string): Promise<ApiResponse>;
119
+ ownership(ticker: string): Promise<ApiResponse>;
120
+ earnings(ticker: string): Promise<ApiResponse>;
121
+ info(ticker: string): Promise<ApiResponse>;
122
+ activity(ticker: string): Promise<ApiResponse>;
123
+ transactions(ticker: string): Promise<ApiResponse>;
124
+ financials(ticker: string): Promise<ApiResponse>;
125
+ traffic(ticker: string): Promise<ApiResponse>;
126
+ }
127
+ export declare class Axion {
128
+ private client;
129
+ private apiKey?;
130
+ credit: CreditAPI;
131
+ esg: ESGAPI;
132
+ etfs: ETFAPI;
133
+ supplyChain: SupplyChainAPI;
134
+ stocks: StocksAPI;
135
+ crypto: CryptoAPI;
136
+ forex: ForexAPI;
137
+ futures: FuturesAPI;
138
+ indices: IndicesAPI;
139
+ econ: EconAPI;
140
+ news: NewsAPI;
141
+ sentiment: SentimentAPI;
142
+ profiles: ProfilesAPI;
143
+ constructor(apiKey?: string);
144
+ _request(method: string, path: string, params?: Record<string, any>, data?: Record<string, any>, authRequired?: boolean): Promise<ApiResponse>;
145
+ }
146
+ export {};
package/dist/index.js CHANGED
@@ -5,292 +5,267 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Axion = void 0;
7
7
  const axios_1 = __importDefault(require("axios"));
8
- const BASE_URL = "http://localhost:3001";
9
- class Axion {
10
- constructor(apiKey) {
11
- this.apiKey = apiKey;
12
- this.client = axios_1.default.create({
13
- baseURL: BASE_URL,
14
- headers: {
15
- "Content-Type": "application/json",
16
- }
17
- });
18
- if (apiKey) {
19
- this.client.defaults.headers.common["Authorization"] = `Bearer ${this.apiKey}`;
20
- }
8
+ const BASE_URL = "https://api.axionquant.com";
9
+ class BaseAPI {
10
+ constructor(client) {
11
+ this.client = client;
21
12
  }
22
13
  async _request(method, path, params = {}, data = {}, authRequired = true) {
23
- const config = {
24
- method,
25
- url: path,
26
- params,
27
- data,
28
- headers: { ...this.client.defaults.headers.common }
29
- };
30
- if (!authRequired) {
31
- delete config.headers["Authorization"];
32
- }
33
- else if (authRequired && !this.apiKey) {
34
- throw new Error("Authentication required but no API key provided to client.");
35
- }
36
- try {
37
- const response = await this.client.request(config);
38
- // The python version has a normalize function, which seems to coerce strings to numbers/booleans.
39
- // This is generally not needed in JS/TS as JSON parsing handles types correctly.
40
- // If the API returns numbers as strings, a normalization step would be needed here.
41
- return response.data;
42
- }
43
- catch (error) {
44
- const axiosError = error;
45
- if (axiosError.response) {
46
- const errorData = axiosError.response.data;
47
- throw new Error(`HTTP Error ${axiosError.response.status}: ${errorData?.message || 'Unknown HTTP error'}`);
48
- }
49
- else if (axiosError.request) {
50
- throw new Error(`Connection Error: Could not connect to ${BASE_URL}`);
51
- }
52
- else {
53
- throw new Error(`Request Error: ${axiosError.message}`);
54
- }
55
- }
14
+ return this.client._request(method, path, params, data, authRequired);
56
15
  }
57
- // --- Credit API ---
58
- searchCredit(query) {
16
+ }
17
+ class CreditAPI extends BaseAPI {
18
+ search(query) {
59
19
  return this._request("GET", "credit/search", { query });
60
20
  }
61
- getCreditRatings(entityId) {
21
+ ratings(entityId) {
62
22
  return this._request("GET", `credit/ratings/${entityId}`);
63
23
  }
64
- // --- ESG API ---
65
- getEsgData(ticker) {
24
+ }
25
+ class ESGAPI extends BaseAPI {
26
+ data(ticker) {
66
27
  return this._request("GET", `esg/${ticker}`);
67
28
  }
68
- // --- ETF API ---
69
- getEtfFundData(ticker) {
29
+ }
30
+ class ETFAPI extends BaseAPI {
31
+ fund(ticker) {
70
32
  return this._request("GET", `etfs/${ticker}/fund`);
71
33
  }
72
- getEtfHoldings(ticker) {
34
+ holdings(ticker) {
73
35
  return this._request("GET", `etfs/${ticker}/holdings`);
74
36
  }
75
- getEtfExposure(ticker) {
37
+ exposure(ticker) {
76
38
  return this._request("GET", `etfs/${ticker}/exposure`);
77
39
  }
78
- // --- Supply Chain API ---
79
- getSupplyChainCustomers(ticker) {
40
+ }
41
+ class SupplyChainAPI extends BaseAPI {
42
+ customers(ticker) {
80
43
  return this._request("GET", `supply-chain/${ticker}/customers`);
81
44
  }
82
- getSupplyChainPeers(ticker) {
45
+ peers(ticker) {
83
46
  return this._request("GET", `supply-chain/${ticker}/peers`);
84
47
  }
85
- getSupplyChainSuppliers(ticker) {
48
+ suppliers(ticker) {
86
49
  return this._request("GET", `supply-chain/${ticker}/suppliers`);
87
50
  }
88
- // --- Stocks API ---
89
- getStockTickers(params = {}) {
51
+ }
52
+ class StocksAPI extends BaseAPI {
53
+ tickers(params = {}) {
90
54
  return this._request("GET", "stocks/tickers", params);
91
55
  }
92
- getStockTickerBySymbol(ticker) {
56
+ ticker(ticker) {
93
57
  return this._request("GET", `stocks/${ticker}`);
94
58
  }
95
- getStockPrices(ticker, params = {}) {
59
+ prices(ticker, params = {}) {
96
60
  return this._request("GET", `stocks/${ticker}/prices`, params);
97
61
  }
98
- // --- Crypto API ---
99
- getCryptoTickers(params = {}) {
62
+ }
63
+ class CryptoAPI extends BaseAPI {
64
+ tickers(params = {}) {
100
65
  return this._request("GET", "crypto/tickers", params);
101
66
  }
102
- getCryptoTickerBySymbol(ticker) {
67
+ ticker(ticker) {
103
68
  return this._request("GET", `crypto/${ticker}`);
104
69
  }
105
- getCryptoPrices(ticker, params = {}) {
70
+ prices(ticker, params = {}) {
106
71
  return this._request("GET", `crypto/${ticker}/prices`, params);
107
72
  }
108
- // --- Forex API ---
109
- getForexTickers(params = {}) {
73
+ }
74
+ class ForexAPI extends BaseAPI {
75
+ tickers(params = {}) {
110
76
  return this._request("GET", "forex/tickers", params);
111
77
  }
112
- getForexTickerBySymbol(ticker) {
78
+ ticker(ticker) {
113
79
  return this._request("GET", `forex/${ticker}`);
114
80
  }
115
- getForexPrices(ticker, params = {}) {
81
+ prices(ticker, params = {}) {
116
82
  return this._request("GET", `forex/${ticker}/prices`, params);
117
83
  }
118
- // --- Futures API ---
119
- getFuturesTickers(params = {}) {
84
+ }
85
+ class FuturesAPI extends BaseAPI {
86
+ tickers(params = {}) {
120
87
  return this._request("GET", "futures/tickers", params);
121
88
  }
122
- getFuturesTickerBySymbol(ticker) {
89
+ ticker(ticker) {
123
90
  return this._request("GET", `futures/${ticker}`);
124
91
  }
125
- getFuturesPrices(ticker, params = {}) {
92
+ prices(ticker, params = {}) {
126
93
  return this._request("GET", `futures/${ticker}/prices`, params);
127
94
  }
128
- // --- Indices API ---
129
- getIndexTickers(params = {}) {
95
+ }
96
+ class IndicesAPI extends BaseAPI {
97
+ tickers(params = {}) {
130
98
  return this._request("GET", "indices/tickers", params);
131
99
  }
132
- getIndexTickerBySymbol(ticker) {
100
+ ticker(ticker) {
133
101
  return this._request("GET", `indices/${ticker}`);
134
102
  }
135
- getIndexPrices(ticker, params = {}) {
103
+ prices(ticker, params = {}) {
136
104
  return this._request("GET", `indices/${ticker}/prices`, params);
137
105
  }
138
- // --- Economic API ---
139
- searchEcon(query) {
106
+ }
107
+ class EconAPI extends BaseAPI {
108
+ search(query) {
140
109
  return this._request("GET", "econ/search", { query });
141
110
  }
142
- getEconDataset(seriesId) {
111
+ dataset(seriesId) {
143
112
  return this._request("GET", `econ/dataset/${seriesId}`);
144
113
  }
145
- getEconCalendar(params = {}) {
114
+ calendar(params = {}) {
146
115
  return this._request("GET", "econ/calendar", params);
147
116
  }
148
- // --- Profiles API ---
149
- /**
150
- * Get asset profile information for a stock
151
- */
152
- getStockAsset(ticker) {
117
+ }
118
+ class NewsAPI extends BaseAPI {
119
+ general() {
120
+ return this._request("GET", "news");
121
+ }
122
+ company(ticker) {
123
+ return this._request("GET", `news/${ticker}`);
124
+ }
125
+ country(country) {
126
+ return this._request("GET", `news/country/${country}`);
127
+ }
128
+ category(category) {
129
+ return this._request("GET", `news/category/${category}`);
130
+ }
131
+ }
132
+ class SentimentAPI extends BaseAPI {
133
+ all(ticker) {
134
+ return this._request("GET", `sentiment/${ticker}/all`);
135
+ }
136
+ social(ticker) {
137
+ return this._request("GET", `sentiment/${ticker}/social`);
138
+ }
139
+ news(ticker) {
140
+ return this._request("GET", `sentiment/${ticker}/news`);
141
+ }
142
+ analyst(ticker) {
143
+ return this._request("GET", `sentiment/${ticker}/analyst`);
144
+ }
145
+ }
146
+ class ProfilesAPI extends BaseAPI {
147
+ asset(ticker) {
153
148
  return this._request("GET", `profiles/${ticker}/asset`);
154
149
  }
155
- /**
156
- * Get recommendation trend for a stock
157
- */
158
- getStockRecommendation(ticker) {
150
+ recommendation(ticker) {
159
151
  return this._request("GET", `profiles/${ticker}/recommendation`);
160
152
  }
161
- /**
162
- * Get cash flow statement history for a stock
163
- */
164
- getStockCashflow(ticker) {
153
+ cashflow(ticker) {
165
154
  return this._request("GET", `profiles/${ticker}/cashflow`);
166
155
  }
167
- /**
168
- * Get index trend estimates for a stock
169
- */
170
- getStockTrendIndex(ticker) {
156
+ indexTrend(ticker) {
171
157
  return this._request("GET", `profiles/${ticker}/trend/index`);
172
158
  }
173
- /**
174
- * Get key statistics for a stock
175
- */
176
- getStockStatistics(ticker) {
159
+ statistics(ticker) {
177
160
  return this._request("GET", `profiles/${ticker}/statistics`);
178
161
  }
179
- /**
180
- * Get income statement history for a stock
181
- */
182
- getStockIncome(ticker) {
162
+ income(ticker) {
183
163
  return this._request("GET", `profiles/${ticker}/income`);
184
164
  }
185
- /**
186
- * Get fund ownership data for a stock
187
- */
188
- getStockFund(ticker) {
165
+ fund(ticker) {
189
166
  return this._request("GET", `profiles/${ticker}/fund`);
190
167
  }
191
- /**
192
- * Get summary detail for a stock
193
- */
194
- getStockSummary(ticker) {
168
+ summary(ticker) {
195
169
  return this._request("GET", `profiles/${ticker}/summary`);
196
170
  }
197
- /**
198
- * Get insider holders for a stock
199
- */
200
- getStockInsiders(ticker) {
171
+ insiders(ticker) {
201
172
  return this._request("GET", `profiles/${ticker}/insiders`);
202
173
  }
203
- /**
204
- * Get calendar events for a stock
205
- */
206
- getStockCalendar(ticker) {
174
+ calendar(ticker) {
207
175
  return this._request("GET", `profiles/${ticker}/calendar`);
208
176
  }
209
- /**
210
- * Get balance sheet history for a stock
211
- */
212
- getStockBalancesheet(ticker) {
177
+ balancesheet(ticker) {
213
178
  return this._request("GET", `profiles/${ticker}/balancesheet`);
214
179
  }
215
- /**
216
- * Get earnings trend estimates for a stock
217
- */
218
- getStockTrendEarnings(ticker) {
180
+ earningsTrend(ticker) {
219
181
  return this._request("GET", `profiles/${ticker}/trend/earnings`);
220
182
  }
221
- /**
222
- * Get institution ownership for a stock
223
- */
224
- getStockInstitution(ticker) {
183
+ institutionOwnership(ticker) {
225
184
  return this._request("GET", `profiles/${ticker}/institution`);
226
185
  }
227
- /**
228
- * Get major holders breakdown for a stock
229
- */
230
- getStockOwnership(ticker) {
186
+ ownership(ticker) {
231
187
  return this._request("GET", `profiles/${ticker}/ownership`);
232
188
  }
233
- /**
234
- * Get earnings history for a stock
235
- */
236
- getStockEarnings(ticker) {
189
+ earnings(ticker) {
237
190
  return this._request("GET", `profiles/${ticker}/earnings`);
238
191
  }
239
- /**
240
- * Get summary profile information for a stock
241
- */
242
- getStockInfo(ticker) {
192
+ info(ticker) {
243
193
  return this._request("GET", `profiles/${ticker}/info`);
244
194
  }
245
- /**
246
- * Get net share purchase activity for a stock
247
- */
248
- getStockActivity(ticker) {
195
+ activity(ticker) {
249
196
  return this._request("GET", `profiles/${ticker}/activity`);
250
197
  }
251
- /**
252
- * Get insider transactions for a stock
253
- */
254
- getStockTransactions(ticker) {
198
+ transactions(ticker) {
255
199
  return this._request("GET", `profiles/${ticker}/transactions`);
256
200
  }
257
- /**
258
- * Get financial data for a stock
259
- */
260
- getStockFinancials(ticker) {
201
+ financials(ticker) {
261
202
  return this._request("GET", `profiles/${ticker}/financials`);
262
203
  }
263
- /**
264
- * Get web traffic data for a company
265
- */
266
- getStockTraffic(ticker) {
204
+ traffic(ticker) {
267
205
  return this._request("GET", `profiles/${ticker}/traffic`);
268
206
  }
269
- // --- News API ---
270
- getNews() {
271
- return this._request("GET", "news");
272
- }
273
- getCompanyNews(ticker) {
274
- return this._request("GET", `news/${ticker}`);
275
- }
276
- getCountryNews(country) {
277
- return this._request("GET", `news/country/${country}`);
278
- }
279
- getCategoryNews(category) {
280
- return this._request("GET", `news/category/${category}`);
281
- }
282
- // --- Sentiment API ---
283
- getSentimentAll(ticker) {
284
- return this._request("GET", `sentiment/${ticker}/all`);
285
- }
286
- getSentimentSocial(ticker) {
287
- return this._request("GET", `sentiment/${ticker}/social`);
288
- }
289
- getSentimentNews(ticker) {
290
- return this._request("GET", `sentiment/${ticker}/news`);
207
+ }
208
+ class Axion {
209
+ constructor(apiKey) {
210
+ this.apiKey = apiKey;
211
+ this.client = axios_1.default.create({
212
+ baseURL: BASE_URL,
213
+ headers: {
214
+ "Content-Type": "application/json",
215
+ }
216
+ });
217
+ if (apiKey) {
218
+ this.client.defaults.headers.common["Authorization"] = `Bearer ${this.apiKey}`;
219
+ }
220
+ // Initialize nested API classes
221
+ this.credit = new CreditAPI(this);
222
+ this.esg = new ESGAPI(this);
223
+ this.etfs = new ETFAPI(this);
224
+ this.supplyChain = new SupplyChainAPI(this);
225
+ this.stocks = new StocksAPI(this);
226
+ this.crypto = new CryptoAPI(this);
227
+ this.forex = new ForexAPI(this);
228
+ this.futures = new FuturesAPI(this);
229
+ this.indices = new IndicesAPI(this);
230
+ this.econ = new EconAPI(this);
231
+ this.news = new NewsAPI(this);
232
+ this.sentiment = new SentimentAPI(this);
233
+ this.profiles = new ProfilesAPI(this);
291
234
  }
292
- getSentimentAnalyst(ticker) {
293
- return this._request("GET", `sentiment/${ticker}/analyst`);
235
+ async _request(method, path, params = {}, data = {}, authRequired = true) {
236
+ const config = {
237
+ method,
238
+ url: path,
239
+ params,
240
+ data,
241
+ headers: { ...this.client.defaults.headers.common }
242
+ };
243
+ if (!authRequired) {
244
+ delete config.headers["Authorization"];
245
+ }
246
+ else if (authRequired && !this.apiKey) {
247
+ throw new Error("Authentication required but no API key provided to client.");
248
+ }
249
+ try {
250
+ const response = await this.client.request(config);
251
+ // The python version has a normalize function, which seems to coerce strings to numbers/booleans.
252
+ // This is generally not needed in JS/TS as JSON parsing handles types correctly.
253
+ // If the API returns numbers as strings, a normalization step would be needed here.
254
+ return response.data;
255
+ }
256
+ catch (error) {
257
+ const axiosError = error;
258
+ if (axiosError.response) {
259
+ const errorData = axiosError.response.data;
260
+ throw new Error(`HTTP Error ${axiosError.response.status}: ${errorData?.message || 'Unknown HTTP error'}`);
261
+ }
262
+ else if (axiosError.request) {
263
+ throw new Error(`Connection Error: Could not connect to ${BASE_URL}`);
264
+ }
265
+ else {
266
+ throw new Error(`Request Error: ${axiosError.message}`);
267
+ }
268
+ }
294
269
  }
295
270
  }
296
271
  exports.Axion = Axion;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axionquant/sdk",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Axion SDK for Node.js",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/readme.md CHANGED
@@ -11,7 +11,7 @@ npm install @axionquant/sdk
11
11
  ## Quick Start
12
12
 
13
13
  ```typescript
14
- import { Axion } from 'axion-sdk';
14
+ import { Axion } from '@axionquant/sdk';
15
15
 
16
16
  // Initialize with API key
17
17
  const client = new Axion('your-api-key');
@@ -276,7 +276,7 @@ try {
276
276
  This SDK is written in TypeScript and includes type definitions. Import types as needed:
277
277
 
278
278
  ```typescript
279
- import { Axion, ApiResponse } from 'axion-sdk';
279
+ import { Axion, ApiResponse } from '@axionquant/sdk';
280
280
  ```
281
281
 
282
282
  ## Base URL