|
| 1 | +# FCS API - Python Functions Reference |
| 2 | + |
| 3 | +Quick reference for all available functions in the FCS API Python library. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## Authentication Methods |
| 8 | + |
| 9 | +```python |
| 10 | +from src import FcsApi, FcsConfig |
| 11 | + |
| 12 | +# Method 1: Default (uses key from fcs_config.py) |
| 13 | +fcsapi = FcsApi() |
| 14 | + |
| 15 | +# Method 2: Pass API Key directly (override) |
| 16 | +fcsapi = FcsApi('YOUR_API_KEY') |
| 17 | + |
| 18 | +# Method 3: IP Whitelist (no key needed if IP whitelisted in account) |
| 19 | +config = FcsConfig.with_ip_whitelist() |
| 20 | +fcsapi = FcsApi(config) |
| 21 | + |
| 22 | +# Method 4: Token-Based (secure for frontend apps) |
| 23 | +config = FcsConfig.with_token('API_KEY', 'PUBLIC_KEY', 3600) |
| 24 | +fcsapi = FcsApi(config) |
| 25 | +token_data = fcsapi.generate_token() # Send to frontend |
| 26 | +``` |
| 27 | + |
| 28 | +### Set Default API Key |
| 29 | +Edit `src/fcs_config.py` and set your key: |
| 30 | +```python |
| 31 | +self.access_key = 'YOUR_API_KEY_HERE' |
| 32 | +``` |
| 33 | + |
| 34 | +### Token Expiry Values |
| 35 | +| Seconds | Duration | |
| 36 | +|---------|----------| |
| 37 | +| 300 | 5 minutes | |
| 38 | +| 900 | 15 minutes | |
| 39 | +| 1800 | 30 minutes | |
| 40 | +| 3600 | 1 hour | |
| 41 | +| 86400 | 24 hours | |
| 42 | + |
| 43 | +--- |
| 44 | + |
| 45 | +## Crypto Functions |
| 46 | + |
| 47 | +```python |
| 48 | +fcsapi.crypto.get_symbols_list(type, sub_type, exchange) |
| 49 | +fcsapi.crypto.get_coins_list() |
| 50 | +fcsapi.crypto.get_latest_price(symbol, period, type, exchange, get_profile) |
| 51 | +fcsapi.crypto.get_all_prices(exchange, period, type) |
| 52 | +fcsapi.crypto.get_coin_data(symbol, limit, sort_by) |
| 53 | +fcsapi.crypto.get_top_by_market_cap(limit) |
| 54 | +fcsapi.crypto.get_top_by_rank(limit) |
| 55 | +fcsapi.crypto.convert(pair1, pair2, amount) |
| 56 | +fcsapi.crypto.get_base_prices(symbol, exchange, fallback) |
| 57 | +fcsapi.crypto.get_cross_rates(symbol, exchange, type, period, crossrates, fallback) |
| 58 | +fcsapi.crypto.get_history(symbol, period, length, from_date, to_date, page, is_chart) |
| 59 | +fcsapi.crypto.get_profile(symbol) |
| 60 | +fcsapi.crypto.get_exchanges(type, sub_type) |
| 61 | +fcsapi.crypto.advanced(params) |
| 62 | +fcsapi.crypto.get_moving_averages(symbol, period, exchange) |
| 63 | +fcsapi.crypto.get_indicators(symbol, period, exchange) |
| 64 | +fcsapi.crypto.get_pivot_points(symbol, period, exchange) |
| 65 | +fcsapi.crypto.get_performance(symbol, exchange) |
| 66 | +fcsapi.crypto.get_top_gainers(exchange, limit, period, type) |
| 67 | +fcsapi.crypto.get_top_losers(exchange, limit, period, type) |
| 68 | +fcsapi.crypto.get_highest_volume(exchange, limit, period, type) |
| 69 | +fcsapi.crypto.get_sorted_data(sort_column, sort_direction, limit, type, exchange, period) |
| 70 | +fcsapi.crypto.search(query, type) |
| 71 | +fcsapi.crypto.multi_url(urls, base) |
| 72 | +``` |
| 73 | + |
| 74 | +### Parameters |
| 75 | +| Parameter | Values | |
| 76 | +|-----------|--------| |
| 77 | +| `type` | crypto, coin, futures, dex, dominance | |
| 78 | +| `sub_type` | spot, swap, index | |
| 79 | +| `exchange` | BINANCE, COINBASE, KRAKEN, BYBIT | |
| 80 | +| `period` | 1m, 5m, 15m, 30m, 1h, 4h, 1D, 1W, 1M | |
| 81 | +| `sort_by` | perf.rank_asc, perf.market_cap_desc, perf.circulating_supply_desc | |
| 82 | +| `sort_column` | active.c, active.chp, active.v, active.h, active.l, perf.rank, perf.market_cap | |
| 83 | +| `sort_direction` | asc, desc | |
| 84 | + |
| 85 | +--- |
| 86 | + |
| 87 | +## Forex Functions |
| 88 | + |
| 89 | +```python |
| 90 | +fcsapi.forex.get_symbols_list(type, sub_type, exchange) |
| 91 | +fcsapi.forex.get_latest_price(symbol, period, type, exchange, get_profile) |
| 92 | +fcsapi.forex.get_all_prices(exchange, period, type) |
| 93 | +fcsapi.forex.get_commodities(symbol, period) |
| 94 | +fcsapi.forex.get_commodity_symbols() |
| 95 | +fcsapi.forex.convert(pair1, pair2, amount, type) |
| 96 | +fcsapi.forex.get_base_prices(symbol, type, exchange, fallback) |
| 97 | +fcsapi.forex.get_cross_rates(symbol, type, period, exchange, crossrates, fallback) |
| 98 | +fcsapi.forex.get_history(symbol, period, length, from_date, to_date, page, is_chart) |
| 99 | +fcsapi.forex.get_profile(symbol) |
| 100 | +fcsapi.forex.get_exchanges(type, sub_type) |
| 101 | +fcsapi.forex.advanced(params) |
| 102 | +fcsapi.forex.get_moving_averages(symbol, period, exchange) |
| 103 | +fcsapi.forex.get_indicators(symbol, period, exchange) |
| 104 | +fcsapi.forex.get_pivot_points(symbol, period, exchange) |
| 105 | +fcsapi.forex.get_performance(symbol, exchange) |
| 106 | +fcsapi.forex.get_economy_calendar(symbol, country, from_date, to_date) |
| 107 | +fcsapi.forex.get_top_gainers(type, limit, period, exchange) |
| 108 | +fcsapi.forex.get_top_losers(type, limit, period, exchange) |
| 109 | +fcsapi.forex.get_most_active(type, limit, period, exchange) |
| 110 | +fcsapi.forex.get_sorted_data(sort_column, sort_direction, limit, type, exchange, period) |
| 111 | +fcsapi.forex.search(query, type, exchange) |
| 112 | +fcsapi.forex.multi_url(urls, base) |
| 113 | +``` |
| 114 | + |
| 115 | +### Parameters |
| 116 | +| Parameter | Values | |
| 117 | +|-----------|--------| |
| 118 | +| `type` | forex, commodity | |
| 119 | +| `sub_type` | spot, synthetic | |
| 120 | +| `exchange` | FX, ONA, SFO, FCM | |
| 121 | +| `period` | 1m, 5m, 15m, 30m, 1h, 4h, 1D, 1W, 1M | |
| 122 | +| `country` | US, GB, DE, JP, AU, CA | |
| 123 | + |
| 124 | +--- |
| 125 | + |
| 126 | +## Stock Functions |
| 127 | + |
| 128 | +```python |
| 129 | +# Symbol/List |
| 130 | +fcsapi.stock.get_symbols_list(exchange, country, sector, indices) |
| 131 | +fcsapi.stock.search(query, exchange, country) |
| 132 | + |
| 133 | +# Indices |
| 134 | +fcsapi.stock.get_indices_list(country, exchange) |
| 135 | +fcsapi.stock.get_indices_latest(symbol, country, exchange) |
| 136 | + |
| 137 | +# Latest Prices |
| 138 | +fcsapi.stock.get_latest_price(symbol, period, exchange, get_profile) |
| 139 | +fcsapi.stock.get_all_prices(exchange, period) |
| 140 | +fcsapi.stock.get_latest_by_country(country, sector, period) |
| 141 | +fcsapi.stock.get_latest_by_indices(indices, period) |
| 142 | + |
| 143 | +# Historical |
| 144 | +fcsapi.stock.get_history(symbol, period, length, from_date, to_date, page, is_chart) |
| 145 | + |
| 146 | +# Profile & Info |
| 147 | +fcsapi.stock.get_profile(symbol) |
| 148 | +fcsapi.stock.get_exchanges(type, sub_type) |
| 149 | + |
| 150 | +# Financial Data |
| 151 | +fcsapi.stock.get_earnings(symbol, duration) |
| 152 | +fcsapi.stock.get_revenue(symbol) |
| 153 | +fcsapi.stock.get_dividends(symbol, format) |
| 154 | +fcsapi.stock.get_balance_sheet(symbol, duration, format) |
| 155 | +fcsapi.stock.get_income_statements(symbol, duration, format) |
| 156 | +fcsapi.stock.get_cash_flow(symbol, duration, format) |
| 157 | +fcsapi.stock.get_statistics(symbol, duration) |
| 158 | +fcsapi.stock.get_forecast(symbol) |
| 159 | +fcsapi.stock.get_stock_data(symbol, data_column, duration, format) |
| 160 | + |
| 161 | +# Technical Analysis |
| 162 | +fcsapi.stock.get_moving_averages(symbol, period) |
| 163 | +fcsapi.stock.get_indicators(symbol, period) |
| 164 | +fcsapi.stock.get_pivot_points(symbol, period) |
| 165 | +fcsapi.stock.get_performance(symbol) |
| 166 | + |
| 167 | +# Top Movers & Sorting |
| 168 | +fcsapi.stock.get_top_gainers(exchange, limit, period, country) |
| 169 | +fcsapi.stock.get_top_losers(exchange, limit, period, country) |
| 170 | +fcsapi.stock.get_most_active(exchange, limit, period, country) |
| 171 | +fcsapi.stock.get_sorted_data(sort_column, sort_direction, limit, exchange, country, period) |
| 172 | + |
| 173 | +# Filter |
| 174 | +fcsapi.stock.get_by_sector(sector, limit, exchange) |
| 175 | +fcsapi.stock.get_by_country(country, limit, exchange) |
| 176 | + |
| 177 | +# Advanced |
| 178 | +fcsapi.stock.advanced(params) |
| 179 | +fcsapi.stock.multi_url(urls, base) |
| 180 | +``` |
| 181 | + |
| 182 | +### Parameters |
| 183 | +| Parameter | Values | |
| 184 | +|-----------|--------| |
| 185 | +| `type` | stock, index, fund, structured, dr | |
| 186 | +| `sub_type` | spot, main, cfd, common, preferred | |
| 187 | +| `exchange` | NASDAQ, NYSE, LSE, TSE, HKEX, BSE | |
| 188 | +| `period` | 1m, 5m, 15m, 30m, 1h, 4h, 1D, 1W, 1M | |
| 189 | +| `duration` | annual, interim, both | |
| 190 | +| `format` | plain, inherit | |
| 191 | +| `data_column` | earnings, revenue, profile, dividends, balance_sheet, income_statements, statistics, cash_flow | |
| 192 | + |
| 193 | +--- |
| 194 | + |
| 195 | +## Common Response Fields |
| 196 | + |
| 197 | +| Field | Description | |
| 198 | +|-------|-------------| |
| 199 | +| `o` | Open price | |
| 200 | +| `h` | High price | |
| 201 | +| `l` | Low price | |
| 202 | +| `c` | Close/Current price | |
| 203 | +| `v` | Volume | |
| 204 | +| `t` | Unix timestamp | |
| 205 | +| `ch` | Change amount | |
| 206 | +| `chp` | Change percentage | |
| 207 | + |
| 208 | +--- |
| 209 | + |
| 210 | +## Quick Examples |
| 211 | + |
| 212 | +```python |
| 213 | +# Initialize (uses key from fcs_config.py) |
| 214 | +fcsapi = FcsApi() |
| 215 | + |
| 216 | +# Crypto |
| 217 | +fcsapi.crypto.get_latest_price('BINANCE:BTCUSDT') |
| 218 | +fcsapi.crypto.get_history('BINANCE:BTCUSDT', '1D', 100) |
| 219 | +fcsapi.crypto.get_coin_data(None, 50, 'perf.rank_asc') |
| 220 | + |
| 221 | +# Forex |
| 222 | +fcsapi.forex.get_latest_price('FX:EURUSD') |
| 223 | +fcsapi.forex.convert('EUR', 'USD', 100) |
| 224 | + |
| 225 | +# Stock |
| 226 | +fcsapi.stock.get_latest_price('NASDAQ:AAPL') |
| 227 | +fcsapi.stock.get_top_gainers('NASDAQ', 10) |
| 228 | +fcsapi.stock.get_earnings('NASDAQ:AAPL', 'annual') |
| 229 | +fcsapi.stock.get_dividends('NASDAQ:AAPL') |
| 230 | +fcsapi.stock.get_balance_sheet('NASDAQ:AAPL', 'annual') |
| 231 | +fcsapi.stock.get_stock_data('NASDAQ:AAPL', 'profile,earnings,dividends') |
| 232 | +``` |
| 233 | + |
| 234 | +--- |
| 235 | + |
| 236 | +## Token Authentication Example |
| 237 | + |
| 238 | +```python |
| 239 | +# Backend: Generate token |
| 240 | +config = FcsConfig.with_token('YOUR_API_KEY', 'YOUR_PUBLIC_KEY', 3600) |
| 241 | +fcsapi = FcsApi(config) |
| 242 | +token_data = fcsapi.generate_token() |
| 243 | + |
| 244 | +# Send token_data to frontend: |
| 245 | +# { |
| 246 | +# '_token': 'abc123...', |
| 247 | +# '_expiry': 1764164233, |
| 248 | +# '_public_key': 'your_public_key' |
| 249 | +# } |
| 250 | + |
| 251 | +# Frontend (JavaScript): Use token |
| 252 | +# fetch('https://api-v4.fcsapi.com/forex/latest?symbol=EURUSD' + |
| 253 | +# '&_public_key=' + token_data._public_key + |
| 254 | +# '&_expiry=' + token_data._expiry + |
| 255 | +# '&_token=' + token_data._token) |
| 256 | +``` |
| 257 | + |
| 258 | +--- |
| 259 | + |
| 260 | +## Get API Key |
| 261 | + |
| 262 | +Get your API key at: https://fcsapi.com |
0 commit comments