Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
com.after_sunrise.cryptocurrency:bitflyer4j
Advanced tools
Java wrapper library for the bitFlyer Lightning API.
bitflyer4j (bitFlyer for Java) is a Java wrapper library for the bitFlyer Lightning API.
bitFlyer is a crytocurrency exchange based in Japan, offering JSON+REST API just like many of the other bitcoin and altcoin exchanges. This library aims to capsulize the raw message formats and protocols, and provide a strictly-typed API library in addition to the handy features.
java.util.concurrent.CompletableFuture
for background message queueing/throttling and method chaining.Use Maven or Gradle to automatically fetch the library jars and its dependencies from The Central Repository.
pom.xml
)<dependency>
<groupId>com.after_sunrise.cryptocurrency</groupId>
<artifactId>bitflyer4j</artifactId>
<version>${VERSION}</version>
</dependency>
Copy and paste the following code snippets into the main
and execute.
Query for the latest tick data (price/size for best-bid/ask/last, accumulated volume, etc).
public class QueryTickSample {
public static void main(String[] args) throws Exception {
Bitflyer4j api = new Bitflyer4jFactory().createInstance();
Tick.Request request = Tick.Request.builder().product("ETH_BTC").build();
System.out.println(api.getMarketService().getTick(request).get());
api.close();
}
}
Send a new order. Note that this is for the "Child Order" in bitFlyer's terminology.
public class SendOrderSample {
public static void main(String[] args) throws Exception {
Bitflyer4j api = new Bitflyer4jFactory().createInstance();
OrderCreate.Request request = OrderCreate.Request.builder()
.product("FX_BTC_JPY").type(ConditionType.LIMIT).side(SideType.BUY)
.price(new BigDecimal("12345.6789")).size(BigDecimal.ONE).build();
System.out.println(api.getOrderService().sendOrder(request).get());
api.close();
}
}
Cancel an existing order. Specify either one of the order id or the acceptance id.
public class CancelOrderSample {
public static void main(String[] args) throws Exception {
Bitflyer4j api = new Bitflyer4jFactory().createInstance();
OrderCancel.Request request = OrderCancel.Request.builder()
.product("BTCJPY_MAT1WK").orderId("JOR20150707-055555-022222").build();
System.out.println(api.getOrderService().cancelOrder(request).get());
api.close();
}
}
Initiate a subscription for the steaming market data. (Automatic reconnect with subscription recovery upon unsolicited disconnect.)
public class RealtimeSample {
public static void main(String[] args) throws Exception {
Bitflyer4j api = new Bitflyer4jFactory().createInstance();
api.getRealtimeService().addListener(new RealtimeListenerAdapter() {
@Override
public void onTicks(String product, List<Tick> values) {
System.out.println("(" + product + ")" + values);
}
});
System.out.println(api.getRealtimeService().subscribeTick(Arrays.asList("BTC_JPY")).get());
TimeUnit.SECONDS.sleep(30L);
api.close();
}
}
For the full list of supported features and sample codes, please refer to Bitflyer4jTest.
Below are some of the features and configurations available, which may be useful for specific use cases and executing environments.
In order to use the Private API, specify the following properties in the environment variables and/or the configuration files:
bitflyer4j.auth_key
bitflyer4j.auth_secret
When the API library is initialized, it will try to search these properties in the following priority:
java -Dbitflyer4j.auth_key=... -Dbitflyer4j.auth_secret=...
)${HOME}/.bitflyer4j
properties file.bitflyer4j-site.properties
file in the classpath.The library will scan from the top of the list, skipping the ones which are not available/accessible, and will use the first one found per variable.
Note that Confidential parameters shall only be stored privately,
preferably by using the local ${HOME}/.bitflyer4j
properties
file. DO NOT COMMIT, LOG, NOR DISSEMINATE THE CREDENTIALS.
# Authentication
bitflyer4j.auth_key=MY_KEY_HERE
bitflyer4j.auth_secret=MY_SECRET_HERE
A template of the .bitflyer4j
file can be downloaded from
here.
In case if this library is to be used behind a network proxy, specify the following environment variables. The variables are fetched by the library in the same manner, as described previously in the authentication section.
# HTTP Proxy
bitflyer4j.http_proxy_type=HTTP
bitflyer4j.http_proxy_host=127.0.0.1
bitflyer4j.http_proxy_port=8080
bitFlyer limits the number of HTTP requests allowed per interval.
In this library, each HTTP calls are queued first, and a background thread takes them out of the queue,
with a throttling mechanism to avoid DOS-attacking the service and comply with the limit. Therefore,
each HTTP calls are designed to return a java.util.concurrent.CompletableFuture
instance,
which is completed only after the HTTP request has been actually executed by the background thread.
To make these asynchronous HTTP calls synchronous, simply call the CompletableFuture#get()
method.
Although there should be no need to overwrite the default configurations, the following parameters are externalized and can be overwritten by the environment variables. For the complete list of configurable parameters and details, refer to the KeyType javadoc.
Property Key | Default Value | Description |
---|---|---|
bitflyer4j.site | local | Optional free-text label to identify the environment which the client app is running. |
bitflyer4j.auth_key | Authentication key for the private API. | |
bitflyer4j.auth_secret | Authentication secret for the private API. | |
bitflyer4j.http_url | https://api.bitflyer.jp | Endpoint URL of the service. |
bitflyer4j.http_proxy_type | Proxy type (DIRECT/HTTP/SOCKS) used for HTTP calls. Leave empty to disable proxy. | |
bitflyer4j.http_proxy_host | Address of the proxy server. Proxy type must be specified for the proxy enablement. | |
bitflyer4j.http_proxy_port | Port of the proxy server. Proxy type must be specified for the proxy enablement. | |
bitflyer4j.http_timeout | 180000 | HTTP socket/read timeout interval in millis. Leave empty for no timeout. |
bitflyer4j.http_threads | 8 | HTTP threads to utilize for HTTP access. |
bitflyer4j.http_limit_interval | 300000 | HTTP access throttling interval in millis. |
bitflyer4j.http_limit_criteria_address | 500 | Number of allowed HTTP access for a single source IP, within the throttling interval. |
bitflyer4j.http_limit_criteria_private | 500 | Number of allowed HTTP access for private API calls, within the throttling interval. |
bitflyer4j.realtime_type | Implementaion type to utilize for realtime subcription. | |
bitflyer4j.socket_endpoint | https://io.lightstream.bitflyer.com | Endpoint URL of the Socket.IO. |
Currently implemented API endpoint paths are as follows:
/v1/markets
/v1/markets/usa
/v1/markets/eu
/v1/board
/v1/ticker
/v1/executions
/v1/getchats
/v1/getchats/usa
/v1/getchats/eu
/v1/gethealth
/v1/getboardstate
/v1/me/getpermissions
/v1/me/getbalance
/v1/me/getcollateral
/v1/me/getcollateralaccounts
/v1/me/getaddresses
/v1/me/getcoinins
/v1/me/getcoinouts
/v1/me/getbankaccounts
/v1/me/getdeposits
/v1/me/getwithdrawals
/v1/me/withdraw
/v1/me/sendchildorder
/v1/me/cancelchildorder
/v1/me/sendparentorder
/v1/me/cancelparentorder
/v1/me/cancelallchildorders
/v1/me/getchildorders
/v1/me/getparentorders
/v1/me/getparentorder
/v1/me/getexecutions
/v1/me/getpositions
/v1/me/getcollateralhistory
/v1/me/gettradingcommission
lightning_board_*
lightning_board_snapshot_*
lightning_ticker_*
lightning_executions_*
FAQs
Java wrapper library for the bitFlyer Lightning API.
We found that com.after_sunrise.cryptocurrency:bitflyer4j demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.