├── LICENSE ├── README.md ├── interactive-map-search └── index.html ├── javascript ├── README.md ├── ajax.js └── index.html ├── php ├── README.md └── simplyrets-example.php └── ruby ├── README.md └── example.rb /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010-2015 SimplyRETS, Inc. https://simplyrets.com 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SimplyRETS API Examples 2 | 3 | A collection of examples showcasing usage of the SimplyRETS API. 4 | SimplyRETS makes it easy to **build software using data from your 5 | MLS** or REALTORS association by normalizing any **RETS**, **IDX**, 6 | or **RESO WebAPI** feed into a [standardized JSON API made for real estate](https://docs.simplyrets.com). 7 | 8 | _NOTE: Looking for something plug-and-play? Check out the 9 | [SimplyRETS WordPress plugin](https://wordpress.org/plugins/simply-rets/)_ 10 | 11 | ## Getting Started 12 | 13 | The SimplyRETS API makes it easy to access your MLS's listing data from 14 | with any programming language. Below you'll find examples for getting started 15 | with some of the most common languages - if you don't see what you're looking 16 | for, [send us a message](https://simplyrets.com/#home-contact) and we'll be 17 | happy to help get you going. 18 | 19 | - [PHP](php/) 20 | - [Ruby](ruby/) 21 | - [JavaScript (ajax)](javascript/) 22 | - [JavaScript (ajax) - interactive map search](interactive-map-search/) 23 | 24 | ## Interactive map search 25 | 26 | The [interactive-map-search](interactive-map-search/) directory contains an 27 | example program for building a map-based search tool using Ajax, Leaflet, 28 | and OpenStreetMap. The test data is located in Houston. 29 | 30 | To run this example, download [`interactive-map-search/index.html`](interactive-map-search/index.html) 31 | and open it in your browser, or [visit the live version here](https://simplyrets.github.io/examples/interactive-map-search) 32 | 33 | ## More resources 34 | 35 | The SimplyRETS API can be accessed from and tool or language that can 36 | make HTTP requests. Use the examples in this repo to get started, or 37 | check out some of the other resources and documentation: 38 | 39 | - [API documentation and help topics](https://docs.simplyrets.com) 40 | - [Interactive API documentation](https://docs.simplyrets.com/api/index.html) 41 | - [Code snippets](https://simplyrets.com/#curl) 42 | -------------------------------------------------------------------------------- /interactive-map-search/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | SimplyRETS Map Search 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 73 | 74 | 75 | 76 |
77 | 78 | 79 | -------------------------------------------------------------------------------- /javascript/README.md: -------------------------------------------------------------------------------- 1 | # SimplyRETS JavaScript Examples 2 | 3 | ## AJAX 4 | You can use the SimplyRETS API on the client-side using AJAX. 5 | `ajax.js` contains an example of doing so. 6 | 7 | ### Running 8 | To run the AJAX example, simply open `index.html` in your browser 9 | of choice. 10 | 11 | `index.html` is just a static page, and it loads `ajax.js` 12 | -------------------------------------------------------------------------------- /javascript/ajax.js: -------------------------------------------------------------------------------- 1 | /* 2 | * AJAX Example - Making Requests to the SimplyRETS API 3 | */ 4 | 5 | 6 | // These are your API Credentials - base64 encode them in the 7 | // `Authorization` header. 8 | var auth = btoa("simplyrets:simplyrets"); 9 | 10 | function main() { 11 | $.ajax({ 12 | // make an AJAX request - this is the /properties endpoint 13 | url: "https://api.simplyrets.com/properties", 14 | type: 'GET', 15 | dataType: 'json', 16 | // authorize with the API credentials 17 | beforeSend: function(xhr) { 18 | xhr.setRequestHeader("Authorization", "Basic " + auth); 19 | }, 20 | success: function(res) { 21 | // res is the set of listings returned from the API 22 | // loop through them and print the address 23 | for(var i=0; i < res.length; i++) { 24 | $("#app").append("

" + res[i].address.full + "

