-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCryptoExample.java
More file actions
50 lines (39 loc) · 1.54 KB
/
CryptoExample.java
File metadata and controls
50 lines (39 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
* FCS API - Crypto Example
* Get your API key at: https://fcsapi.com
*
* This example only uses the Crypto module (FcsCrypto)
* Other modules (Forex, Stock) are not loaded
*
* Run: javac -cp ".:../../lib/*" CryptoExample.java && java -cp ".:../../lib/*" CryptoExample
*/
package examples;
import com.fcsapi.FcsApi;
import com.fcsapi.FcsCrypto;
import java.util.Map;
public class CryptoExample {
public static void main(String[] args) {
// Initialize API - only Crypto module will be used
FcsApi fcsapi = new FcsApi();
// Access only Crypto module
FcsCrypto crypto = fcsapi.getCrypto();
System.out.println("=== Symbols List ===\n");
Map<String, Object> result = crypto.getSymbolsList("crypto", null, "BINANCE");
System.out.println(result);
System.out.println("\n\n=== Latest Price ===\n");
result = crypto.getLatestPrice("BINANCE:BTCUSDT");
System.out.println(result);
System.out.println("\n\n=== Historical Data ===\n");
result = crypto.getHistory("BINANCE:BTCUSDT", "1D", 5);
System.out.println(result);
System.out.println("\n\n=== Profile ===\n");
result = crypto.getProfile("BTC");
System.out.println(result);
System.out.println("\n\n=== Top by Market Cap ===\n");
result = crypto.getTopByMarketCap(10);
System.out.println(result);
System.out.println("\n\n=== Convert 1 BTC to USD ===\n");
result = crypto.convert("BTC", "USD", 1);
System.out.println(result);
}
}