# Java SDK for Fireblocks

**URL:** <https://community.fireblocks.com/t/java-sdk-for-fireblocks/98>\
**Category:** Developer Discussion\
**Tags:** getting-started\
**Created:** [March 14, 2023, 2:32pm UTC](https://community.fireblocks.com/t/java-sdk-for-fireblocks/98 "2023-03-14T14:32:49Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![moza](https://avatars.discourse-cdn.com/v4/letter/m/edb3f5/32.png) [@moza](https://community.fireblocks.com/u/moza)\
**Post date:** [March 14, 2023, 2:32pm UTC](https://community.fireblocks.com/t/java-sdk-for-fireblocks/98/1 "2023-03-14T14:32:49Z")

</div>

Hi,

I need a java SDK, does anyone know of a good open source java sdk project for Fireblocks?

---

<div class="post-metadata">

**Author:** ![alec](https://sea1.discourse-cdn.com/flex015/user_avatar/community.fireblocks.com/alec/32/112_2.png) [@alec](https://community.fireblocks.com/u/alec)\
**Post date:** [March 14, 2023, 2:42pm UTC](https://community.fireblocks.com/t/java-sdk-for-fireblocks/98/2 "2023-03-14T14:42:49Z")

</div>

Hi @moza !

There is no official Java SDK for Fireblocks, but you can find instructions and examples for working with the Fireblocks API in Java here: [Java Guide](https://developers.fireblocks.com/docs/java-guide).

You can also check out [this repository](https://github.com/andyflury/fireblocks-java-api), although it is a bit outdated and is not maintained by Fireblocks.

---

<div class="post-metadata">

**Author:** ![alec](https://sea1.discourse-cdn.com/flex015/user_avatar/community.fireblocks.com/alec/32/112_2.png) [@alec](https://community.fireblocks.com/u/alec)\
**Post date:** [March 14, 2023, 3:04pm UTC](https://community.fireblocks.com/t/java-sdk-for-fireblocks/98/3 "2023-03-14T15:04:52Z")

</div>

Another available option is to use [https://editor.swagger.io/](https://editor.swagger.io/). You can paste in the [Fireblocks OpenAPI 3.0 spec](https://docs.fireblocks.com/api/v1/swagger), then select Generate Client \> Java. This will generate and download a custom SDK based on the spec. Please note that Fireblocks can only guarantee the correctness of the spec, and not any specific correctness or functionality of the SDK that Swagger creates.

---

<div class="post-metadata">

**Author:** ![oyomtov](https://avatars.discourse-cdn.com/v4/letter/o/ad7895/32.png) [@oyomtov](https://community.fireblocks.com/u/oyomtov)\
**Post date:** [March 15, 2023, 12:46pm UTC](https://community.fireblocks.com/t/java-sdk-for-fireblocks/98/4 "2023-03-15T12:46:43Z")

</div>

Hey @moza ! Is this for working mainly with EVM blockchains?

If so, you might want to give the `fireblocks-json-rpc` project a try together with web3j

> **[GitHub - fireblocks/fireblocks-json-rpc](https://github.com/fireblocks/fireblocks-json-rpc)**
>
> Contribute to fireblocks/fireblocks-json-rpc development by creating an account on GitHub.

> **[Web3 Labs Web3j](https://docs.web3j.io/4.9.7/)**
>
> Develop on Ethereum with the JVM. Web3j makes it easy to build Ethereum applications with Java and Android.

---

<div class="post-metadata">

**Author:** ![moza](https://avatars.discourse-cdn.com/v4/letter/m/edb3f5/32.png) [@moza](https://community.fireblocks.com/u/moza)\
**Post date:** [March 22, 2023, 6:15pm UTC](https://community.fireblocks.com/t/java-sdk-for-fireblocks/98/5 "2023-03-22T18:15:04Z")

</div>

Thank you Alec so I am going off of this project called proximax ([GitHub - proximax-storage/java-xpx-chain-sdk: ProximaX Sirius-Chain Java SDK](https://github.com/proximax-storage/java-xpx-chain-sdk)), they create and maintain their SDK using openApiGenerate. Using openApiGenerate I was able to generate all my java SDK code. Now I am stuck on something obvious, I generated a APIClient that takes in a x-API-Key and bearerTokenAuth. I can’t figure what field should I use for the API token and which one I should use for the secret key generated with the cert. Here is the code that’s requesting it ` authentications.put("ApiKeyAuth", new ApiKeyAuth("header", "X-API-Key")); authentications.put("bearerTokenAuth", new HttpBearerAuth("bearer"));`

---

<div class="post-metadata">

**Author:** ![alec](https://sea1.discourse-cdn.com/flex015/user_avatar/community.fireblocks.com/alec/32/112_2.png) [@alec](https://community.fireblocks.com/u/alec)\
**Post date:** [March 22, 2023, 8:06pm UTC](https://community.fireblocks.com/t/java-sdk-for-fireblocks/98/6 "2023-03-22T20:06:29Z")

</div>

Hi @moza -

If you have created an [API User](https://developers.fireblocks.com/docs/quickstart#api-user-creation) in Fireblocks, you can copy the API key in the Fireblocks Console. This is the “X-API-Key”. The bearer auth token is a JWT requiring fields that are described [here](https://docs.fireblocks.com/api/#jwt-structure). You can check out example in the Java Guide I sent above to see how we build and sign the JWT.

---

<div class="post-metadata">

**Author:** ![moza](https://avatars.discourse-cdn.com/v4/letter/m/edb3f5/32.png) [@moza](https://community.fireblocks.com/u/moza)\
**Post date:** [May 10, 2023, 4:34pm UTC](https://community.fireblocks.com/t/java-sdk-for-fireblocks/98/7 "2023-05-10T16:34:29Z")

</div>

Thank you! After debugging through the generated code, we found that there is ApiClient class that you need to use to authenticate to Fireblocks. The ApiClient is annoying because it has setBearerToken and setAPIKey methods, those are pretty useless. Instead we had to use the addDefaultHeaders method and pass the API key and bearer token. Here is example code in setting that up.

```auto
  /** Setting up the ApiClient */
  public void initializeApiClient() {

    // apiClient = new ApiClient(restTemplate);

    // Setting the ApiKey
    apiClient.setApiKey(apiKey);
    apiClient.addDefaultHeader("X-API-Key", apiKey);
  }

  public void setJWT(String path) {
    // Setting the Auth Bearer JWT Token
    String privateKeyPem = readPrivateKeyFromFile(secretKeyPath);
    JwtTokenGenerator jwtTokenGenerator = new JwtTokenGenerator(apiKey, privateKeyPem);
    String jwtToken = jwtTokenGenerator.generateJwtTokenForGet(path);
    apiClient.addDefaultHeader("Authorization", "Bearer " + jwtToken);
    apiClient.setBearerToken(jwtToken);
  }

```

---

<div class="post-metadata">

**Author:** ![pavel.niedoba](https://avatars.discourse-cdn.com/v4/letter/p/b5ac83/32.png) [@pavel.niedoba](https://community.fireblocks.com/u/pavel.niedoba)\
**Post date:** [May 30, 2024, 8:24am UTC](https://community.fireblocks.com/t/java-sdk-for-fireblocks/98/8 "2024-05-30T08:24:21Z")

</div>

There is official sdk now [GitHub - fireblocks/java-sdk](https://github.com/fireblocks/java-sdk), it’s little outdated, but usable.
