Examples

cURL

Forward Geocoding
curl https://zip.getziptastic.com/v3/US/48867 -H "x-key: 123examplekey456"
Reverse Geocoding
curl https://zip.getziptastic.com/v3/reverse/43.00/-84.17/5000 -H "x-key: 123examplekey456"

jQuery

Forward Geocoding
$.ajax({
  type: "GET",
  beforeSend: function(request) {
    request.setRequestHeader("x-key", "123examplekey456");
  },
  url: "//zip.getziptastic.com/v3/US/48867",
  success: function(data) {
    console.log(data);
  }
});
Reverse Geocoding
var success = function(position) {
    var API_URL = '//zip.getziptastic.com/v3/reverse/';
    $.ajax({
        url: API_URL + position.coords.latitude + '/' + position.coords.longitude,
        type: 'GET',
        dataType: 'json',
        beforeSend: setHeader
    }).done(function(data) {
        console.log(data);
    });

    function setHeader(xhr) {
        xhr.setRequestHeader('x-key', '123examplekey456');
    }
  }

  var error = function(e) {
    console.log(e);
  }

  // Check to see if browser supports geolocation.
  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(success, error);
  } else {
    error('not supported');
  }

PHP

Forward Geocoding
$opts = array(
    'http'=>array(
        'method'=>"GET",
        'header'=>"x-key: 123examplekey456\r\n"
    )
);

$context = stream_context_create($opts);
$result = file_get_contents('https://zip.getziptastic.com/v3/US/48867', false, $context);
Reverse Geocoding
$opts = array(
    'http'=>array(
        'method'=>"GET",
        'header'=>"x-key: 123examplekey456\r\n"
    )
);

$latitude = "42.9934";
$longitude = "-84.1595";

$context = stream_context_create($opts);
// file_get_contents() is used for maximum compatibility in this example.
// I highly recommend not using this in production.
// Use something like this instead http://php.net/manual/en/function.http-get.php
$result = file_get_contents('https://zip.getziptastic.com/v3/reverse/' + $latitude + '/' + $longitude, false, $context);

Python

Forward Geocoding
import urllib2
headers = {
    "x-key" : "123examplekey456"
}
url = "https://zip.getziptastic.com/v3/US/48867"

request = urllib2.Request(url, headers=headers)
contents = urllib2.urlopen(request).read()
Reverse Geocoding
import urllib2
headers = {
    "x-key" : "123examplekey456"
}
latitude = "42.9934"
longitude = "-84.1595"
url = "https://zip.getziptastic.com/v3/reverse/%s/%s" % (latitude, longitude)

request = urllib2.Request(url, headers=headers)
contents = urllib2.urlopen(request).read()

NodeJs

Forward Geocoding
var request = require('request');

var headers = {
    'x-key': '123examplekey456'
}

var options = {
    url: 'https://zip.getziptastic.com/v3/US/48867',
    method: 'GET',
    headers: headers
}

request(options, function (error, response, body) {
    if (!error && response.statusCode == 200) {
        console.log(body)
    }
})
Reverse Geocoding
var request = require('request');

var headers = {
    'x-key': '123examplekey456'
}

var options = {
    url: 'https://zip.getziptastic.com/v3/reverse/42.9934/-84.1595',
    method: 'GET',
    headers: headers
}

request(options, function (error, response, body) {
    if (!error && response.statusCode == 200) {
        console.log(body)
    }
})

Ruby

Forward Geocoding
require "net/http"
require "uri"

url = URI.parse("https://zip.getziptastic.com/v3/US/48867")

req = Net::HTTP::Get.new(url.path)
req.add_field("X-key", "123examplekey456")

res = Net::HTTP.new(url.host, url.port).start do |http|
  http.request(req)
end

puts res.body
Reverse Geocoding
require "net/http"
require "uri"

url = URI.parse("https://zip.getziptastic.com/v3/reverse/42.9934/-84.1595")

req = Net::HTTP::Get.new(url.path)
req.add_field("X-key", "123examplekey456")

res = Net::HTTP.new(url.host, url.port).start do |http|
  http.request(req)
end

puts res.body