How to properly use api

I’m trying to access the api for geocoding conversion. I’ve received an api key and used the following http:// web browser request and seen that it works great:

where my_zip and my_api_key are replaced with the appropriate values.

I’m having trouble getting the appropriate Arduino sequence of client prints.

The documentation says:

The base API url is

You can also use Geocodio over plain HTTP, but it’s not recommended.

All HTTP responses (including errors) are returned with JSON-formatted output.

I’ve tried the following:
if ( WiFi.status() == WL_CONNECTED) {

if (client.connect({46,4,34,210}, 80)) {
Serial.println(“connected to server”);
// Make a HTTP request:
client.println(“GET /v1/geocode?q=my_zip&fields=timezone&api_key=my_api_key HTTP/1.1”);
client.println(“User-Agent: me@my_address”);
client.println(“Accept: application/json”);
client.println(“Connection: close”);
Serial.println(“Done with client.println routine calls for”);
latlon_requested = true;
latlon_attempted_reads = 0;
else {
Serial.println(“Failed to connect to server!”);
latlon_timeout = true;

I’ve got the ip address (retrieved from nslookup), because when I put there, it wouldn’t connect. When I do calls, I end up seeing text like this:

HTTP/1.1 400 Bad Request
Server: nginx/1.6.2
Date: Tue, 07 Jun 2016 01:36:05 GMT
Content-Type: text/html
Content-Length: 172
Connection: close

400 Bad Request

400 Bad Request

nginx/1.6.2 ---------------------------------------------

I get the feeling I’m not actually talking to the api engine. Is it clear from the web browser line (that does work) how to put together the Arduino sequence?



Hi there,

Mathias from here. Exciting to see that you're using with an Arduino!

It looks like you are hitting the server, but that an unexpected HTTP header was set.

It looks like this could be the culprit:

should be changed to (removing the forward slash):

I noticed that you are using the IP address directly, which is fine for now. But please note that it could potentially change in the future.

Currently we have two load balancers, located at and

Another thing I wanted to mention is to make sure to url encode the "q" query parameter if you are going to pass anything else than zip codes.

Feel free to reach out in our online chat on as well, and I'll be happy to help out.


Feel free to reach out in our online chat on as well, and I'll be happy to help out.

It's good to see someone actually support a product that they want people to use.