Documentationcake

Our free API is easy to use and that includes helpful, concise documentation and complete examples provided in several popular programming languages.

Getting Started

Quick Example

Use the mls endpoint to request MLS data, e.g., cakemls.com/api/mls/. URL encoding GET parameters is required. Encoding POST parameters is optional.

Bash

                        # GET
curl https://cakemls.com/api/mls/?address=1340+Arbor+Rd%2C+Menlo+Park%2C+CA+94025  # url encoded

# POST
curl --data-urlencode "address=1340 Arbor Rd, Menlo Park, CA 94025" https://cakemls.com/api/mls/  # encoding optional
                      

HTTPS Encryption

All non-secure requests will be HTTPS re-directed.

Authentication

For requests that do require API key authentication, provide the api_key parameter and assign it your key string.

https://cakemls.com/api/geocode/address=2830+Aquarius+Ave%2C+Silver+Spring%2C+MD+20906&api_key=YOUR_API_KEY

JSONP Callbacks

The API supports JSONP. Append the callback parameter to your request and assign your function name to it. The API will return your API results wrapped in a function with the name you provided.

https://cakemls.com/api/geocode/address=722+E+Portland+St%2C+Phoenix%2C+AZ+85006&callback=myFunc
myFunc ({
  {
    "data": {.....}
  }
})
                    

API Errors

The below list outlines the error codes.

  • 200 - Ok. Request completed successfully.
  • 204 - Empty result. No MLS data could be found.
  • 206 - Partial result. Complete data could not be found but partial data was returned.
  • 401 - Unauthorized. You need to create an account and provide an api key for this type of request.
  • 404 - The given API endpoint does not exist.
  • 400 - Bad or malformed request.
  • 404 - The given API endpoint does not exist.
  • 407 - The given API endpoint does not exist.
  • 500 - A general server-side error occurred.
  • 503 - This particular endpoint is currently unavailable.

In the event your request returns with an error, the response will be the same format as a successful response except the data field will be emtpy and the error field will be non-empty.

{
  {
    "data": {},
    "error": {
      "errorCode": 500,
      "errorMessage": "Server-side error. Your request could not be completed."
    }
  }
}
                    

API Endpoints

Forward Geocoding

Use the geocode endpoint and provide the address parameter to convert an address to latitude/longitude coordinates.

https://cakemls.com/api/geocode/address=4240+E+Aquarius+Dr%2C+Tuscon%2C+AZ+85718 

Reverse Geocoding

Use the geocode endpoint and provide the location parameter to convert latitude/longitude coordinates to an address.

https://cakemls.com/api/geocode/location=40.127,-80.375&name=4240+E+Aquarius+Dr%2C+Tuscon%2C+AZ+85718 

Batch Requests

Batch requests may ONLY be sent via POST request. Use the address parameter for a single request. Use the adresses parameter for multiple/batch requests.

https://cakemls.com/api/geocode/
POST: {
  "addresses": [
    "1233 Bainbridge Dr, Nashville, TN 37211",
    "5066 12th Ave, Sacramento, CA 95820",
    "402 Wright St, Tuskegee, AL 36083"
  ]
}

Formatting

Use the format parameter to define the desired response format. The default is JSON.
The options are:

  • JSON
  • XML
  • GeoJSON

https://cakemls.com/api/forward/address=4240+E+Aquarius+Dr%2C+Tuscon%2C+AZ+85718&format=xml

If you found this API helpful, please consider donating to keep this service running. Donate


Code Examples

PHP

MLS Data

                          $query = http_build_query([
    'access_key' => 'YOUR_ACCESS_KEY',
    'address' => '705 W Red Bridge Rd, Kansas City, MO 64114',
    'format' => 'json',
  ]);

  $ch = curl_init(urlencode('https://mlsdata.com/api/mls/')));
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $query);

  $json = curl_exec($ch);

  curl_close($ch);

  $result = json_decode($json, true);

  print_r($result);
                          
                      

