Untitled
unknown
java
2 years ago
1.3 kB
6
Indexable
package org.example; import okhttp3.MediaType; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.Response; import java.io.IOException; public class BitqueryWebsocketClient { public static void main(String[] args) { try { OkHttpClient client = new OkHttpClient().newBuilder().build(); MediaType mediaType = MediaType.parse("application/json"); String utf8EncodedJsonPayload = "{\"query\":\"query getNewBlock { EVM(network: eth) { Blocks(limit: {count: 1}) { Block { Number Time } } } }\",\"variables\":{}}"; RequestBody body = RequestBody.create(mediaType, utf8EncodedJsonPayload); Request request = new Request.Builder() .url("https://streaming.bitquery.io/graphql") .method("POST", body) .addHeader("Content-Type", "application/json") .addHeader("X-API-KEY", "********************") .build(); Response response = client.newCall(request).execute(); // Print the response body System.out.println(response.body().string()); } catch (IOException e) { e.printStackTrace(); } } }
Editor is loading...
Leave a Comment