Skip to content
Advertisement

How do I parse the realtor api data to show property data (Realtor API/Rapid)?

’m trying to parse the response data to view property data. However, I searched through all the properties in the response data but none seemed to hold property data. For anybody who isn’t familiar with realtor API this is the site I’m talking about. The data shows the exact way I want to receive mine https://rapidapi.com/apidojo/api/realtor/endpoints

 fetch("https://realtor.p.rapidapi.com/properties/v2/list-for-rent?sort=relevance&city=New%20York%20City&state_code=NY&limit=200&offset=0", {
  "method": "GET",
  "headers": {
    "x-rapidapi-host": "realtor.p.rapidapi.com",
    "x-rapidapi-key": "e5b0286ea4msh1d616284115d5efp16cadcjsn0392ca0398ac"
  }
})
.then(response => {
  console.log(response.json());
})
.catch(err => {
  console.log(err);
});

Advertisement

Answer

I was able to use Postman and test this endpoint and found that you likely need to be looking for the properties array and loop through the objects and sub-arrays/objects contained in each parent object of the properties array to get to the details about each property.

Inside of this array are objects that contain the address, latitude, longitude, etc.

I would recommend using Postman if you are not already, doing a GET request when doing so and using the same headers. You should see the same. Using Postman is a great way to test endpoints!