Forward Geocoding

                          $query = http_build_query([
  'access_key' => 'YOUR_ACCESS_KEY',
  'address' => '1322 N Grant Ave, Springfield, MO 65802',
  'format' => 'json',
]);

$ch = curl_init(urlencode('https://mlsdata.com/api/geocode/')));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $query);

$json = curl_exec($ch);

curl_close($ch);

$result = json_decode($json, true);

print_r($result);
                        
                      

Reverse Geocoding

                          $query = http_build_query([
  'access_key' => 'YOUR_ACCESS_KEY',
  'location' => '40.767,-120.505',
  'format' => 'json',
]);

$ch = curl_init(urlencode('https://mlsdata.com/api/geocode/')));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $query);

$json = curl_exec($ch);

curl_close($ch);

$result = json_decode($json, true);

print_r($result);
                          
                        

Python

MLS Data

                            import parse, http.client, urllib

conntn = http.client.HTTPConnection(‘https://mlsdata.com')

params = urllib.parse.urlencode({
    'access_key': 'YOUR_ACCESS_KEY',
    'address': '3066 Sultana Dr, Madera, CA 93637',
    ‘format’: ‘json’
    })

conn.request('GET', '/api/mls/?{}'.format(params))

resp = conntn.getresponse()
data = resp.read()

print(data.decode('utf-8'))
                            
                          

Forward Geocoding

                            import parse, http.client, urllib

conntn = http.client.HTTPConnection(‘https://mlsdata.com')

params = urllib.parse.urlencode({
    'access_key': 'YOUR_ACCESS_KEY',
    'address': '1658 Riverside, Atlantic City, NJ 08401',
    ‘format’: ‘json’
    })

conn.request('GET', '/api/geocode/?{}'.format(params))

resp = conntn.getresponse()
data = resp.read()

print(data.decode('utf-8'))
                          
                        

Reverse Geocoding

                            # Python 3
import parse, http.client, urllib

conntn = http.client.HTTPConnection(‘https://mlsdata.com')

params = urllib.parse.urlencode({
    'access_key': 'YOUR_ACCESS_KEY',
    'location': '39.098,-94.302',
    ‘format’: ‘json’,
    })

conn.request('GET', '/api/geocode/?{}'.format(params))

resp = conntn.getresponse()
data = resp.read()

print(data.decode('utf-8'))
                          
                        

Node.js

MLS Data

                            const axios = require('axios');
const params = {
  access_key: 'YOUR_ACCESS_KEY',
  address: '2809 Aiden Ct, College Park, GA 30337',
  format: ‘json’
}

axios.get('https://mlsdata.com/api/mls/', {params})
  .then(response => {
    console.log(response.data);
  }).catch(error => {
    console.log(error);
  });
                            
                          

Forward Geocoding

                            const axios = require('axios');
const params = {
  access_key: 'YOUR_ACCESS_KEY',
  address: '2818 18th St, Tuscaloosa, AL 35401',
  format: ‘json’
}

axios.get('https://mlsdata.com/api/geocode/', {params})
  .then(response => {
    console.log(response.data);
  }).catch(error => {
    console.log(error);
  });
                            
                          

Reverse Geocoding

                            const axios = require('axios');
const params = {
  access_key: 'YOUR_ACCESS_KEY',
  location: '42.765,-93.345',
  format: ‘json’
}

axios.get('https://mlsdata.com/api/geocode/', {params})
  .then(response => {
    console.log(response.data);
  }).catch(error => {
    console.log(error);
  });
                            
                          

jQuery

MLS Data

                            $.ajax({
  url: "https://cakemls.com/api/mls/",
  data: {
    address: "1146 E Long St, Columbus, OH 43203",
    access_key: "YOUR_ACCESS_KEY",
    format: "json"
  },
  success: function(response) {
    console.log("Ajax response: ", response);
  }
});
                            
                          

Forward Geocoding

                            $.ajax({
  url: "https://cakemls.com/api/geocode/",
  data: {
    address: "9352 Bronze River Ave, Las Vegas, NV 89149",
    access_key: "YOUR_ACCESS_KEY",
    format: "json"
  },
  success: function(response) {
    console.log("Ajax response: ", response);
  }
});
                            
                          

Reverse Geocoding

                            $.ajax({
  url: "https://cakemls.com/api/geocode/",
  data: {
    location: "40.4402,-80.9023",
    access_key: "YOUR_ACCESS_KEY",
    format: "json"
  },
  success: function(response) {
    console.log("Ajax response: ", response);
  }
});
                            
                          

Go/Golang

MLS Data

                            package main

import (
  "fmt"
  "io/ioutil"
  "net/http"
  "net/url"
)

func main() {
  baseURL, _ := url.Parse("https://mlsdata.com")

  baseURL.Path += "api/mls/"

  params := url.Values{}
  // Access Key
  params.Add("access_key", "YOUR_ACCESS_KEY")
  // Query
  params.Add("address", "5617 Malarkey Rd, Del Valle, TX 78617")
  // Optional parameters
  params.Add("format", "json")

  baseURL.RawQuery = params.Encode()

  req, _ := http.NewRequest("GET", baseURL.String(), nil)

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()

  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(string(body))
}
                            
                          

Forward Geocoding

                            package main

import (
  "fmt"
  "io/ioutil"
  "net/http"
  "net/url"
)

func main() {
  baseURL, _ := url.Parse("https://mlsdata.com")

  baseURL.Path += "api/geocode/"

  params := url.Values{}
  // Access Key
  params.Add("access_key", "YOUR_ACCESS_KEY")
  // Query
  params.Add("address", "1301 Trinidad Ave NE, Washington, DC 20002")
  // Optional parameters
  params.Add("format", "json")

  baseURL.RawQuery = params.Encode()

  req, _ := http.NewRequest("GET", baseURL.String(), nil)

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()

  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(string(body))
}
                            
                          

Reverse Geocoding

                            package main

import (
  "fmt"
  "io/ioutil"
  "net/http"
  "net/url"
)

func main() {
  baseURL, _ := url.Parse("https://mlsdata.com")

  baseURL.Path += "api/geocode/"

  params := url.Values{}
  // Access Key
  params.Add("access_key", "YOUR_ACCESS_KEY")
  // Query
  params.Add("location", "39.707,-110.472")
  // Optional parameters
  params.Add("format", "json")

  baseURL.RawQuery = params.Encode()

  req, _ := http.NewRequest("GET", baseURL.String(), nil)

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()

  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(string(body))
}
                            
                          

Ruby

MLS Data

                            require 'uri'
require 'net/http'

uri = URI('https://mlsdata.com/api/mls/')

params = {
    'access_key' => 'YOUR_ACCESS_KEY',
    'address' => '719 Fairview Ave NE, Grand Rapids, MI 49503',
    ‘format’: ‘json’
}

uri.query = URI.encode_www_form(params)

response = Net::HTTP.get_response(uri)

puts response.read_body

                            
                          

Forward Geocoding

                            require 'uri'
require 'net/http'

uri = URI('https://mlsdata.com/api/geocode/')

params = {
    'access_key' => 'YOUR_ACCESS_KEY',
    'address' => '11780 Gold Hill Rd, Boulder, CO 80302',
    ‘format’: ‘json’
}

uri.query = URI.encode_www_form(params)

response = Net::HTTP.get_response(uri)

puts response.read_body

                            
                          

Reverse Geocoding

                            require 'uri'
require 'net/http'

uri = URI('https://mlsdata.com/api/geocode/')

params = {
    'access_key' => 'YOUR_ACCESS_KEY',
    'location' => '39.202,-96.403',
    ‘format’: ‘json’
}

uri.query = URI.encode_www_form(params)

response = Net::HTTP.get_response(uri)

puts response.read_body

                            
                          

If you found this API helpful, please consider donating to keep this service running. Donate

Attribution