Use the official Mux SDK for Elixir to call the Mux API from your server. The SDK handles authentication and wraps each API endpoint in native Elixir code.
The Mux SDK for Elixir wraps the Mux REST API in native Elixir code. Use this SDK when you write your server application in Elixir. You can create assets, manage live streams, and query Mux Data without manual HTTP requests.
Add mux to your list of dependencies in mix.exs.
def deps do
[
{:mux, "~> 3.2.1"}
]
endTo start, we'll need a Mux access token. We'll put our access token in our application configuration.
# config/dev.exs
config :mux,
access_token_id: "abcd1234",
access_token_secret: "efghijkl"Then use this config to initialize a new client in your application.
client = Mux.client()You can also pass the access token ID and secret directly to client/2 function if you'd prefer:
client = Mux.client("access_token_id", "access_token_secret")Now we can use the client to upload new videos, manage playback IDs, etc.
params = %{
input: "https://example.com/video.mp4"
}
{:ok, asset, _} = Mux.Video.Assets.create(client, params);Check out the Mux Elixir SDK docs for more information.