ExMLS is an Elixir library for read-only access to MLS feeds through the RESO Web API. It reads listings, media, and EDMX metadata while preserving provider-specific fields. See the HexDocs API reference for function options and return values.

Installation

Add ex_mls to your application's dependencies in mix.exs and run mix deps.get.

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

Authentication

ExMLS.new/1 builds a client for an OData service root without making a network request. Configure the full service root, including the provider's dataset path when applicable. Use HTTPS for hosted feeds.

Pass the bearer token supplied by your provider.

client =
  ExMLS.new(
    service_root: "https://feed.example.com/odata/",
    auth: {:bearer, System.fetch_env!("MLS_ACCESS_TOKEN")}
  )

For OAuth 2 client credentials, configure the provider's token endpoint.

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")}
  )

ExMLS acquires the token on the first request and renews it after expiry. Set scope: if your provider requires a scope. Use client_auth: :post if the token endpoint expects credentials in the form body. The default is HTTP Basic authentication. When the feed returns HTTP 401, ExMLS returns the error and discards the cached OAuth token so a later request can obtain a fresh one. The token endpoint may have its own origin. Feed requests and continuations stay on the service root's origin, and redirects are returned as errors.

Reading listings and media

ExMLS.property/2 and ExMLS.media/2 accept select:, filter:, orderby:, top:, and expand: where the feed supports the corresponding OData options. Both return lazy streams of pages. Each page contains the original record maps, including provider-specific fields.

pages =
  ExMLS.property(client,
    select: "ListingKey,StandardStatus",
    filter: "StandardStatus eq 'Active'",
    orderby: "ListingKey",
    top: 100
  )

