import requests
import json


def get_vendor_from_mac(mac):
    """Get the vendor from the MAC using an API"""
    url = "https://mac2vendor.com/api/v4/mac/"
    mac_str = "".join(mac.split(":")[:3])
    try:
        r = requests.get(url + mac_str)
        response = json.loads(r.text)
        if not response["success"]:
            return "Unknown"
        else:
            return response["payload"][0]["vendor"]
    except:
        return "Unknown"