Skip to content

Commit a492701

Browse files
committed
Initial commit: FCS REST API JS/Node.js client
0 parents  commit a492701

19 files changed

Lines changed: 3345 additions & 0 deletions

.gitignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Composer
2+
/vendor/
3+
composer.lock
4+
5+
# IDE
6+
.idea/
7+
.vscode/
8+
*.swp
9+
*.swo
10+
*~
11+
12+
# OS
13+
.DS_Store
14+
Thumbs.db
15+
16+
# Environment
17+
.env
18+
.env.local
19+
.env.*.local
20+
21+
# Logs
22+
*.log
23+
24+
# Cache
25+
/cache/
26+
*.cache

FUNCTIONS.md

Lines changed: 322 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,322 @@
1+
# FCS API - JavaScript Functions Reference
2+
3+
Quick reference for all available functions in the FCS API JavaScript library.
4+
5+
---
6+
7+
## Authentication Methods
8+
9+
### Method 1: Access Key (Default)
10+
11+
```javascript
12+
// Set in FcsConfig.js
13+
authMethod = 'access_key';
14+
accessKey = 'YOUR_ACCESS_KEY_HERE';
15+
16+
// Or pass directly
17+
const config = FcsConfig.withAccessKey('YOUR_ACCESS_KEY');
18+
const fcsapi = new FcsApi(config);
19+
20+
// Or set after initialization
21+
const fcsapi = new FcsApi();
22+
fcsapi.setAccessKey('YOUR_ACCESS_KEY');
23+
```
24+
25+
### Method 2: IP Whitelist
26+
27+
```javascript
28+
// Set in FcsConfig.js
29+
authMethod = 'ip_whitelist';
30+
31+
// Or use static method
32+
const config = FcsConfig.withIpWhitelist();
33+
const fcsapi = new FcsApi(config);
34+
35+
// Or set after initialization
36+
const fcsapi = new FcsApi();
37+
fcsapi.useIpWhitelist();
38+
```
39+
40+
### Method 3: Token-Based
41+
42+
```javascript
43+
// Set in FcsConfig.js
44+
authMethod = 'token';
45+
publicKey = 'YOUR_PUBLIC_KEY';
46+
token = 'TOKEN_FROM_BACKEND';
47+
tokenExpiry = 1735123456;
48+
49+
// Or use static method
50+
const config = FcsConfig.withToken('PUBLIC_KEY', 'TOKEN', 1735123456);
51+
const fcsapi = new FcsApi(config);
52+
53+
// Or set after initialization
54+
const fcsapi = new FcsApi();
55+
fcsapi.setToken({
56+
token: 'TOKEN_FROM_BACKEND',
57+
expiry: 1735123456,
58+
publicKey: 'YOUR_PUBLIC_KEY'
59+
});
60+
```
61+
62+
### Token Expiry Values
63+
| Seconds | Duration |
64+
|---------|----------|
65+
| 300 | 5 minutes |
66+
| 900 | 15 minutes |
67+
| 1800 | 30 minutes |
68+
| 3600 | 1 hour |
69+
| 86400 | 24 hours |
70+
71+
### Check Token Validity
72+
```javascript
73+
if (!fcsapi.isTokenValid()) {
74+
// Refresh token from your backend
75+
}
76+
```
77+
78+
---
79+
80+
## Crypto Functions
81+
82+
```javascript
83+
await fcsapi.crypto.getSymbolsList(type, subType, exchange)
84+
await fcsapi.crypto.getCoinsList()
85+
await fcsapi.crypto.getLatestPrice(symbol, period, type, exchange, getProfile)
86+
await fcsapi.crypto.getAllPrices(exchange, period, type)
87+
await fcsapi.crypto.getCoinData(symbol, limit, sortBy)
88+
await fcsapi.crypto.getTopByMarketCap(limit)
89+
await fcsapi.crypto.getTopByRank(limit)
90+
await fcsapi.crypto.convert(pair1, pair2, amount)
91+
await fcsapi.crypto.getBasePrices(symbol, exchange, fallback)
92+
await fcsapi.crypto.getCrossRates(symbol, exchange, type, period, crossrates, fallback)
93+
await fcsapi.crypto.getHistory(symbol, period, length, from, to, page, isChart)
94+
await fcsapi.crypto.getProfile(symbol)
95+
await fcsapi.crypto.getExchanges(type, subType)
96+
await fcsapi.crypto.advanced(params)
97+
await fcsapi.crypto.getMovingAverages(symbol, period, exchange)
98+
await fcsapi.crypto.getIndicators(symbol, period, exchange)
99+
await fcsapi.crypto.getPivotPoints(symbol, period, exchange)
100+
await fcsapi.crypto.getPerformance(symbol, exchange)
101+
await fcsapi.crypto.getTopGainers(exchange, limit, period, type)
102+
await fcsapi.crypto.getTopLosers(exchange, limit, period, type)
103+
await fcsapi.crypto.getHighestVolume(exchange, limit, period, type)
104+
await fcsapi.crypto.getSortedData(sortColumn, sortDirection, limit, type, exchange, period)
105+
await fcsapi.crypto.search(query, type)
106+
await fcsapi.crypto.multiUrl(urls, base)
107+
```
108+
109+
### Parameters
110+
| Parameter | Values |
111+
|-----------|--------|
112+
| `type` | crypto, coin, futures, dex, dominance |
113+
| `subType` | spot, swap, index |
114+
| `exchange` | BINANCE, COINBASE, KRAKEN, BYBIT |
115+
| `period` | 1m, 5m, 15m, 30m, 1h, 4h, 1D, 1W, 1M |
116+
| `sortBy` | perf.rank_asc, perf.market_cap_desc, perf.circulating_supply_desc |
117+
| `sortColumn` | active.c, active.chp, active.v, active.h, active.l, perf.rank, perf.market_cap |
118+
| `sortDirection` | asc, desc |
119+
120+
---
121+
122+
## Forex Functions
123+
124+
```javascript
125+
await fcsapi.forex.getSymbolsList(type, subType, exchange)
126+
await fcsapi.forex.getLatestPrice(symbol, period, type, exchange, getProfile)
127+
await fcsapi.forex.getAllPrices(exchange, period, type)
128+
await fcsapi.forex.getCommodities(symbol, period)
129+
await fcsapi.forex.getCommoditySymbols()
130+
await fcsapi.forex.convert(pair1, pair2, amount, type)
131+
await fcsapi.forex.getBasePrices(symbol, type, exchange, fallback)
132+
await fcsapi.forex.getCrossRates(symbol, type, period, exchange, crossrates, fallback)
133+
await fcsapi.forex.getHistory(symbol, period, length, from, to, page, isChart)
134+
await fcsapi.forex.getProfile(symbol)
135+
await fcsapi.forex.getExchanges(type, subType)
136+
await fcsapi.forex.advanced(params)
137+
await fcsapi.forex.getMovingAverages(symbol, period, exchange)
138+
await fcsapi.forex.getIndicators(symbol, period, exchange)
139+
await fcsapi.forex.getPivotPoints(symbol, period, exchange)
140+
await fcsapi.forex.getPerformance(symbol, exchange)
141+
await fcsapi.forex.getEconomyCalendar(country, from, to)
142+
await fcsapi.forex.getTopGainers(type, limit, period, exchange)
143+
await fcsapi.forex.getTopLosers(type, limit, period, exchange)
144+
await fcsapi.forex.getMostActive(type, limit, period, exchange)
145+
await fcsapi.forex.getSortedData(sortColumn, sortDirection, limit, type, exchange, period)
146+
await fcsapi.forex.search(query, type, exchange)
147+
await fcsapi.forex.multiUrl(urls, base)
148+
```
149+
150+
### Parameters
151+
| Parameter | Values |
152+
|-----------|--------|
153+
| `type` | forex, commodity |
154+
| `subType` | spot, synthetic |
155+
| `exchange` | FX, ONA, SFO, FCM |
156+
| `period` | 1m, 5m, 15m, 30m, 1h, 4h, 1D, 1W, 1M |
157+
| `country` | US, GB, DE, JP, AU, CA |
158+
159+
---
160+
161+
## Stock Functions
162+
163+
```javascript
164+
// Symbol/List
165+
await fcsapi.stock.getSymbolsList(exchange, country, sector, indices)
166+
await fcsapi.stock.search(query, exchange, country)
167+
168+
// Indices
169+
await fcsapi.stock.getIndicesList(country, exchange)
170+
await fcsapi.stock.getIndicesLatest(symbol, country, exchange)
171+
172+
// Latest Prices
173+
await fcsapi.stock.getLatestPrice(symbol, period, exchange, getProfile)
174+
await fcsapi.stock.getAllPrices(exchange, period)
175+
await fcsapi.stock.getLatestByCountry(country, sector, period)
176+
await fcsapi.stock.getLatestByIndices(indices, period)
177+
178+
// Historical
179+
await fcsapi.stock.getHistory(symbol, period, length, from, to, page, isChart)
180+
181+
// Profile & Info
182+
await fcsapi.stock.getProfile(symbol)
183+
await fcsapi.stock.getExchanges(type, subType)
184+
185+
// Financial Data
186+
await fcsapi.stock.getEarnings(symbol, duration)
187+
await fcsapi.stock.getRevenue(symbol)
188+
await fcsapi.stock.getDividends(symbol, format)
189+
await fcsapi.stock.getBalanceSheet(symbol, duration, format)
190+
await fcsapi.stock.getIncomeStatements(symbol, duration, format)
191+
await fcsapi.stock.getCashFlow(symbol, duration, format)
192+
await fcsapi.stock.getStatistics(symbol, duration)
193+
await fcsapi.stock.getForecast(symbol)
194+
await fcsapi.stock.getStockData(symbol, dataColumn, duration, format)
195+
196+
// Technical Analysis
197+
await fcsapi.stock.getMovingAverages(symbol, period)
198+
await fcsapi.stock.getIndicators(symbol, period)
199+
await fcsapi.stock.getPivotPoints(symbol, period)
200+
await fcsapi.stock.getPerformance(symbol)
201+
202+
// Top Movers & Sorting
203+
await fcsapi.stock.getTopGainers(exchange, limit, period, country)
204+
await fcsapi.stock.getTopLosers(exchange, limit, period, country)
205+
await fcsapi.stock.getMostActive(exchange, limit, period, country)
206+
await fcsapi.stock.getSortedData(sortColumn, sortDirection, limit, exchange, country, period)
207+
208+
// Filter
209+
await fcsapi.stock.getBySector(sector, limit, exchange)
210+
await fcsapi.stock.getByCountry(country, limit, exchange)
211+
212+
// Advanced
213+
await fcsapi.stock.advanced(params)
214+
await fcsapi.stock.multiUrl(urls, base)
215+
```
216+
217+
### Parameters
218+
| Parameter | Values |
219+
|-----------|--------|
220+
| `type` | stock, index, fund, structured, dr |
221+
| `subType` | spot, main, cfd, common, preferred |
222+
| `exchange` | NASDAQ, NYSE, LSE, TSE, HKEX, BSE |
223+
| `period` | 1m, 5m, 15m, 30m, 1h, 4h, 1D, 1W, 1M |
224+
| `duration` | annual, interim, both |
225+
| `format` | plain, inherit |
226+
| `dataColumn` | earnings, revenue, profile, dividends, balance_sheet, income_statements, statistics, cash_flow |
227+
228+
---
229+
230+
## Response Handling
231+
232+
```javascript
233+
const response = await fcsapi.forex.getLatestPrice('FX:EURUSD');
234+
235+
// Check if successful
236+
if (fcsapi.isSuccess()) {
237+
const data = response.response;
238+
console.log(data);
239+
} else {
240+
console.error('Error:', fcsapi.getError());
241+
}
242+
243+
// Get last response
244+
const lastResponse = fcsapi.getLastResponse();
245+
246+
// Get response data only
247+
const data = fcsapi.getResponseData();
248+
```
249+
250+
---
251+
252+
## Common Response Fields
253+
254+
| Field | Description |
255+
|-------|-------------|
256+
| `o` | Open price |
257+
| `h` | High price |
258+
| `l` | Low price |
259+
| `c` | Close/Current price |
260+
| `v` | Volume |
261+
| `t` | Unix timestamp |
262+
| `ch` | Change amount |
263+
| `chp` | Change percentage |
264+
265+
---
266+
267+
## Quick Examples
268+
269+
```javascript
270+
// Initialize (uses settings from FcsConfig.js)
271+
const fcsapi = new FcsApi();
272+
273+
// Or with specific config
274+
const config = FcsConfig.withAccessKey('YOUR_KEY');
275+
const fcsapi = new FcsApi(config);
276+
277+
// Crypto
278+
await fcsapi.crypto.getLatestPrice('BINANCE:BTCUSDT');
279+
await fcsapi.crypto.getHistory('BINANCE:BTCUSDT', '1D', 100);
280+
await fcsapi.crypto.getCoinData(null, 50, 'perf.rank_asc');
281+
await fcsapi.crypto.getTopByMarketCap(100);
282+
283+
// Forex
284+
await fcsapi.forex.getLatestPrice('FX:EURUSD');
285+
await fcsapi.forex.convert('EUR', 'USD', 100);
286+
await fcsapi.forex.getEconomyCalendar('US');
287+
288+
// Stock
289+
await fcsapi.stock.getLatestPrice('NASDAQ:AAPL');
290+
await fcsapi.stock.getTopGainers('NASDAQ', 10);
291+
await fcsapi.stock.getEarnings('NASDAQ:AAPL', 'annual');
292+
await fcsapi.stock.getDividends('NASDAQ:AAPL');
293+
await fcsapi.stock.getBalanceSheet('NASDAQ:AAPL', 'annual');
294+
await fcsapi.stock.getStockData('NASDAQ:AAPL', 'profile,earnings,dividends');
295+
```
296+
297+
---
298+
299+
## File Structure
300+
301+
```
302+
rest-api-js/
303+
├── src/
304+
│ ├── FcsConfig.js # Configuration (auth methods)
305+
│ ├── FcsApi.js # Main client (initializes modules)
306+
│ ├── FCS_Crypto.js # Crypto module
307+
│ ├── FCS_Forex.js # Forex module
308+
│ └── FCS_Stock.js # Stock module
309+
├── examples/
310+
│ ├── forex-example.html # Forex demo
311+
│ ├── crypto-example.html # Crypto demo
312+
│ └── stock-example.html # Stock demo
313+
├── FUNCTIONS.md # This file
314+
├── README.md # Documentation
315+
└── LICENSE # MIT License
316+
```
317+
318+
---
319+
320+
## Get API Key
321+
322+
Get your API key at: https://fcsapi.com/dashboard

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021-2025 FCS API
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)