# ExMLS: Reading MLS Listing Feeds From Elixir

Author: Ziyan Junaideen
Published: 2026-11-30T10:00:34Z
Updated: 2026-11-30T10:00:34Z
Original: https://www.jdeen.com/blog/ex-mls-reading-mls-listing-feeds-from-elixir

![ExMLS share card: the ExMLS name and headline "Read MLS listing feeds from Elixir." beside a code window streaming Property pages](https://sgp1.digitaloceanspaces.com/jdeen/uploads/7020c0c9-2f56-48fa-ab8e-450ef7721dc9/ex-mls-card.jpg)

I've just published [ExMLS](https://hex.pm/packages/ex_mls) 0.1.0 on Hex. It's a small, read-only Elixir library for pulling listings out of an MLS feed over the [RESO Web API](https://transport.reso.org/proposals/web-api-core/). The source is on [GitHub](https://github.com/ziyan-junaideen/ex_mls) under the MIT licence, and the API reference is on [HexDocs](https://hexdocs.pm/ex_mls/ExMLS.html).

### Why I needed it

[Estate](https://estate.jdeen.com), the real-estate software I [rebuilt in Phoenix](https://www.jdeen.com/blog/from-lankadreamhomes-to-estate-why-i-rebuilt-my-real-estate-software-in-phoenix), is the first consumer. An agency's website is only as useful as the listings on it, and in markets with an MLS those listings come from a feed. Today most MLS providers expose that feed through the RESO Web API, which is OData under the hood: an `$metadata` document describing the schema, a `Property` collection, a `Media` collection, and the usual `$select`, `$filter`, `$orderby` and `$top` query options.

Talking to it isn't hard, but getting it right takes care: OAuth tokens that expire, pagination links that the server controls, provider-specific fields, and credentials that must never leak to another host. I wanted that work done once, tested, and kept out of Estate's own code, so I made it a library.

### What it does

ExMLS deliberately does very little:

- **Authentication.** Pass a bearer token from your provider, or configure OAuth 2 client credentials with the provider's token endpoint. ExMLS fetches the token on the first request, caches it until it expires and renews it. A 401 from the feed throws the cached token away so the next request gets a fresh one.
- **Listings and media.**`ExMLS.property/2` and `ExMLS.media/2` take `select:`, `filter:`, `orderby:`, `top:` and `expand:` and return lazy streams of pages.
- **Metadata.**`ExMLS.metadata/1` returns the feed's raw EDMX XML, so you can see which fields your provider actually offers.

That's the whole public API. Persistence, sync checkpoints, removal rules and IDX/VOW display policy belong to the application using it, so they aren't in the library. Write-back and RETS are left out until someone needs them.

### Using it

Add it to `mix.exs`:

```elixir
defp deps do
  [
    {:ex_mls, "~> 0.1.0"}
  ]
end
```

Build a client. This doesn't touch the network:

```elixir
client =
  ExMLS.new(
    service_root: "https://feed.example.com/odata/",
    auth:
      {:client_credentials,
       token_url: "https://auth.example.com/oauth/token",
       client_id: System.fetch_env!("MLS_CLIENT_ID"),
       client_secret: System.fetch_env!("MLS_CLIENT_SECRET")}
  )
```

Then read listings. Each element of the stream is either `{:ok, records}` for a page or `{:error, %ExMLS.Error{}}`, which is always the last thing the stream emits:

```elixir
client
|> ExMLS.property(
  select: "ListingKey,StandardStatus,ListPrice",
  filter: "StandardStatus eq 'Active'",
  orderby: "ListingKey",
  top: 100
)
|> Enum.reduce_while(:ok, fn
  {:ok, records}, :ok ->
    Enum.each(records, &upsert_listing/1)
    {:cont, :ok}

  {:error, error}, :ok ->
    {:halt, {:error, error}}
end)
```

The stream follows `@odata.nextLink` as you enumerate it, so you only fetch as many pages as you consume.

### The decisions that matter

Most of the work went into a few rules that are easy to get wrong in an HTTP client.

**Keep every field.** MLS providers add their own local fields on top of the RESO Data Dictionary. ExMLS returns records as plain maps with string keys, nothing dropped. Mapping them onto a fixed struct would quietly lose the fields an agency often cares about most.

**Don't parse the schema.** Metadata comes back as raw EDMX instead of a fixed Data Dictionary version baked into the library. The feed's own metadata is the source of truth, and it changes.

**Credentials stay on one origin.** Feed requests and `@odata.nextLink` continuations must stay on the service root's scheme, host and port, or they fail with `:unsafe_origin`. Redirects are returned as errors instead of followed. A server can't send your bearer token somewhere else, even by accident. Continuation query strings are sent exactly as the server gave them.

**Partial reads are visible.** If page 40 fails after 39 good pages, the stream emits those 39 pages, then the error, then stops. You can't mistake a half-finished sync for a complete one unless you ignore the last element.

**Errors are part of the API.** Every failure is an `%ExMLS.Error{}` with a stable `reason`, such as `:unauthorized`, `:token_request_failed`, `:http_error` (429 throttling included) or `:transport_error`, and an HTTP `status` where there is one. Error values and `inspect` output never contain tokens, secrets, URLs or response bodies, so they're safe to log. Retry and backoff are up to you.

Under the hood it's built on [Req](https://hex.pm/packages/req), with the OAuth tokens cached in ETS so concurrent requests on one node share a token instead of each asking for its own.

### How it was tested

The default test suite runs offline. Beyond that I verified it against two real servers:

- The **RESO Reference Server**, run locally with SQLite and its synthetic dataset. The integration tests check that unauthenticated reads get a 401, that both bearer and mock OAuth can read metadata and query listings with expanded media, and that all 285 seeded `Media` records stream across three server-driven pages.
- **Bridge Interactive's hosted `test` dataset**, with Bridge's public test token. Bearer auth, filtered and ordered `Property` queries, a continuation page, metadata and media embedded in `Property` records all worked.

The Bridge run was also a reminder that every provider is a bit different. Its standalone `Media` collection returned no records, and `$expand=Media` returned a 400, while `$select=ListingKey,Media` worked. That's why ExMLS doesn't guess: check your feed's metadata and its documentation, and choose the query it supports. The repository includes [an example script](https://github.com/ziyan-junaideen/ex_mls/blob/v0.1.0/examples/read_feed.exs) that runs the whole read path against either server.

### What's next

ExMLS is at 0.1.0 and its job is to feed Estate. As I connect it to more providers I expect to find more of their quirks, and the library will grow from what those feeds need rather than from guesses. If you're building real-estate software in Elixir and have access to an MLS feed, I'd like to hear how it behaves with yours. Issues and pull requests are welcome on [GitHub](https://github.com/ziyan-junaideen/ex_mls).