"); 25 | } 26 | } 27 | }); 28 | } 29 | 30 | main(); 31 | -------------------------------------------------------------------------------- /javascript/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | SimplyRETS Example 8 | 9 | 10 |

SimplyRETS API Request with AJAX

11 |
12 | 13 | 14 | -------------------------------------------------------------------------------- /php/README.md: -------------------------------------------------------------------------------- 1 | SimplyRETS API example - PHP 2 | ========== 3 | 4 | The [simplyrets-example.php](simplyrets-example.php) file contains a sample 5 | program for making requests to the SimplyRETS API from php. Read through 6 | the comments in the code to learn how it works. 7 | 8 | [**Try it out on phpfiddle.org**](http://phpfiddle.org/) 9 | 10 | _NOTE: This example requires `curl` to be installed on the server._ 11 | 12 | --- 13 | SimplyRETS - Copyright (c) 2015 - present 14 | 15 | [support@simplyrets.com](https://simplyrets.com/#home-contact) · 16 | [https://simplyrets.com](https://simplyrets.com) 17 | -------------------------------------------------------------------------------- /php/simplyrets-example.php: -------------------------------------------------------------------------------- 1 | "https://api.simplyrets.com/properties", 8 | CURLOPT_RETURNTRANSFER => true, 9 | CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, 10 | CURLOPT_CUSTOMREQUEST => "GET", 11 | CURLOPT_HTTPHEADER => 12 | array( 13 | "Authorization: Basic '" . base64_encode('simplyrets:simplyrets') . "'", 14 | ), 15 | )); 16 | 17 | /** 18 | * 1. Execute the request 19 | * 2. Check for errors 20 | * 3. Close the connection 21 | */ 22 | $response = curl_exec($curl); 23 | $err = curl_error($curl); 24 | curl_close($curl); 25 | 26 | if ($err) { 27 | echo "cURL Error #:" . $err; 28 | } 29 | 30 | /** Decode JSON response - this is a list of listings */ 31 | $json_response = json_decode($response); 32 | 33 | /** Print address and list price of the first listing */ 34 | echo "

" . $json_response[0]->address->full . "

"; 35 | echo "

List price: " . $json_response[0]->listPrice . "

"; 36 | 37 | ?> 38 | -------------------------------------------------------------------------------- /ruby/README.md: -------------------------------------------------------------------------------- 1 | example.rb 2 | ========== 3 | 4 | See the comments in example.rb for a walk-through. 5 | 6 | ## Running 7 | 8 | $ ruby example.rb 9 | 10 | -- 11 | SimplyRETS, Inc - Copyright (c) 2015 12 | support@simplyrets.com - https://simplyrets.com 13 | -------------------------------------------------------------------------------- /ruby/example.rb: -------------------------------------------------------------------------------- 1 | # example.rb - Accessing the SimplyRETS API via Ruby 2 | # SimplyRETS, Inc - Copyright (c) 2015 3 | 4 | require "net/http" 5 | require "uri" 6 | require "json" 7 | 8 | ## Define our API Endpoint and settings. Since the API is 9 | ## over HTTPS we set use_ssl to true. 10 | 11 | uri = URI.parse("https://api.simplyrets.com/properties") 12 | http = Net::HTTP.new(uri.host, uri.port) 13 | http.use_ssl = true 14 | 15 | ## Make the request. The API uses Basic Authorization for authentication with 16 | ## the API. Put your API Key/Secret there. 17 | 18 | request = Net::HTTP::Get.new(uri.request_uri) 19 | request.basic_auth("simplyrets", "simplyrets") 20 | response = http.request(request) 21 | 22 | ## The response body, which contains the listings, is not held in response.body. 23 | ## We parse the JSON response into `listings`. Then we iterate over each listing 24 | ## to get the information we need. 25 | 26 | listings = JSON.parse(response.body) 27 | 28 | listings.each do |listing| 29 | puts listing['address']['full'] 30 | end 31 | --------------------------------------------------------------------------------