Skip to content

Instantly share code, notes, and snippets.

@caulinez
Created May 31, 2018 05:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save caulinez/84077125f49a489195e169a9359fa285 to your computer and use it in GitHub Desktop.
Save caulinez/84077125f49a489195e169a9359fa285 to your computer and use it in GitHub Desktop.
Gemini Sample Connection in Java using Closeable HTTP
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.dotcomculture.arbbot;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.CloseableHttpResponse;
public class ArbBot {
public static void main(String [ ] args)throws Exception{
System.out.println("I am in main" );
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost("https://api.sandbox.gemini.com/v1/balances");
httpPost.setHeader("Content-type", "text/plain");
//httpPost.setHeader("Content-Length", "0");
httpPost.setHeader("X-GEMINI-APIKEY", "Your API Key Here");
httpPost.setHeader("X-GEMINI-PAYLOAD", "Gemini Payload here");
httpPost.setHeader("X-GEMINI-SIGNATURE", "Gemini Signature here");
httpPost.setHeader("Cache-Control", "0");
CloseableHttpResponse closeableHttpResponse = httpClient.execute(httpPost);
int statusCode = closeableHttpResponse.getStatusLine().getStatusCode();
System.out.println("Status Code : " +statusCode );
}
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.dotcomculture</groupId>
<artifactId>ArbBot</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.9</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.json/json -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20180130</version>
</dependency>
</dependencies>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment