import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
public class Main {
public static void main(String[] args) {
try {
String myKey = "insert your server key here";
URL url = new URL("https://gender-api.com/get?key=" + myKey + "&name=markus");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
if (conn.getResponseCode() != 200) {
throw new RuntimeException("Error: " + conn.getResponseCode());
}
InputStreamReader input = new InputStreamReader(conn.getInputStream());
BufferedReader reader = new BufferedReader(input);
Gson gson = new Gson();
JsonObject json = gson.fromJson(reader, JsonObject.class);
String gender = json.get("gender").getAsString();
System.out.println("Gender: " + gender);
conn.disconnect();
} catch (IOException e) {
e.printStackTrace();
}
}
}