Skip to content
Advertisement

How to filter expanded datasets in json URL?

I am trying to filter results in my json URL’s expanded dataset. I can filter the regular data just fine but I am having issues reaching the expanded data which is being returned as a nested array (I believe).

For example I use this url to filter and only display the city Austin:

https://api.bridgedataoutput.com/api/v2/OData/actris/Property?access_token=HIDDEN&$filter=City%20eq%20%27Austin%27   (or unfriendly URL would look like this &$filter=City eq 'Austin')

I am able to expand this dataset and include open house information so the URL looks like this:

https://api.bridgedataoutput.com/api/v2/OData/actris/Property?access_token=HIDDEN&$expand=OpenHouses&$filter=City%20eq%20%27Austin%27

I’d like to know how I can filter by a value in the expanded section. So instead of filtering by City I would filter by OpenHouseStatus = Active (see json example below).

The structure of the json results look like this:

{
  "value": [
    {
      "PhotosCount": 15,
      "FireplacesTotal": 0,
      "City": "Austin",
      "Media": [
        {
          "Order": "1",
          "MediaURL": "https://dvvjkgh94f2v6.cloudfront.net/62e30b5c/108289219/83dcefb7.jpeg",
          "MediaCategory": "Photo",
          "MediaObjectID": "108289219_1",
        },
        {
          "Order": "2",
          "MediaURL": "https://dvvjkgh94f2v6.cloudfront.net/62e30b5c/108289219/1ad5be0d.jpeg",
          "MediaCategory": "Photo",
          "MediaObjectID": "108289219_2",
        },
      ],
      "PostalCode": "78701",
      "UnparsedAddress": "48 E East Ave # 2509, Austin TX 78701",
      "OpenHouses": [
        {
          "OpenHouseMethod": "In Person",
          "OpenHouseStatus": "Active",
          "OpenHouseType": "Public",
          "OpenHouseStartTime": "2021-04-01T15:00:00.000Z",
          "OpenHouseEndTime": "2021-04-01T19:00:00.000Z",
          "ListingId": "5645082",
          "OpenHouseDate": "2021-04-01",
        },
        {
          "OpenHouseMethod": "In Person",
          "OpenHouseStatus": "Ended",
          "OpenHouseType": "Public",
          "OpenHouseStartTime": "2021-03-30T15:00:00.000Z",
          "OpenHouseEndTime": "2021-03-30T19:00:00.000Z",
          "ListingId": "5645082",
          "OpenHouseDate": "2021-03-30",
        }
      ]
    }
  ]
}

Advertisement

Answer

The way I resolved this issue was by doing the following:

https://api.bridgedataoutput.com/api/v2/OData/actris/Property?access_token=HIDDEN&$expand=OpenHouses($filter=OpenHouseStatus%20eq%20%27Active%27)

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement