Identify Zambian mobile networks (Airtel, MTN, Zamtel, Zed Mobile) from a phone number.
The operator prefix is the two digits after the leading 0 or 260 country code.
| Network | Local | With country code |
|---|---|---|
| Airtel | 097, 077, 057 | 26097, 26077, 26057 |
| MTN | 096, 076, 056 | 26096, 26076, 26056 |
| Zamtel | 095, 075, 055 | 26095, 26075, 26055 |
| Zed Mobile | 098, 078*, 058* | 26098, 26078*, 26058* |
* 078/058 are reserved for Zed Mobile but not yet officially enabled by the
network provider; they are detected pre-emptively.
Summary
Functions
Detects the network for an MSISDN, or nil if unrecognised.
Human-readable label for a network.
Returns the network logo as a base64 data: URI (200x200 PNG), or nil for an
unknown network.
Returns the supported networks.
Operator prefixes for a network.
Whether the MSISDN belongs to the given network.
Types
Functions
Detects the network for an MSISDN, or nil if unrecognised.
Accepts local (0XY…) and country-code (260XY…, +260 XY…) formats.
Examples
iex> ZambiaMobileNetworks.detect("0971234567")
:airtel
iex> ZambiaMobileNetworks.detect("260761234567")
:mtn
iex> ZambiaMobileNetworks.detect("+260 95 123 4567")
:zamtel
iex> ZambiaMobileNetworks.detect("0981234567")
:zed
iex> ZambiaMobileNetworks.detect("0911234567")
nil
Human-readable label for a network.
Returns the network logo as a base64 data: URI (200x200 PNG), or nil for an
unknown network.
Pass custom (a file path or raw image binary) to use your own logo instead of
the bundled one. The custom image is returned encoded as-is — it is not resized.
iex> "data:image/png;base64," <> _ = ZambiaMobileNetworks.logo(:mtn)
@spec networks() :: [network()]
Returns the supported networks.
Operator prefixes for a network.
Whether the MSISDN belongs to the given network.
Examples
iex> ZambiaMobileNetworks.supports?("0961234567", :mtn)
true
iex> ZambiaMobileNetworks.supports?("0961234567", :airtel)
false