Skip to content

Commit 4c411f4

Browse files
committed
Initial commit: FCS REST API Python client v4.0.0
0 parents  commit 4c411f4

19 files changed

+3265
-0
lines changed

.github/workflows/publish.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
publish:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
id-token: write
12+
contents: read
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Set up Python
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: '3.x'
22+
23+
- name: Install build tools
24+
run: pip install build
25+
26+
- name: Build package
27+
run: python -m build
28+
29+
- name: Publish to PyPI
30+
uses: pypa/gh-action-pypi-publish@release/v1

.gitignore

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
pip-wheel-metadata/
24+
share/python-wheels/
25+
*.egg-info/
26+
.installed.cfg
27+
*.egg
28+
MANIFEST
29+
30+
# PyInstaller
31+
*.manifest
32+
*.spec
33+
34+
# Installer logs
35+
pip-log.txt
36+
pip-delete-this-directory.txt
37+
38+
# Unit test / coverage reports
39+
htmlcov/
40+
.tox/
41+
.nox/
42+
.coverage
43+
.coverage.*
44+
.cache
45+
nosetests.xml
46+
coverage.xml
47+
*.cover
48+
*.py,cover
49+
.hypothesis/
50+
.pytest_cache/
51+
52+
# Translations
53+
*.mo
54+
*.pot
55+
56+
# Environments
57+
.env
58+
.venv
59+
env/
60+
venv/
61+
ENV/
62+
env.bak/
63+
venv.bak/
64+
65+
# IDE
66+
.idea/
67+
.vscode/
68+
*.swp
69+
*.swo
70+
*~
71+
72+
# OS
73+
.DS_Store
74+
Thumbs.db
75+
76+
# Project specific
77+
*.log

FUNCTIONS.md

Lines changed: 262 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,262 @@
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

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)