Here is an example of the data that is returned from the results inside of the properties array when hitting your endpoint with a GET request:

 "properties": [
...
...
        {
            "property_id": "R3188507190",
            "listing_id": "612930061",
            "prop_type": "apartment",
            "list_date": "2018-08-20T17:22:00.000Z",
            "last_update": "2020-08-25T08:17:00.000Z",
            "year_built": 2018,
            "listing_status": "active",
            "beds": 0,
            "prop_status": "for_rent",
            "address": {
                "city": "Arverne",
                "country": "USA",
                "county": "Queens",
                "lat": 40.589922,
                "line": "190 Beach 69th St",
                "postal_code": "11692",
                "state_code": "NY",
                "state": "New York",
                "time_zone": "America/New_York",
                "neighborhood_name": "Rockaway Peninsula",
                "neighborhoods": [
                    {
                        "id": "8c06e34c-3044-5621-aea4-b59d9ddde719",
                        "level": "macro_neighborhood",
                        "name": "Rockaway Peninsula"
                    }
                ],
                "lon": -73.79765
            },
            "client_display_flags": {
                "presentation_status": "for_rent",
                "is_showcase": true,
                "lead_form_phone_required": true,
                "price_change": 0,
                "has_specials": false,
                "is_mls_rental": false,
                "is_rental_community": true,
                "is_rental_unit": false,
                "is_co_star": true,
                "is_apartmentlist": false,
                "suppress_map_pin": false,
                "suppress_phone_call_lead_event": true,
                "price_reduced": false,
                "allows_cats": true,
                "allows_dogs": true,
                "allows_dogs_small": true,
                "allows_dogs_large": true
            },
            "agents": [
                {
                    "primary": true
                }
            ],
            "lead_forms": {
                "form": {
                    "name": {
                        "required": true,
                        "minimum_character_count": 1
                    },
                    "email": {
                        "required": true,
                        "minimum_character_count": 5
                    },
                    "move_in_date": {
                        "required": true,
                        "default_date": "2020-09-01T12:00:00Z",
                        "minimum_days_from_today": 1,
                        "maximum_days_from_today": 180
                    },
                    "phone": {
                        "required": true,
                        "minimum_character_count": 10,
                        "maximum_character_count": 11
                    },
                    "message": {
                        "required": false,
                        "minimum_character_count": 0
                    },
                    "show": false
                },
                "show_agent": false,
                "show_broker": false,
                "show_provider": false,
                "show_management": false
            },
            "lot_size": {
                "size": 0,
                "units": "sqft"
            },
            "building_size": {
                "units": "sqft"
            },
            "rdc_web_url": "https://www.realtor.com/realestateandhomes-detail/190-Beach-69th-St_Arverne_NY_11692_M31885-07190",
            "rdc_app_url": "move-rdc://www.realtor.com/realestateandhomes-detail/190-Beach-69th-St_Arverne_NY_11692_M31885-07190",
            "community": {
                "baths_max": 1,
                "baths_min": 1,
                "beds_max": 1,
                "beds_min": 1,
                "contact_number": "(844) 454-2289",
                "id": 1839240,
                "name": "The Tides At Arverne By The Sea",
                "price_max": 2195,
                "price_min": 2195,
                "source_id": "46dfexj",
                "sqft_max": 659,
                "sqft_min": 659
            },
            "data_source_name": "co-star",
            "source": "community",
            "page_no": 1,
            "rank": 1,
            "list_tracking": "type|property|data|prop_id|3188507190|list_id|612930061|comm_id|1839240|page|rank|data_source|co-star|property_status|product_code|advantage_code^1|1|3K2|E8|0^^$0|1|2|$3|4|5|6|7|8|9|G|A|H|B|C|D|I|E|J|F|K]]",
            "photo_count": 19,
            "photos": [
                {
                    "href": "https://ar.rdcpix.com/610e208fe79b9533c5e103166312b312c-f75218736o.jpg"
                },
                {
                    "href": "https://ar.rdcpix.com/610e208fe79b9533c5e103166312b312c-f3178227471o.jpg"
                },
                {
                    "href": "https://ar.rdcpix.com/610e208fe79b9533c5e103166312b312c-f3306091863o.jpg"
                },
                {
                    "href": "https://ar.rdcpix.com/610e208fe79b9533c5e103166312b312c-f1799178643o.jpg"
                },
                {
                    "href": "https://ar.rdcpix.com/610e208fe79b9533c5e103166312b312c-f884518299o.jpg"
                },
                {
                    "href": "https://ar.rdcpix.com/610e208fe79b9533c5e103166312b312c-f1142482343o.jpg"
                },
                {
                    "href": "https://ar.rdcpix.com/610e208fe79b9533c5e103166312b312c-f624998745o.jpg"
                },
                {
                    "href": "https://ar.rdcpix.com/610e208fe79b9533c5e103166312b312c-f3641852832o.jpg"
                },
                {
                    "href": "https://ar.rdcpix.com/610e208fe79b9533c5e103166312b312c-f2581754924o.jpg"
                },
                {
                    "href": "https://ar.rdcpix.com/610e208fe79b9533c5e103166312b312c-f1976580515o.jpg"
                },
                {
                    "href": "https://ar.rdcpix.com/610e208fe79b9533c5e103166312b312c-f586291969o.jpg"
                },
                {
                    "href": "https://ar.rdcpix.com/610e208fe79b9533c5e103166312b312c-f2803556443o.jpg"
                },
                {
                    "href": "https://ar.rdcpix.com/610e208fe79b9533c5e103166312b312c-f3294921843o.jpg"
                },
                {
                    "href": "https://ar.rdcpix.com/610e208fe79b9533c5e103166312b312c-f852583007o.jpg"
                },
                {
                    "href": "https://ar.rdcpix.com/610e208fe79b9533c5e103166312b312c-f4164216811o.jpg"
                },
                {
                    "href": "https://ar.rdcpix.com/610e208fe79b9533c5e103166312b312c-f3902720508o.jpg"
                },
                {
                    "href": "https://ar.rdcpix.com/610e208fe79b9533c5e103166312b312c-f850731407o.jpg"
                },
                {
                    "href": "https://ar.rdcpix.com/610e208fe79b9533c5e103166312b312c-f2027588413o.jpg"
                },
                {
                    "href": "https://ar.rdcpix.com/610e208fe79b9533c5e103166312b312c-f805760224o.jpg"
                }
            ]
        },
...
...
]

If the response is not returning the data you expect then it could be that the format of your fetch GET request code is not quite right.

EDIT: In fact, that is exactly the problem I do believe. So, it should probably work if you try to structure your fetch similarly to this:

let url = 'https://realtor.p.rapidapi.com/properties/v2/list-for-rent?sort=relevance&city=New%20York%20City&state_code=NY&limit=200&offset=0';
      

       fetch(url, {
        method: 'GET',
        headers: {
          'Content-Type': 'application/json',
          'x-rapidapi-host': 'realtor.p.rapidapi.com',
          'x-rapidapi-key': 'e5b0286ea4msh1d616284115d5efp16cadcjsn0392ca0398ac'

        }})
              .then((response) => {
                return response.json();

              })
              .then((data) => {
                console.log(data);
              });
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement