Income by Location API

You can see pricing and an interactive version of this documentation on Mashape!

Documentation

This page is going to walk you through how to get your app or site set up with Mazon IO's Income by Location API. This page will show some very basic integrations with .NET, Objective-C, Python, PHP, Ruby, and Node, but the API is language and framework agnostic: it returns JSON, so any programming environment with a JSON library can use the Income by Location API. This page assumes you've created a Mashape account and have subscribed to our api and thereby have an API key to make requests.

So step 1 is to go and subscribe to our api:
Mashape

Below are some examples to get you started:


Making your first request
Making a request with the Income by Location API is pretty simple. Here is a sample curl request via the Unix command line:
curl --get --include 'https://income.p.mashape.com/api/income/{ip_address}' \
  -H 'X-Mashape-Key: {your_mashape_key}' \
  -H 'Accept: application/json'
That should return a JSON object that depending on the fields you have selected looks something like this:
{
  "city": "Minneapolis",
  "county": "Hennepin",
  "income": 64490,
  "state": "Minnesota"
}
Simple.
Calling the API using .NET

// These code snippets use an open-source library. http://unirest.io/net
Task<HttpResponse<MyClass>> response = Unirest.get("https://income.p.mashape.com/api/income/{ip_address}")
.header("X-Mashape-Key", "{your_mashape_key}")
.header("Accept", "application/json")
.asJson();


Calling the API using Python

Doing some data analysis on your userbase? Below is a snippet of python code calling the api. You could also use urllib2 or requests, but unirest gives us a common interface across multiple languages to build these example calls.

# These code snippets use an open-source library. http://unirest.io/python
response = unirest.get("https://income.p.mashape.com/api/income/{ip_address}",
  headers={
    "X-Mashape-Key": "{your_mashape_key}",
    "Accept": "application/json"
  }
)


Calling the API using Objective-C

Building an iPhone app? Below is a snippet to get you started.

// These code snippets use an open-source library. http://unirest.io/objective-c
NSDictionary *headers = @{@"X-Mashape-Key": @"{your_mashape_key}", @"Accept": @"application/json"};
UNIUrlConnection *asyncConnection = [[UNIRest get:^(UNISimpleRequest *request) {
  [request setUrl:@"https://income.p.mashape.com/api/income/{ip_address}"];
  [request setHeaders:headers];
}] asJsonAsync:^(UNIHTTPJsonResponse *response, NSError *error) {
  NSInteger code = response.code;
  NSDictionary *responseHeaders = response.headers;
  UNIJsonNode *body = response.body;
  NSData *rawBody = response.rawBody;
}];


Calling the API using Ruby

# These code snippets use an open-source library. http://unirest.io/ruby
response = Unirest.get "https://income.p.mashape.com/api/income/{ip_address}",
  headers:{
    "X-Mashape-Key" => "{your_mashape_key}",
    "Accept" => "application/json"
  }


Calling the API using NodeJS
// These code snippets use an open-source library. http://unirest.io/nodejs
unirest.get("https://income.p.mashape.com/api/income/{ip_address}")
.header("X-Mashape-Key", "{your_mashape_key}")
.header("Accept", "application/json")
.end(function (result) {
  console.log(result.status, result.headers, result.body);
});


Calling the API using Java

// These code snippets use an open-source library. http://unirest.io/java
HttpResponse<JsonNode> response = Unirest.get("https://income.p.mashape.com/api/income/{ip_address}")
.header("X-Mashape-Key", "{your_mashape_key}")
.header("Accept", "application/json")
.asJson();


Calling the API using PHP

// These code snippets use an open-source library. http://unirest.io/php
$response = Unirest\Request::get("https://income.p.mashape.com/api/income/{ip_address}",
  array(
    "X-Mashape-Key" => "{your_mashape_key}",
    "Accept" => "application/json"
  )
);