result =
  Enum.reduce_while(pages, :ok, fn
    {:ok, records}, :ok ->
      Enum.each(records, &IO.inspect/1)
      {:cont, :ok}

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

The stream follows the feed's @odata.nextLink as you enumerate it, including after an empty page. ExMLS sends continuation query strings as supplied by the server. If a later page fails, the stream emits the error after the successful pages and then ends. Treat the read as complete only after the stream finishes successfully. Omit top: to read the full query result.

When the feed exposes a standalone Media collection, query it by the listing's ResourceRecordKey. Consume its pages the same way as Property pages.

media_pages =
  ExMLS.media(client,
    select: "MediaKey,ResourceRecordKey,MediaURL",
    filter: "ResourceRecordKey eq 'example-listing-key'",
    orderby: "MediaKey"
  )

Some feeds also support ExMLS.property(client, expand: "Media"). Bridge's Test dataset exposes media through ExMLS.property(client, select: "ListingKey,Media"). Use the feed's metadata and provider documentation to choose the supported query.

Discovering feed fields

ExMLS.metadata/1 fetches $metadata from the configured service root using the same client and credentials. It returns {:ok, xml} with the raw EDMX XML as a binary, or {:error, %ExMLS.Error{}} if the request fails. You can save the document locally for inspection.

with {:ok, xml} <- ExMLS.metadata(client) do
  File.write("metadata.xml", xml)
end

To find listing fields, locate the EntitySet named Property in the EntityContainer. Follow its EntityType attribute to the matching type in the schema. Each Property element on that type declares a field's Name and Type, including any provider-specific fields. If the type declares a BaseType, inspect that type for inherited fields. Use the names from the feed in query options such as select:.

Errors

Requests return {:error, %ExMLS.Error{}} on failure. For a collection stream, this tuple is the final element. Match on reason and, where available, status. Error values omit credentials, URLs, and response bodies.

ReasonMeaning
:unauthorized, :forbiddenThe feed returned HTTP 401 or 403.
:token_request_failed, :invalid_token_responseThe token request failed or the token endpoint returned an unusable response.
:http_errorThe feed returned another unsuccessful status, including HTTP 429 for throttling and 3xx redirects.
:invalid_url, :unsafe_originA request target is invalid or points to a different origin.
:invalid_response, :transport_errorThe feed response is malformed or the HTTP connection failed.

ExMLS returns request failures to the caller for retry or backoff. Invalid client configuration and invalid query options raise ArgumentError.

Runnable feed example

The example script shows the read path Estate can use. It builds one client, fetches the feed's EDMX, queries listings, follows continuations, and reads standalone or embedded media. It samples up to two pages per collection, prints counts, and exits with status 1 if a request fails, including after an earlier page succeeds.

From an ExMLS checkout, run mix deps.get and start and seed the local RESO sandbox. Run the example with its static bearer token.

EX_MLS_SERVICE_ROOT=http://127.0.0.1:8080 \
  EX_MLS_ACCESS_TOKEN=read-token \
  mix run examples/read_feed.exs

To try mock OAuth on the same sandbox, set EX_MLS_TOKEN_URL.

EX_MLS_SERVICE_ROOT=http://127.0.0.1:8080 \
  EX_MLS_TOKEN_URL='http://127.0.0.1:8080/oauth/token?role=read' \
  EX_MLS_CLIENT_ID=ex-mls-example EX_MLS_CLIENT_SECRET=mock-secret \
  EX_MLS_CLIENT_AUTH=post mix run examples/read_feed.exs

The script defaults to HTTP Basic for OAuth and accepts EX_MLS_SCOPE for providers that require a scope. For a hosted feed, set EX_MLS_SERVICE_ROOT and the matching credentials. Use --embedded-media for the Bridge Test dataset, as shown in the hosted example.

Contributing

CI runs on these supported Elixir and Erlang/OTP pairs:

ElixirErlang/OTP
1.19.x28.x
1.20.x29.x

Run these commands from a checkout using either pair:

mix local.hex --force
mix local.rebar --force
mix deps.get
mix format --check-formatted
mix compile --warnings-as-errors
mix test --warnings-as-errors
mix docs
mix hex.build

Installing Hex and Rebar and fetching dependencies require network access. Once dependencies are present, the default test suite runs offline without an MLS account. mix docs generates doc/index.html. mix hex.build creates ex_mls-0.1.0.tar in the project directory without publishing to Hex.

Feed verification

Local RESO Reference Server

Use Node.js 24 and npm 11 to build the pinned RESO Reference Server with SQLite. Run this in a directory separate from your ExMLS checkout.

git clone https://github.com/RESOStandards/reso-tools.git
cd reso-tools
git checkout --detach 06ea4c994146f4d6c2da87e3d72a43d7a9ac73b4
npm ci --ignore-scripts
npm run build
cd reso-reference-server

PORT=8080 DB_BACKEND=sqlite AUTH_REQUIRED=true node --input-type=module <<'JS'
import express from "express";
import { createApp, loadConfig } from "./dist/index.js";
import { loadAuthConfig } from "./dist/auth/config.js";
import { requireAuth } from "./dist/auth/middleware.js";

const config = loadConfig();
const { app } = await createApp({ config });
const server = express();
server.get(/^\/(?:Property|Media|\$metadata)$/, requireAuth("read", loadAuthConfig()));
server.use(app);
server.listen(config.port, "127.0.0.1");
JS

The wrapper applies the server's bearer-token check to the read routes so the tests can verify both the static read token and the token issued by mock OAuth. Once the server is running, seed its synthetic dataset in a second terminal, then run the integration tests from the ExMLS checkout.

curl --fail-with-body --silent --show-error http://127.0.0.1:8080/admin/seed \
  -H 'Authorization: Bearer admin-token' \
  -H 'Content-Type: application/json' --data '{}'

mix test --only reso_integration

Set EX_MLS_RESO_URL if you use a different local port. The tests verify unauthenticated reads return 401, both authentication modes can read EDMX and query listings with expanded media, and Media streams all 285 seeded records across three server-driven pages.

Hosted Bridge Test dataset

Use the public test token prefilled in the Bridge API Explorer, or a Bridge server token with access to the test dataset. In the Explorer, copy the access_token from the displayed request URL. From the ExMLS checkout, enter the token into your shell and run the smoke tests.

read -rs -p 'Bridge test token: ' EX_MLS_BRIDGE_TOKEN
printf '\n'
export EX_MLS_BRIDGE_TOKEN
mix test --only bridge_smoke
EX_MLS_SERVICE_ROOT=https://api.bridgedataoutput.com/api/v2/OData/test/ \
  EX_MLS_ACCESS_TOKEN="$EX_MLS_BRIDGE_TOKEN" \
  mix run examples/read_feed.exs --embedded-media
unset EX_MLS_BRIDGE_TOKEN

Bridge Interactive's hosted test dataset is the first verified hosted feed. On 2026-11-30 it passed bearer authentication, Property queries using $select, $filter, $orderby, and $top, a Property continuation, EDMX metadata, and reads of media embedded in Property records via $select=ListingKey,Media. Standalone Media returned HTTP 200 with no records. Property with $expand=Media returned HTTP 400. The hosted check used Bridge's public test token. Provider credentials and hosted records stay out of the repository.

License

ExMLS is available under the MIT License.