MAC vendor lookup: Difference between revisions

No edit summary
m (→‎{{header|Wren}}: Minor tidy)
 
(46 intermediate revisions by 11 users not shown)
Line 19: Line 19:
=={{header|Ada}}==
=={{header|Ada}}==
{{libheader|AWS}}
{{libheader|AWS}}
<lang Ada>with Ada.Text_IO;
<syntaxhighlight lang="ada">with Ada.Text_IO;


with AWS.Client;
with AWS.Client;
Line 52: Line 52:
Lookup ("23-45-67"); delay 1.500;
Lookup ("23-45-67"); delay 1.500;
Lookup ("foobar");
Lookup ("foobar");
end MAC_Vendor;</lang>
end MAC_Vendor;</syntaxhighlight>
{{out}}
{{out}}
<pre>88:53:2E:67:07:BE Intel Corporate
<pre>88:53:2E:67:07:BE Intel Corporate
Line 62: Line 62:
foobar N/A</pre>
foobar N/A</pre>


=={{header|AppleScript}}==
=={{header|APL}}==
{{works with|Dyalog APL}}
This is the first implementation to build in a delay between two calls to avoid throttling by macvendors.com. The version below is the as-typed one :
{{libheader|HttpCommand}}
<lang AppleScript>
set {table, macList} to {{return}, {"88:53:2E:67:07:BE", "D4:F4:6F:C9:EF:8D", "FC:FB:FB:01:FA:21", "4c:72:b9:56:fe:bc", "00-14-22-01-23-45"}}


Normally something like this would just be mapping the lookup across an array, but that doesn't let us control the timing of the request dispatch. To insert a delay between requests we have to create a traditional function ("tradfn") with a for loop.
repeat with burger in macList
set end of table to do shell script "curl http://api.macvendors.com/" & burger & " && sleep 5 && echo '\n'" & return
end repeat


<syntaxhighlight lang="apl">⍝load the library module
return table as string
]load HttpCommand
</lang>


⍝ define a direct function (dfn) to look up a single MAC address
Which will turn into the one below once it is compiled. Script Editor translates \n to a newline in the code itself.
vendorLookup1 ← { (HttpCommand.Get 'http://api.macvendors.com/',⍕⍵).Data }
<lang AppleScript>
set {table, macList} to {{return}, {"88:53:2E:67:07:BE", "D4:F4:6F:C9:EF:8D", "FC:FB:FB:01:FA:21", "4c:72:b9:56:fe:bc", "00-14-22-01-23-45"}}


⍝ define a traditional function to look up all the MAC addresses in a list with
repeat with burger in macList
⍝ a delay between calls
set end of table to do shell script "curl http://api.macvendors.com/" & burger & " && sleep 5 && echo '

'" & return
⍝ The header says that the function is named vendorLookup, it takes a single
⍝ parameter which we call macList, and the value of the local variable
⍝ vendors will become the function's return value
∇ vendors ← vendorLookup macList
⍝ look up the first vendor and put it into an array in our return var
vendors ← ⊆vendorLookup1 1↑macList
⍝ Loop over the rest of the array
:For burger :In 1↓macList
⎕DL 2 ⍝ wait 2 seconds
vendors ⍪← ⊆vendorLookup1 burger ⍝ then look up the next vendor and append
:EndFor

⍝ demo data
macList ← '88:53:2E:67:07:BE' 'D4:F4:6F:C9:EF:8D' 'FC:FB:FB:01:FA:21'
macList ⍪← '4c:72:b9:56:fe:bc' '00-14-22-01-23-45'

⍝ look up the vendors (takes a while with the 2-second delay between lookups)
vendorList ← vendorLookup macList

⍝ the result is an array (a 1-row by N-column matrix). to print out one vendor
⍝ per line, we reshape it to be N rows by 1 column instead.
{(1⌷⍴⍵) 1 ⍴ ⍵} vendorList</syntaxhighlight>

{{Out}}
<pre> Intel Corporate
Apple, Inc.
Cisco Systems, Inc
PEGATRON CORPORATION
Dell Inc.
</pre>

=={{header|AppleScript}}==
<syntaxhighlight lang="applescript">set apiRoot to "https://api.macvendors.com"
set macList to {"88:53:2E:67:07:BE", "D4:F4:6F:C9:EF:8D", ¬
"FC:FB:FB:01:FA:21", "4c:72:b9:56:fe:bc", "00-14-22-01-23-45"}

on lookupVendor(macAddr)
global apiRoot
return do shell script "curl " & apiRoot & "/" & macAddr
end lookupVendor

set table to { lookupVendor(first item of macList) }
repeat with burger in macList's items 2 thru -1
delay 1.5
set end of table to lookupVendor(burger)
end repeat
end repeat


set text item delimiters to linefeed
return table as string
return table as string
</syntaxhighlight>
</lang>

If this is part of a larger script you probably want to save and restore the text item delimiters:

<syntaxhighlight lang="applescript">set savedTID to text item delimiters
set text item delimiters to linefeed
set tableText to table as string
set text item delimiters to savedTID
return tableText</syntaxhighlight>


{{out}}
{{out}}
<pre>
<pre>
"
Intel Corporate
Intel Corporate
Apple, Inc.
Apple, Inc.
Line 94: Line 146:
PEGATRON CORPORATION
PEGATRON CORPORATION
Dell Inc.
Dell Inc.
"
</pre>
</pre>


=={{header|Arturo}}==
=={{header|Arturo}}==


<lang rebol>loop ["FC-A1-3E" "FC:FB:FB:01:FA:21" "BC:5F:F4"] 'mac [
<syntaxhighlight lang="rebol">loop ["FC-A1-3E" "FC:FB:FB:01:FA:21" "BC:5F:F4"] 'mac [
print [mac "=>" read ~"http://api.macvendors.com/|mac|"]
print [mac "=>" read ~"http://api.macvendors.com/|mac|"]
pause 1500
pause 1500
]</lang>
]</syntaxhighlight>


{{out}}
{{out}}
Line 111: Line 162:


=={{header|AutoHotkey}}==
=={{header|AutoHotkey}}==
<lang AutoHotkey>macLookup(MAC){
<syntaxhighlight lang="autohotkey">macLookup(MAC){
WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
WebRequest.Open("GET", "http://api.macvendors.com/" MAC)
WebRequest.Open("GET", "http://api.macvendors.com/" MAC)
WebRequest.Send()
WebRequest.Send()
return WebRequest.ResponseText
return WebRequest.ResponseText
}</lang>
}</syntaxhighlight>
Examples:<lang AutoHotkey>MsgBox % macLookup("00-14-22-01-23-45")</lang>
Examples:<syntaxhighlight lang="autohotkey">MsgBox % macLookup("00-14-22-01-23-45")</syntaxhighlight>
Outputs:<pre>Dell Inc.</pre>
Outputs:<pre>Dell Inc.</pre>


=={{header|BaCon}}==
=={{header|BaCon}}==
This code requires BaCon 3.8.2 or higher.
This code requires BaCon 3.8.2 or higher.
<lang bacon>OPTION TLS TRUE
<syntaxhighlight lang="bacon">OPTION TLS TRUE


website$ = "api.macvendors.com"
website$ = "api.macvendors.com"
Line 132: Line 183:
CLOSE NETWORK mynet
CLOSE NETWORK mynet


PRINT TOKEN$(info$, 2, "\r\n\r\n")</lang>
PRINT TOKEN$(info$, 2, "\r\n\r\n")</syntaxhighlight>
{{out}}
{{out}}
<pre>Hon Hai Precision Ind. Co.,Ltd.</pre>
<pre>Hon Hai Precision Ind. Co.,Ltd.</pre>

=={{header|BBC BASIC}}==
{{works with|BBC BASIC for Windows}}
<syntaxhighlight lang="bbcbasic"> DIM Block% 599 : REM Memory buffer to receive GET info
INSTALL @lib$ + "SOCKLIB" : PROC_initsockets
READ Mac$
WHILE Mac$ > ""
WAIT 100 : REM 1 sec pause to avoid 'Too Many Requests' errors
Socket=FN_tcpconnect("api.macvendors.com", "80")
I%=FN_writelinesocket(Socket, "GET /" + Mac$ + " HTTP/1.0")
I%=FN_writelinesocket(Socket, "")
REPEAT N%=FN_readsocket(Socket, Block%, 600) UNTIL N% > 0
PROC_closesocket(Socket)
PRINT Mac$ TAB(24);
CASE LEFT$($(Block% + 9), 3) OF
WHEN "200"
Block%?N%=0 : REM Add terminating 0x00
REPEAT N%-=1 UNTIL Block%?N% < 32 : REM Leave only last line
PRINT $$(Block% + N% + 1) : REM Print string from memory
WHEN "404"
PRINT "N/A"
OTHERWISE
PRINT "ERROR"
ENDCASE
READ Mac$
ENDWHILE
PROC_exitsockets
END
DATA 88:53:2E:67:07:BE, FC:FB:FB:01:FA:21, D4:F4:6F:C9:EF:8D, 10-11-22-33-44-55,</syntaxhighlight>
{{out}}

<pre>
88:53:2E:67:07:BE Intel Corporate
FC:FB:FB:01:FA:21 Cisco Systems, Inc
D4:F4:6F:C9:EF:8D Apple, Inc.
10-11-22-33-44-55 N/A
</pre>


=={{header|C}}==
=={{header|C}}==
Takes MAC address as input, prints usage on incorrect invocation, requires [https://curl.haxx.se/libcurl/ libcurl]
Takes MAC address as input, prints usage on incorrect invocation, requires [https://curl.haxx.se/libcurl/ libcurl]
<syntaxhighlight lang="c">
<lang C>
#include <curl/curl.h>
#include <curl/curl.h>
#include <string.h>
#include <string.h>
Line 216: Line 307:
return EXIT_FAILURE;
return EXIT_FAILURE;
}
}
</syntaxhighlight>
</lang>
Invocation and output :
Invocation and output :
<pre>
<pre>
Line 227: Line 318:
=={{header|C sharp|C#}}==
=={{header|C sharp|C#}}==


<lang csharp>using System;
<syntaxhighlight lang="csharp">using System;
using System.Net;
using System.Net;
using System.Net.Http;
using System.Net.Http;
Line 246: Line 337:
Console.ReadLine();
Console.ReadLine();
}
}
}</lang>
}</syntaxhighlight>


{{out}}
{{out}}
Line 258: Line 349:
=={{header|C++}}==
=={{header|C++}}==
{{libheader|Boost}}
{{libheader|Boost}}
<lang cpp>// This code is based on the example 'Simple HTTP Client' included with
<syntaxhighlight lang="cpp">// This code is based on the example 'Simple HTTP Client' included with
// the Boost documentation.
// the Boost documentation.


Line 320: Line 411:
}
}
return EXIT_FAILURE;
return EXIT_FAILURE;
}</lang>
}</syntaxhighlight>


{{out}}
{{out}}
Line 329: Line 420:


=={{header|Common Lisp}}==
=={{header|Common Lisp}}==
<lang Common Lisp>(quicklisp:quickload :Drakma) ; or load it in another way
<syntaxhighlight lang="common lisp">(quicklisp:quickload :Drakma) ; or load it in another way


(defun mac-vendor (mac)
(defun mac-vendor (mac)
Line 338: Line 429:
(format t "~%Vendor is ~a" vendor)
(format t "~%Vendor is ~a" vendor)
(error "~%Not a MAC address: ~a" mac))))
(error "~%Not a MAC address: ~a" mac))))
</syntaxhighlight>
</lang>
=={{header|Delphi}}==
=={{header|Delphi}}==
{{libheader| System.SysUtils}}
{{libheader| System.SysUtils}}
{{libheader| IdHttp}}
{{libheader| IdHttp}}
<syntaxhighlight lang="delphi">
<lang Delphi>
program MAC_Vendor_Lookup;
program MAC_Vendor_Lookup;


Line 374: Line 465:
Writeln(macLookUp('BC:5F:F4'));
Writeln(macLookUp('BC:5F:F4'));
readln;
readln;
end.</lang>
end.</syntaxhighlight>
{{out}}
{{out}}
<pre>Samsung Electronics Co.,Ltd
<pre>Samsung Electronics Co.,Ltd
Line 381: Line 472:


=={{header|Factor}}==
=={{header|Factor}}==
<lang factor>USING: accessors calendar continuations http.client io kernel
<syntaxhighlight lang="factor">USING: accessors calendar continuations http.client io kernel
sequences threads ;
sequences threads ;


Line 391: Line 482:
"FC:FB:FB:01:FA:21"
"FC:FB:FB:01:FA:21"
"10-11-22-33-44-55-66"
"10-11-22-33-44-55-66"
[ mac-vendor print 1 seconds sleep ] tri@</lang>
[ mac-vendor print 1 seconds sleep ] tri@</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 400: Line 491:


=={{header|FreeBASIC}}==
=={{header|FreeBASIC}}==
<lang freebasic>Function pipeout(Byval s As String = "") Byref As String
<syntaxhighlight lang="freebasic">Function pipeout(Byval s As String = "") Byref As String
Var f = Freefile
Var f = Freefile
Dim As String tmp
Dim As String tmp
Line 425: Line 516:
Next i
Next i
Sleep
Sleep
</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre>
<pre>
Line 435: Line 526:


=={{header|Free Pascal}}==
=={{header|Free Pascal}}==
<lang pascal>program MACVendorLookup;
<syntaxhighlight lang="pascal">program MACVendorLookup;


uses
uses
Line 458: Line 549:
end;
end;
end;
end;
end.</lang>
end.</syntaxhighlight>


{{out}}
{{out}}
Line 470: Line 561:


=={{header|Go}}==
=={{header|Go}}==
<lang go>package main
<syntaxhighlight lang="go">package main


import (
import (
Line 490: Line 581:
fmt.Println(macLookUp("BC:5F:F4"))
fmt.Println(macLookUp("BC:5F:F4"))
}
}
</syntaxhighlight>
</lang>
{{Out}}
{{Out}}
<pre>Samsung Electronics Co.,Ltd
<pre>Samsung Electronics Co.,Ltd
Line 501: Line 592:
{{libheader|http-client}}
{{libheader|http-client}}


<lang haskell>#!/usr/bin/env stack
<syntaxhighlight lang="haskell">#!/usr/bin/env stack
{- stack
{- stack
script
script
Line 547: Line 638:
putStr $ printf "%-17s" mac ++ " = "
putStr $ printf "%-17s" mac ++ " = "
vendor <- lookupMac mgr mac
vendor <- lookupMac mgr mac
putStrLn vendor</lang>
putStrLn vendor</syntaxhighlight>


{{Out}}
{{Out}}
Line 560: Line 651:
=={{header|J}}==
=={{header|J}}==
'''Solution
'''Solution
<lang j>require 'web/gethttp'
<syntaxhighlight lang="j">require 'web/gethttp'
lookupMACvendor=: [: gethttp 'http://api.macvendors.com/'&,</lang>
lookupMACvendor=: [: gethttp 'http://api.macvendors.com/'&,</syntaxhighlight>
'''Example Usage
'''Example Usage
<lang j> addr=: '88:53:2E:67:07:BE';'FC:FB:FB:01:FA:21';'D4:F4:6F:C9:EF:8D';'23:45:67'
<syntaxhighlight lang="j"> addr=: '88:53:2E:67:07:BE';'FC:FB:FB:01:FA:21';'D4:F4:6F:C9:EF:8D';'23:45:67'
(,&' ' , lookupMACvendor)&> addr
(,&' ' , lookupMACvendor)&> addr
88:53:2E:67:07:BE Intel Corporate
88:53:2E:67:07:BE Intel Corporate
FC:FB:FB:01:FA:21 Cisco Systems, Inc
FC:FB:FB:01:FA:21 Cisco Systems, Inc
D4:F4:6F:C9:EF:8D Apple, Inc.
D4:F4:6F:C9:EF:8D Apple, Inc.
23:45:67 Vendor not found</lang>
23:45:67 Vendor not found</syntaxhighlight>


=={{header|Java}}==
=={{header|Java}}==
<lang java>package com.jamesdonnell.MACVendor;
<syntaxhighlight lang="java">package com.jamesdonnell.MACVendor;


import java.io.BufferedReader;
import java.io.BufferedReader;
Line 618: Line 709:
}
}
}
}
}</lang>
}</syntaxhighlight>

===Java 11===
<syntaxhighlight lang="java">
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.List;
import java.util.concurrent.TimeUnit;

public final class MacVendorLookup {

public static void main(String[] aArgs) throws InterruptedException, IOException {
for ( String macAddress : macAddresses ) {
HttpResponse<String> response = getMacVendor(macAddress);
System.out.println(macAddress + " " + response.statusCode() + " " + response.body());
TimeUnit.SECONDS.sleep(2);
}
}

private static HttpResponse<String> getMacVendor(String aMacAddress) throws IOException, InterruptedException {
URI uri = URI.create(BASE_URL + aMacAddress);
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest
.newBuilder()
.uri(uri)
.header("accept", "application/json")
.GET()
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
return response;
}
private static final String BASE_URL = "http://api.macvendors.com/";
private static final List<String> macAddresses = List.of("88:53:2E:67:07:BE",
"D4:F4:6F:C9:EF:8D",
"FC:FB:FB:01:FA:21",
"4c:72:b9:56:fe:bc",
"00-14-22-01-23-45"
);
}
</syntaxhighlight>
{{ out }}
<pre>
88:53:2E:67:07:BE 200 Intel Corporate
D4:F4:6F:C9:EF:8D 200 Apple, Inc.
FC:FB:FB:01:FA:21 200 Cisco Systems, Inc
4c:72:b9:56:fe:bc 200 PEGATRON CORPORATION
00-14-22-01-23-45 200 Dell Inc.
</pre>


=={{header|Javascript}}==
=={{header|Javascript}}==
<lang javascript>
<syntaxhighlight lang="javascript">
var mac = "88:53:2E:67:07:BE";
var mac = "88:53:2E:67:07:BE";
function findmac(){
function findmac(){
Line 628: Line 775:


findmac();
findmac();
</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre>Intel Corporate</pre>
<pre>Intel Corporate</pre>


=={{header|Julia}}==
=={{header|Julia}}==
<lang julia># v0.6.0
<syntaxhighlight lang="julia"># v0.6.0


using Requests
using Requests
Line 647: Line 794:
for addr in ["88:53:2E:67:07:BE", "FC:FB:FB:01:FA:21", "D4:F4:6F:C9:EF:8D", "23:45:67"]
for addr in ["88:53:2E:67:07:BE", "FC:FB:FB:01:FA:21", "D4:F4:6F:C9:EF:8D", "23:45:67"]
println("$addr -> ", getvendor(addr))
println("$addr -> ", getvendor(addr))
end</lang>
end</syntaxhighlight>


{{out}}
{{out}}
Line 656: Line 803:


=={{header|Kotlin}}==
=={{header|Kotlin}}==
<lang scala>// version 1.1.2
<syntaxhighlight lang="scala">// version 1.1.2


import java.net.URL
import java.net.URL
Line 665: Line 812:
val macs = arrayOf("FC-A1-3E", "FC:FB:FB:01:FA:21", "88:53:2E:67:07:BE", "D4:F4:6F:C9:EF:8D")
val macs = arrayOf("FC-A1-3E", "FC:FB:FB:01:FA:21", "88:53:2E:67:07:BE", "D4:F4:6F:C9:EF:8D")
for (mac in macs) println(lookupVendor(mac))
for (mac in macs) println(lookupVendor(mac))
}</lang>
}</syntaxhighlight>


{{out}}
{{out}}
Line 674: Line 821:
Apple, Inc.
Apple, Inc.
</pre>
</pre>

=={{header|Logo}}==
{{works with|UCB Logo}}
<syntaxhighlight lang="logo">make "api_root "http://api.macvendors.com/
make "mac_list [88:53:2E:67:07:BE D4:F4:6F:C9:EF:8D FC:FB:FB:01:FA:21
4c:72:b9:56:fe:bc 00-14-22-01-23-45]

to lookup_vendor :mac
output first shell (sentence [curl -s] (word :api_root :mac) [&& echo])
end

print lookup_vendor first :mac_list
foreach butfirst :mac_list [
wait 90
print lookup_vendor ?
]
bye
bye</syntaxhighlight>
{{Out}}
<pre>Intel Corporate
Apple, Inc.
Cisco Systems, Inc
PEGATRON CORPORATION
Dell Inc.</pre>


=={{header|Lua}}==
=={{header|Lua}}==
<lang lua>-- Requires LuaSocket extension by Lua
<syntaxhighlight lang="lua">-- Requires LuaSocket extension by Lua
-- Created by James A. Donnell Jr.
-- Created by James A. Donnell Jr.
-- www.JamesDonnell.com
-- www.JamesDonnell.com
Line 689: Line 860:


local macAddress = "FC-A1-3E-2A-1C-33"
local macAddress = "FC-A1-3E-2A-1C-33"
print(lookup(macAddress))</lang>
print(lookup(macAddress))</syntaxhighlight>


=={{header|M2000 Interpreter}}==
=={{header|M2000 Interpreter}}==
<syntaxhighlight lang="m2000 interpreter">
<lang M2000 Interpreter>
Module Checkit {
Module Checkit {
httpGet$=lambda$ (url$, timeout=500)->{
httpGet$=lambda$ (url$, timeout=500)->{
Line 709: Line 880:
declare htmldoc nothing
declare htmldoc nothing
}
}
Urls=("88:53:2E:67:07:BE", "FC:FB:FB:01:FA:21", "D4:F4:6F:C9:EF:8D", "23:45:67")
Urls=("88:53:2E:67:07:BE", "FC:FB:FB:01:FA:21", "D4:F4:6F:C9:EF:8D", "BC:5F:F4")
url=each(URLs)
url=each(URLs)
While Url {
While Url {
Print Array$(URL), httpGet$("http://api.macvendors.com/"+Array$(URL))
Print Array$(URL),@(20), httpGet$("https://api.macvendors.com/"+Array$(URL))
Wait 20
Wait 1500
}
}
}
}
Checkit
Checkit
</syntaxhighlight>
</lang>


=={{header|Mathematica}}/{{header|Wolfram Language}}==
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<lang Mathematica>macLookup[mac_String] := Quiet[Check[Import["http://api.macvendors.com/" <> mac], "N/A"]]</lang>
<syntaxhighlight lang="mathematica">macLookup[mac_String] := Quiet[Check[Import["http://api.macvendors.com/" <> mac], "N/A"]]</syntaxhighlight>
Examples:<lang Mathematica>macLookup["00-14-22-01-23-45"]</lang>
Examples:<syntaxhighlight lang="mathematica">macLookup["00-14-22-01-23-45"]</syntaxhighlight>
Outputs:<pre>Dell Inc.</pre>
Outputs:<pre>Dell Inc.</pre>

=={{header|MiniScript}}==
This implementation is for use with the [http://miniscript.org/MiniMicro Mini Micro] version of MiniScript.
<syntaxhighlight lang="miniscript">
macList = ["88:53:2E:67:07:BE", "FC:FB:FB:01:FA:21", "00:02:55:00:00:00",
"D4:F4:6F:C9:EF:8D", "23:45:67", "18:93:D7", "1C:A6:81"]

for mac in macList
ret = http.get("http://api.macvendors.com/"+mac)
if ret == "HTTP/1.1 404 Not Found" then ret = "N/A"
print ret
wait 1
end for
</syntaxhighlight>
{{out}}
<pre>
Intel Corporate
Cisco Systems, Inc
IBM Corp
Apple, Inc.
N/A
Texas Instruments
HUAWEI TECHNOLOGIES CO.,LTD
</pre>


=={{header|Nim}}==
=={{header|Nim}}==


<lang Nim>import httpclient
<syntaxhighlight lang="nim">import httpclient


for mac in ["FC-A1-3E", "FC:FB:FB:01:FA:21", "BC:5F:F4"]:
for mac in ["FC-A1-3E", "FC:FB:FB:01:FA:21", "BC:5F:F4"]:
echo newHttpClient().getContent("http://api.macvendors.com/"&mac)</lang>
echo newHttpClient().getContent("http://api.macvendors.com/"&mac)</syntaxhighlight>


{{out}}
{{out}}
Line 736: Line 931:
ASRock Incorporation
ASRock Incorporation
</pre>
</pre>

=={{header|Nu}}==
<syntaxhighlight lang="nu">
let mactable = http get "http://standards-oui.ieee.org/oui/oui.csv" | from csv --no-infer

def get-mac-org [] {
let assignment = $in | str upcase | str replace --all --regex "[^A-Z0-9]" "" | str substring 0..6
$mactable | where Assignment == $assignment | try {first | get "Organization Name"} catch {"N/A"}
}

# Test cases from the Ada entry
let macs = [
# Should succeed
"88:53:2E:67:07:BE"
"D4:F4:6F:C9:EF:8D"
"FC:FB:FB:01:FA:21"
"4c:72:b9:56:fe:bc"
"00-14-22-01-23-45"
# Should fail
"23-45-67"
"foobar"
]

$macs | each {{MAC: $in, Vendor: ($in | get-mac-org)}}
</syntaxhighlight>
{{out}}
<pre>
╭───┬───────────────────┬──────────────────────╮
│ # │ MAC │ Vendor │
├───┼───────────────────┼──────────────────────┤
│ 0 │ 88:53:2E:67:07:BE │ Intel Corporate │
│ 1 │ D4:F4:6F:C9:EF:8D │ Apple, Inc. │
│ 2 │ FC:FB:FB:01:FA:21 │ Cisco Systems, Inc │
│ 3 │ 4c:72:b9:56:fe:bc │ PEGATRON CORPORATION │
│ 4 │ 00-14-22-01-23-45 │ Dell Inc. │
│ 5 │ 23-45-67 │ N/A │
│ 6 │ foobar │ N/A │
╰───┴───────────────────┴──────────────────────╯
</pre>

=={{header|OCaml}}==
=={{header|OCaml}}==
<syntaxhighlight lang="ocaml">
<lang OCaml>
(* build with ocamlfind ocamlopt -package netclient -linkpkg macaddr.ml -o macaddr *)
(* build with ocamlfind ocamlopt -package netclient -linkpkg macaddr.ml -o macaddr *)


Line 773: Line 1,008:




</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre>
<pre>
Line 785: Line 1,020:


=={{header|Perl}}==
=={{header|Perl}}==
<lang perl>#!/usr/bin/env perl -T
<syntaxhighlight lang="perl">#!/usr/bin/env perl -T
use 5.018_002;
use v5.18.2;
use warnings;
use warnings;
use LWP;
use LWP;
use Time::HiRes qw(sleep);


our $VERSION = 1.000_000;
our $VERSION = 1.000_000;
Line 794: Line 1,030:
my $ua = LWP::UserAgent->new;
my $ua = LWP::UserAgent->new;


no warnings 'qw';
my @macs = (
my @macs = qw(
'FC-A1-3EFC:FB:FB:01:FA:21', '00,0d,4b',
FC-A1-3EFC:FB:FB:01:FA:21 00,0d,4b
'Rhubarb', '00-14-22-01-23-45',
'10:dd:b1', 'D4:F4:6F:C9:EF:8D',
Rhubarb 00-14-22-01-23-45
'FC-A1-3E', '88:53:2E:67:07:BE',
10:dd:b1 D4:F4:6F:C9:EF:8D
'23:45:67', 'FC:FB:FB:01:FA:21',
FC-A1-3E 88:53:2E:67:07:BE
23:45:67 FC:FB:FB:01:FA:21
'BC:5F:F4',
BC:5F:F4
);
);


for my $mac (@macs) {
while (my $mac = shift @macs) {
my $vendor = get_mac_vendor($mac);
my $vendor = get_mac_vendor($mac);
if ($vendor) {
if ($vendor) {
say "$mac = $vendor";
say "$mac = $vendor";
}
}
sleep 1.5 if @macs;
}
}


Line 850: Line 1,088:
# }
# }
# return;
# return;
#}</lang>
#}</syntaxhighlight>


{{out}}
{{out}}
Line 865: Line 1,103:
=={{header|Phix}}==
=={{header|Phix}}==
{{libheader|Phix/libcurl}}
{{libheader|Phix/libcurl}}
<!--<lang Phix>(notonline)-->
<!--<syntaxhighlight lang="phix">(notonline)-->
<span style="color: #008080;">without</span> <span style="color: #008080;">js</span> <span style="color: #000080;font-style:italic;">-- libcurl</span>
<span style="color: #008080;">without</span> <span style="color: #008080;">js</span> <span style="color: #000080;font-style:italic;">-- libcurl</span>
<span style="color: #004080;">string</span> <span style="color: #000000;">test</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">"00-11-22-33-44-55-66"</span> <span style="color: #000080;font-style:italic;">-- CIMSYS Inc
<span style="color: #004080;">string</span> <span style="color: #000000;">test</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">"00-11-22-33-44-55-66"</span> <span style="color: #000080;font-style:italic;">-- CIMSYS Inc
Line 886: Line 1,124:
<span style="color: #7060A8;">curl_easy_cleanup</span><span style="color: #0000FF;">(</span><span style="color: #000000;">curl</span><span style="color: #0000FF;">)</span>
<span style="color: #7060A8;">curl_easy_cleanup</span><span style="color: #0000FF;">(</span><span style="color: #000000;">curl</span><span style="color: #0000FF;">)</span>
<span style="color: #7060A8;">curl_global_cleanup</span><span style="color: #0000FF;">()</span>
<span style="color: #7060A8;">curl_global_cleanup</span><span style="color: #0000FF;">()</span>
<!--</lang>-->
<!--</syntaxhighlight>-->
{{out}}
{{out}}
<pre>
<pre>
Line 892: Line 1,130:
</pre>
</pre>


=={{header|PicoLisp}}==
=={{header|PHP}}==
{{trans|AppleScript}}
<lang PicoLisp>(load "@lib/http.l")
<syntaxhighlight lang="php"><?php
$apiRoot = "https://api.macvendors.com";
$macList = array("88:53:2E:67:07:BE", "D4:F4:6F:C9:EF:8D",
"FC:FB:FB:01:FA:21", "4c:72:b9:56:fe:bc", "00-14-22-01-23-45");


$curl = curl_init();
(de maclookup (M)
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
(client "api.macvendors.com" 80
foreach ($macList as $burger) {
M
curl_setopt($curl, CURLOPT_URL, "$apiRoot/$burger");
(while (line))
echo(curl_exec($curl));
(line T) ) )
echo("\n");
(test
sleep(2);
"Intel Corporate"
}
(maclookup "88:53:2E:67:07:BE") )
curl_close($curl);
(test
?></syntaxhighlight>
"Apple, Inc."

(maclookup "D4:F4:6F:C9:EF:8D") )</lang>
{{Out}}
<pre>Intel Corporate
Apple, Inc.
Cisco Systems, Inc
PEGATRON CORPORATION
Dell Inc.</pre>

=={{header|PowerShell}}==
{{trans|AppleScript}}
<syntaxhighlight lang="powershell">$apiRoot = "http://api.macvendors.com"
$macAddresses = @("88:53:2E:67:07:BE", "D4:F4:6F:C9:EF:8D",
"FC:FB:FB:01:FA:21", "4c:72:b9:56:fe:bc",
"00-14-22-01-23-45")

$macAddresses | % {
(Invoke-WebRequest "$apiRoot/$_").Content
Start-Sleep 1.5
}</syntaxhighlight>

{{Out}}
<pre>Intel Corporate
Apple, Inc.
Cisco Systems, Inc
PEGATRON CORPORATION
Dell Inc.</pre>


=={{header|Python}}==
=={{header|Python}}==
<lang python>import requests
{{libheader|requests}}

<syntaxhighlight lang="python">import requests


for addr in ['88:53:2E:67:07:BE', 'FC:FB:FB:01:FA:21',
for addr in ['88:53:2E:67:07:BE', 'FC:FB:FB:01:FA:21',
'D4:F4:6F:C9:EF:8D', '23:45:67']:
'D4:F4:6F:C9:EF:8D', '23:45:67']:
vendor = requests.get('http://api.macvendors.com/' + addr).text
vendor = requests.get('http://api.macvendors.com/' + addr).text
print(addr, vendor)</lang>
print(addr, vendor)</syntaxhighlight>
{{out}}
{{out}}
<pre>88:53:2E:67:07:BE Intel Corporate
<pre>88:53:2E:67:07:BE Intel Corporate
Line 922: Line 1,191:


=={{header|Racket}}==
=={{header|Racket}}==
<lang racket>#lang racket
<syntaxhighlight lang="racket">#lang racket


(require net/url)
(require net/url)
Line 935: Line 1,204:
"FC:FB:FB:01:FA:21"
"FC:FB:FB:01:FA:21"
"D4:F4:6F:C9:EF:8D"))))
"D4:F4:6F:C9:EF:8D"))))
(printf "~a\t~a~%" i (lookup-MAC-address i))))</lang>
(printf "~a\t~a~%" i (lookup-MAC-address i))))</syntaxhighlight>


{{out}}
{{out}}
Line 947: Line 1,216:
Apparently there is some rate limiting on place now, sleep a bit between requests.
Apparently there is some rate limiting on place now, sleep a bit between requests.


<lang perl6>use HTTP::UserAgent;
<syntaxhighlight lang="raku" line>use HTTP::UserAgent;
my $ua = HTTP::UserAgent.new;
my $ua = HTTP::UserAgent.new;
Line 971: Line 1,240:
00:0d:4b
00:0d:4b
23:45:67
23:45:67
> -> $mac { say lookup $mac }</lang>
> -> $mac { say lookup $mac }</syntaxhighlight>
{{out}}
{{out}}
<pre>ASRock Incorporation
<pre>ASRock Incorporation
Line 981: Line 1,250:


=={{header|Red}}==
=={{header|Red}}==
<lang Red>print read rejoin [http://api.macvendors.com/ ask "MAC address: "]
<syntaxhighlight lang="red">print read rejoin [http://api.macvendors.com/ ask "MAC address: "]
</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre>MAC address: 88:53:2E:67:07:BE
<pre>MAC address: 88:53:2E:67:07:BE
Line 989: Line 1,258:
=={{header|REXX}}==
=={{header|REXX}}==
This REXX version only works under Microsoft Windows and Regina REXX.
This REXX version only works under Microsoft Windows and Regina REXX.
<lang rexx>/*REXX pgm shows a network device's manufacturer based on the Media Access Control addr.*/
<syntaxhighlight lang="rexx">/*REXX pgm shows a network device's manufacturer based on the Media Access Control addr.*/
win_command = 'getmac' /*name of the Microsoft Windows command*/
win_command = 'getmac' /*name of the Microsoft Windows command*/
win_command_options = '/v /fo list' /*options of " " " */
win_command_options = '/v /fo list' /*options of " " " */
Line 1,014: Line 1,283:
if maker=. | MACaddr==. then say 'MAC address manufacturer not found.'
if maker=. | MACaddr==. then say 'MAC address manufacturer not found.'
else say 'manufacturer for MAC address ' MACaddr " is " maker
else say 'manufacturer for MAC address ' MACaddr " is " maker
exit 0 /*stick a fork in it, we're all done. */</lang>
exit 0 /*stick a fork in it, we're all done. */</syntaxhighlight>
{{out|output|text=&nbsp; when using the default input:}}
{{out|output|text=&nbsp; when using the default input:}}
<pre>
<pre>
Line 1,021: Line 1,290:


=={{header|Ring}}==
=={{header|Ring}}==
<lang ring>
<syntaxhighlight lang="ring">
# Project: MAC Vendor Lookup
# Project: MAC Vendor Lookup


Line 1,033: Line 1,302:
url = download("api.macvendors.com/" + mac)
url = download("api.macvendors.com/" + mac)
see url + nl
see url + nl
</syntaxhighlight>
</lang>
Output:
Output:
<pre>
<pre>
Line 1,043: Line 1,312:


=={{header|Ruby}}==
=={{header|Ruby}}==
<lang ruby>require 'net/http'
<syntaxhighlight lang="ruby">require 'net/http'


arr = ['88:53:2E:67:07:BE', 'FC:FB:FB:01:FA:21', 'D4:F4:6F:C9:EF:8D', '23:45:67']
arr = ['88:53:2E:67:07:BE', 'FC:FB:FB:01:FA:21', 'D4:F4:6F:C9:EF:8D', '23:45:67']
Line 1,050: Line 1,319:
vendor = Net::HTTP.get('api.macvendors.com', "/#{addr}/") rescue nil
vendor = Net::HTTP.get('api.macvendors.com', "/#{addr}/") rescue nil
puts "#{addr} #{vendor}"
puts "#{addr} #{vendor}"
end</lang>
end</syntaxhighlight>
{{out}}
{{out}}
<pre>88:53:2E:67:07:BE Intel Corporate
<pre>88:53:2E:67:07:BE Intel Corporate
Line 1,059: Line 1,328:


=={{header|Rust}}==
=={{header|Rust}}==
<lang rust>extern crate reqwest;
<syntaxhighlight lang="rust">extern crate reqwest;


use std::{thread, time};
use std::{thread, time};
Line 1,110: Line 1,379:
}
}
}
}
</syntaxhighlight>
</lang>
Output:
Output:
<pre>
<pre>
Line 1,120: Line 1,389:


=={{header|Scala}}==
=={{header|Scala}}==
<lang scala>object LookUp extends App {
<syntaxhighlight lang="scala">object LookUp extends App {
val macs = Seq("FC-A1-3E", "FC:FB:FB:01:FA:21", "88:53:2E:67:07:BE", "D4:F4:6F:C9:EF:8D")
val macs = Seq("FC-A1-3E", "FC:FB:FB:01:FA:21", "88:53:2E:67:07:BE", "D4:F4:6F:C9:EF:8D")


Line 1,127: Line 1,396:


macs.foreach(mac => println(lookupVendor(mac)))
macs.foreach(mac => println(lookupVendor(mac)))
}</lang>
}</syntaxhighlight>

=={{header|Scheme}}==
{{trans|Applescript}}
{{works with|Chicken Scheme}}
{{libheader|http-client}}
<syntaxhighlight lang="scheme">(import http-client (chicken io))
(define api-root "http://api.macvendors.com")
(define mac-addresses '("88:53:2E:67:07:BE" "D4:F4:6F:C9:EF:8D"
"FC:FB:FB:01:FA:21" "4c:72:b9:56:fe:bc"
"00-14-22-01-23-45"))

(define get-vendor (lambda (mac-address)
(with-input-from-request (string-append api-root "/" mac-address)
#f read-string)))

(display (get-vendor (car mac-addresses)))
(newline)
(map (lambda (burger) (sleep 2) (display (get-vendor burger)) (newline))
(cdr mac-addresses))</syntaxhighlight>
{{Out}}
<pre>Intel Corporate
Apple, Inc.
Cisco Systems, Inc
PEGATRON CORPORATION
Dell Inc.</pre>


=={{header|Tcl}}==
=={{header|Tcl}}==
<lang Tcl>package require http
<syntaxhighlight lang="tcl">package require http


# finally is a bit like go's defer
# finally is a bit like go's defer
Line 1,149: Line 1,443:
foreach mac {00-14-22-01-23-45 88:53:2E:67:07:BE} {
foreach mac {00-14-22-01-23-45 88:53:2E:67:07:BE} {
puts "$mac\t[maclookup $mac]"
puts "$mac\t[maclookup $mac]"
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
Line 1,157: Line 1,451:
=={{header|UNIX Shell}}==
=={{header|UNIX Shell}}==
{{trans|AppleScript}}
{{trans|AppleScript}}
{{works with|Bourne Again SHell}}
Surprising that nobody had implemented the Bash / Shell version yet although the majority of the implementations on this page are just leveraging it.
{{works with|Korn Shell|93+}}
{{works with|Z Shell}}
Surprising that nobody had implemented the Bash / Shell version yet.
<syntaxhighlight lang="bash">macList=(88:53:2E:67:07:BE D4:F4:6F:C9:EF:8D FC:FB:FB:01:FA:21
4c:72:b9:56:fe:bc 00-14-22-01-23-45)

lookup() {
curl -s "http://api.macvendors.com/$1" && echo
}

lookup "${macList[0${ZSH_VERSION:++1}]}"
for burger in "${macList[@]:1}"; do
sleep 2
lookup "$burger"
done</syntaxhighlight>

It can be made to work in a pure-POSIX shell without array variables:
{{works with|Bourne Shell}}
{{works with|Almquist Shell}}
<syntaxhighlight lang="bash">set -- 88:53:2E:67:07:BE D4:F4:6F:C9:EF:8D FC:FB:FB:01:FA:21 \
4c:72:b9:56:fe:bc 00-14-22-01-23-45

lookup() {
curl -s "http://api.macvendors.com/$1" && echo
}

lookup "$1"
shift
for burger; do
sleep 2
curl -s "http://api.macvendors.com/$burger" && echo
done</syntaxhighlight>

And hey, just for completeness, let's toss in a [t]csh version:

{{works with|C Shell}}
<syntaxhighlight lang="csh">set macList=(88:53:2E:67:07:BE D4:F4:6F:C9:EF:8D FC:FB:FB:01:FA:21 \
4c:72:b9:56:fe:bc 00-14-22-01-23-45)

alias lookup curl -s "http://api.macvendors.com/!":1 "&&" echo

lookup "$macList[1]"
foreach burger ($macList[2-]:q)
sleep 2
lookup "$burger"
end</syntaxhighlight>


Shell one liners can be hard to read but are incredibly compact and powerful.
<lang bash>
macList=("88:53:2E:67:07:BE" "D4:F4:6F:C9:EF:8D" "FC:FB:FB:01:FA:21" "4c:72:b9:56:fe:bc" "00-14-22-01-23-45");for burger in ${macList[@]};do curl http://api.macvendors.com/$burger && sleep 5 && echo;done
</lang>
{{out}}
{{out}}
All the above versions have identical output:

<pre>
<pre>
Intel Corporate
Intel Corporate
Line 1,173: Line 1,511:


=={{header|VBScript}}==
=={{header|VBScript}}==
<lang>
<syntaxhighlight lang="text">
a=array("00-20-6b-ba-d0-cb","00-40-ae-04-87-86")
a=array("00-20-6b-ba-d0-cb","00-40-ae-04-87-86")
set WebRequest = CreateObject("WinHttp.WinHttpRequest.5.1")
set WebRequest = CreateObject("WinHttp.WinHttpRequest.5.1")
Line 1,185: Line 1,523:
wscript.echo mac & " -> " & WebRequest.ResponseText
wscript.echo mac & " -> " & WebRequest.ResponseText
next
next
</syntaxhighlight>
</lang>
Output:
Output:
<pre>
<pre>
Line 1,191: Line 1,529:
Spacing next request...
Spacing next request...
00-40-ae-04-87-86 -> DELTA CONTROLS, INC.
00-40-ae-04-87-86 -> DELTA CONTROLS, INC.
</pre>

=={{header|V (Vlang)}}==
<syntaxhighlight lang="v (vlang)">import net.http
import time

const macs =
('
FC-A1-3E
FC:FB:FB:01:FA:21
D4:F4:6F:C9:EF:8D
')

fn main() {
for line in macs.split('\n') {
if line !='' {
println(mac_lookup(line))
time.sleep(2 * time.second) // considerate delay between attempts
}
}
}

fn mac_lookup(mac string) string {
resp := http.get("http://api.macvendors.com/" + mac) or {return 'No data from server'}
return resp.body.str()
}</syntaxhighlight>

{{out}}
<pre>
Samsung Electronics Co.,Ltd
Cisco Systems, Inc
Apple, Inc.
</pre>

=={{header|Visual Basic .NET}}==
Based on the C# sample but works with .Net versions prior to Framework 4.5.<br>
Expects the address to be on the command line, if not specified, it defaults to 88:53:2E:67:07:BE.
<syntaxhighlight lang="vbnet">
' MAC Vendor lookup - based on the C# sample.

Imports System
Imports System.Net

Module LookupMac

Public Sub Main(args() As String)

Dim macAddress As String = If(args.Length < 1, "88:53:2E:67:07:BE", args(0))
Dim uri As New Uri("http://api.macvendors.com/" & WebUtility.UrlEncode(macAddress))
Dim wc As New WebClient()
Console.Out.WriteLine(macAddress & " " & wc.DownloadString(uri))

End Sub

End Module
</syntaxhighlight>
{{out}}
With no address on the command line:
<pre>
88:53:2E:67:07:BE Intel Corporate
</pre>

With FC:FB:FB:01:FA:21 on the command line:
<pre>
FC:FB:FB:01:FA:21 Cisco Systems, Inc
</pre>
</pre>


Line 1,197: Line 1,600:


However, if Wren is embedded in (say) a suitable Go program, then we can ask the latter to do it for us.
However, if Wren is embedded in (say) a suitable Go program, then we can ask the latter to do it for us.
<lang ecmascript>/* mac_vendor_lookup.wren */
<syntaxhighlight lang="wren">/* MAC_vendor_lookup.wren */
class MAC {
class MAC {
foreign static lookup(address)
foreign static lookup(address)
Line 1,204: Line 1,607:
System.print(MAC.lookup("FC:FB:FB:01:FA:21"))
System.print(MAC.lookup("FC:FB:FB:01:FA:21"))
for (i in 1..1e8) {} // slow down request
for (i in 1..1e8) {} // slow down request
System.print(MAC.lookup("23:45:67"))</lang>
System.print(MAC.lookup("23:45:67"))</syntaxhighlight>


which we embed in the following Go program and run it.
which we embed in the following Go program and run it.
{{libheader|WrenGo}}
{{libheader|WrenGo}}
<lang go>/* mac_vendor_lookup.go */
<syntaxhighlight lang="go">/* MAC_vendor_lookup.go */
package main
package main


Line 1,238: Line 1,641:
func main() {
func main() {
vm := wren.NewVM()
vm := wren.NewVM()
fileName := "mac_vendor_lookup.wren"
fileName := "MAC_vendor_lookup.wren"
methodMap := wren.MethodMap{"static lookup(_)": macLookup}
methodMap := wren.MethodMap{"static lookup(_)": macLookup}
classMap := wren.ClassMap{"MAC": wren.NewClass(nil, nil, methodMap)}
classMap := wren.ClassMap{"MAC": wren.NewClass(nil, nil, methodMap)}
Line 1,245: Line 1,648:
vm.InterpretFile(fileName)
vm.InterpretFile(fileName)
vm.Free()
vm.Free()
}</lang>
}</syntaxhighlight>


{{out}}
{{out}}
Line 1,256: Line 1,659:
{{trans|Lua}}
{{trans|Lua}}
Uses libcurl (the multiprotocol file transfer library) to do the web query
Uses libcurl (the multiprotocol file transfer library) to do the web query
<lang zkl>var [const] CURL=Import("zklCurl"); // libcurl
<syntaxhighlight lang="zkl">var [const] CURL=Import("zklCurl"); // libcurl
const MAC_VENDORS="http://api.macvendors.com/";
const MAC_VENDORS="http://api.macvendors.com/";


Line 1,264: Line 1,667:
vender=vender[0].del(0,vender[1]); // remove HTTP header
vender=vender[0].del(0,vender[1]); // remove HTTP header
vender.text; // Data --> String (Data is a byte bucket)
vender.text; // Data --> String (Data is a byte bucket)
}</lang>
}</syntaxhighlight>
<lang zkl>lookUp("FC-A1-3E-2A-1C-33").println();
<syntaxhighlight lang="zkl">lookUp("FC-A1-3E-2A-1C-33").println();
lookUp("4c:72:b9:56:fe:bc").println();
lookUp("4c:72:b9:56:fe:bc").println();
lookUp("foobar").println();</lang>
lookUp("foobar").println();</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 1,276: Line 1,679:


=={{header|Zoea}}==
=={{header|Zoea}}==
<syntaxhighlight lang="zoea">
<lang Zoea>
program: mac_vendor_lookup
program: mac_vendor_lookup


Line 1,284: Line 1,687:
derive: 'http://api.macvendors.com/D4:F4:6F:C9:EF:8D'
derive: 'http://api.macvendors.com/D4:F4:6F:C9:EF:8D'
output: 'Apple, Inc.'
output: 'Apple, Inc.'
</syntaxhighlight>
</lang>


=={{header|Zoea Visual}}==
=={{header|Zoea Visual}}==
[http://zoea.co.uk/examples/zv-rc/MAC_vendor_lookup.png MAC Vendor Lookup]
[http://zoea.co.uk/examples/zv-rc/MAC_vendor_lookup.png MAC Vendor Lookup]

{{omit from|EasyLang|Has no internet functions}}

Latest revision as of 10:32, 30 December 2023

Every connected device around the world comes with a unique Media Access Control address, or a   MAC address.

Task
MAC vendor lookup
You are encouraged to solve this task according to the task description, using any language you may know.

A common task a network administrator may come across is being able to identify a network device's manufacturer when given only a MAC address.


Task

Interface with one (or numerous) APIs that exist on the internet and retrieve the device manufacturer based on a supplied MAC address.

A MAC address that does not return a valid result should return the String "N/A".   An error related to the network connectivity or the API should return a null result.

Many implementations on this page use http://api.macvendors.com/ which, as of 19th September 2021, is throttling requests. After only 2 calls, the following response is returned for all subsequent requests. If you are planning to use the same provider or going to run the examples on this page, consider building in a delay between two calls.

{"errors":{"detail":"Too Many Requests","message":"Please slow down your requests or upgrade your plan at https://macvendors.com"}}

Ada

Library: AWS
with Ada.Text_IO;

with AWS.Client;
with AWS.Response;
with AWS.Messages;

procedure MAC_Vendor is

   procedure Lookup (MAC : in String) is
      use AWS.Response;
      use AWS.Messages;
      URL     : constant String := "http://api.macvendors.com/" & MAC;
      Page    : constant Data   := AWS.Client.Get (URL);
      use Ada.Text_IO;
   begin
      Put (MAC);
      Set_Col (20);
      case AWS.Response.Status_Code (Page) is
         when S200   => Put_Line (Message_Body (Page));
         when S404   => Put_Line ("N/A");
         when others => Put_Line ("Error");
      end case;
   end Lookup;

begin
   --  Have to throttle traffic to site
   Lookup ("88:53:2E:67:07:BE");   delay 1.500;
   Lookup ("D4:F4:6F:C9:EF:8D");   delay 1.500;
   Lookup ("FC:FB:FB:01:FA:21");   delay 1.500;
   Lookup ("4c:72:b9:56:fe:bc");   delay 1.500;
   Lookup ("00-14-22-01-23-45");   delay 1.500;
   Lookup ("23-45-67");            delay 1.500;
   Lookup ("foobar");
end MAC_Vendor;
Output:
88:53:2E:67:07:BE  Intel Corporate
D4:F4:6F:C9:EF:8D  Apple, Inc.
FC:FB:FB:01:FA:21  Cisco Systems, Inc
4c:72:b9:56:fe:bc  PEGATRON CORPORATION
00-14-22-01-23-45  Dell Inc.
23-45-67           N/A
foobar             N/A

APL

Works with: Dyalog APL
Library: HttpCommand

Normally something like this would just be mapping the lookup across an array, but that doesn't let us control the timing of the request dispatch. To insert a delay between requests we have to create a traditional function ("tradfn") with a for loop.

⍝load the library module
]load HttpCommand

⍝ define a direct function (dfn) to look up a single MAC address
vendorLookup1  { (HttpCommand.Get 'http://api.macvendors.com/',⍕).Data }

⍝ define a traditional function to look up all the MAC addresses in a list with
⍝ a delay between calls

⍝ The header says that the function is named vendorLookup, it takes a single
⍝ parameter which we call macList, and the value of the local variable
⍝ vendors will become the function's return value
 vendors   vendorLookup macList 
    ⍝ look up the first vendor and put it into an array in our return var
    vendors  vendorLookup1 1macList
    
    ⍝ Loop over the rest of the array
    :For burger :In 1macList
       ⎕DL 2                              ⍝ wait 2 seconds
       vendors  vendorLookup1 burger   ⍝ then look up the next vendor and append
    :EndFor


⍝ demo data
macList   '88:53:2E:67:07:BE' 'D4:F4:6F:C9:EF:8D' 'FC:FB:FB:01:FA:21' 
macList  '4c:72:b9:56:fe:bc' '00-14-22-01-23-45'

⍝ look up the vendors (takes a while with the 2-second delay between lookups)
vendorList  vendorLookup macList

⍝ the result is an array (a 1-row by N-column matrix). to print out one vendor
⍝ per line, we reshape it to be N rows by 1 column instead. 
{(1⌷⍴) 1  } vendorList
Output:
 Intel Corporate      
 Apple, Inc.          
 Cisco Systems, Inc   
 PEGATRON CORPORATION 
 Dell Inc.        

AppleScript

set apiRoot to "https://api.macvendors.com"
set macList to {"88:53:2E:67:07:BE", "D4:F4:6F:C9:EF:8D", ¬
                "FC:FB:FB:01:FA:21", "4c:72:b9:56:fe:bc", "00-14-22-01-23-45"}

on lookupVendor(macAddr)
  global apiRoot
  return do shell script "curl " & apiRoot & "/" & macAddr
end lookupVendor

set table to { lookupVendor(first item of macList) }
repeat with burger in macList's items 2 thru -1
    delay 1.5
    set end of table to lookupVendor(burger)
end repeat

set text item delimiters to linefeed
return table as string

If this is part of a larger script you probably want to save and restore the text item delimiters:

set savedTID to text item delimiters
set text item delimiters to linefeed
set tableText to table as string
set text item delimiters to savedTID
return tableText
Output:
Intel Corporate
Apple, Inc.
Cisco Systems, Inc
PEGATRON CORPORATION
Dell Inc.

Arturo

loop ["FC-A1-3E" "FC:FB:FB:01:FA:21" "BC:5F:F4"] 'mac [
    print [mac "=>" read ~"http://api.macvendors.com/|mac|"]
    pause 1500
]
Output:
FC-A1-3E => Samsung Electronics Co.,Ltd 
FC:FB:FB:01:FA:21 => Cisco Systems, Inc 
BC:5F:F4 => ASRock Incorporation

AutoHotkey

macLookup(MAC){
	WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
	WebRequest.Open("GET", "http://api.macvendors.com/" MAC)
	WebRequest.Send()
	return WebRequest.ResponseText
}

Examples:

MsgBox % macLookup("00-14-22-01-23-45")

Outputs:

Dell Inc.

BaCon

This code requires BaCon 3.8.2 or higher.

OPTION TLS TRUE

website$ = "api.macvendors.com"
mac$ = "b0:52:16:d0:3c:fb"

OPEN website$ & ":443" FOR NETWORK AS mynet
    SEND "GET /" & mac$ & " HTTP/1.1\r\nHost: " & website$ & "\r\n\r\n" TO mynet
    RECEIVE info$ FROM mynet
CLOSE NETWORK mynet

PRINT TOKEN$(info$, 2, "\r\n\r\n")
Output:
Hon Hai Precision Ind. Co.,Ltd.

BBC BASIC

      DIM Block% 599 : REM Memory buffer to receive GET info
      INSTALL @lib$ + "SOCKLIB" : PROC_initsockets
      
      READ Mac$
      WHILE Mac$ > ""
        WAIT 100 : REM 1 sec pause to avoid 'Too Many Requests' errors
        Socket=FN_tcpconnect("api.macvendors.com", "80")
        I%=FN_writelinesocket(Socket, "GET /" + Mac$ + " HTTP/1.0")
        I%=FN_writelinesocket(Socket, "")
        REPEAT N%=FN_readsocket(Socket, Block%, 600) UNTIL N% > 0
        PROC_closesocket(Socket)
        PRINT Mac$ TAB(24);
        CASE LEFT$($(Block% + 9), 3) OF
          WHEN "200"
            Block%?N%=0                       : REM Add terminating 0x00
            REPEAT N%-=1 UNTIL Block%?N% < 32 : REM Leave only last line
            PRINT $$(Block% + N% + 1)         : REM Print string from memory
          WHEN "404"
            PRINT "N/A"
          OTHERWISE
            PRINT "ERROR"
        ENDCASE
        READ Mac$
      ENDWHILE
      
      PROC_exitsockets
      END
      
      DATA 88:53:2E:67:07:BE, FC:FB:FB:01:FA:21, D4:F4:6F:C9:EF:8D, 10-11-22-33-44-55,
Output:
88:53:2E:67:07:BE       Intel Corporate
FC:FB:FB:01:FA:21       Cisco Systems, Inc
D4:F4:6F:C9:EF:8D       Apple, Inc.
10-11-22-33-44-55       N/A

C

Takes MAC address as input, prints usage on incorrect invocation, requires libcurl

#include <curl/curl.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>

/* Length of http://api.macvendors.com/ */
#define FIXED_LENGTH 16

struct MemoryStruct {
  char *memory;
  size_t size;
};
 
static size_t WriteMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp)
{
  size_t realsize = size * nmemb;
  struct MemoryStruct *mem = (struct MemoryStruct *)userp;
 
  mem->memory = realloc(mem->memory, mem->size + realsize + 1);
 
  memcpy(&(mem->memory[mem->size]), contents, realsize);
  mem->size += realsize;
  mem->memory[mem->size] = 0;
 
  return realsize;
}

void checkResponse(char* str){
	char ref[] = "Vendor not found";
	int len = strlen(str),flag = 1,i;
	
	if(len<16)
		fputs(str,stdout);
	else{
		for(i=0;i<len && i<16;i++)
			flag = flag && (ref[i]==str[i]);
		
		flag==1?fputs("N/A",stdout):fputs(str,stdout);
	}
}

int main(int argC,char* argV[])
{
		if(argC!=2)
			printf("Usage : %s <MAC address>",argV[0]);
		else{
			CURL *curl;
			int len = strlen(argV[1]);
			char* str = (char*)malloc((FIXED_LENGTH + len)*sizeof(char));
			struct MemoryStruct chunk;
			CURLcode res;
 
			chunk.memory = malloc(1);
			chunk.size = 0;  
 
        if ((curl = curl_easy_init()) != NULL) {
				sprintf(str,"http://api.macvendors.com/%s",argV[1]);

                                curl_easy_setopt(curl, CURLOPT_URL, str);
				curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
				curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&chunk);
				
				free(str);
				
				res = curl_easy_perform(curl);
				
                if (res == CURLE_OK) {
				checkResponse(chunk.memory);
                                return EXIT_SUCCESS;
                }
				
                curl_easy_cleanup(curl);
			}
		}
        
        return EXIT_FAILURE;
}

Invocation and output :

C:\rosettaCode>macLookUp 00-11-22-33-44-55-66
CIMSYS Inc
C:\rosettaCode>macLookUp 10-11-22-33-44-55-66
N/A

C#

using System;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;

class Program
{
    static async Task<string> LookupMac(string MacAddress)
    {
        var uri = new Uri("http://api.macvendors.com/" + WebUtility.UrlEncode(MacAddress));
        using (var wc = new HttpClient())
            return await wc.GetStringAsync(uri);
    }
    static void Main(string[] args)
    {
        foreach (var mac in new string[] { "88:53:2E:67:07:BE", "FC:FB:FB:01:FA:21", "D4:F4:6F:C9:EF:8D" })
            Console.WriteLine(mac + "\t" + LookupMac(mac).Result);
        Console.ReadLine();
    }
}
Output:
88:53:2E:67:07:BE       Intel Corporate
FC:FB:FB:01:FA:21       Cisco Systems, Inc
D4:F4:6F:C9:EF:8D       Apple, Inc.

C++

Library: Boost
// This code is based on the example 'Simple HTTP Client' included with
// the Boost documentation.

#include <boost/beast/core.hpp>
#include <boost/beast/http.hpp>
#include <boost/beast/version.hpp>
#include <boost/asio/connect.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <iostream>
#include <string>

bool get_mac_vendor(const std::string& mac, std::string& vendor) {
    namespace beast = boost::beast;
    namespace http = beast::http;
    namespace net = boost::asio;
    using tcp = net::ip::tcp;

    net::io_context ioc;
    tcp::resolver resolver(ioc);
    const char* host = "api.macvendors.com";

    beast::tcp_stream stream(ioc);
    stream.connect(resolver.resolve(host, "http"));

    http::request<http::string_body> req{http::verb::get, "/" + mac, 10};
    req.set(http::field::host, host);
    req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING);
    http::write(stream, req);

    beast::flat_buffer buffer;
    http::response<http::string_body> res;
    http::read(stream, buffer, res);

    bool success = res.result() == http::status::ok;
    if (success)
        vendor = res.body();

    beast::error_code ec;
    stream.socket().shutdown(tcp::socket::shutdown_both, ec);
    if (ec && ec != beast::errc::not_connected)
        throw beast::system_error{ec};

    return success;
}

int main(int argc, char** argv) {
    if (argc != 2 || strlen(argv[1]) == 0) {
        std::cerr << "usage: " << argv[0] << " MAC-address\n";
        return EXIT_FAILURE;
    }
    try {
        std::string vendor;
        if (get_mac_vendor(argv[1], vendor)) {
            std::cout << vendor << '\n';
            return EXIT_SUCCESS;
        } else {
            std::cout << "N/A\n";
        }
    } catch(std::exception const& e) {
        std::cerr << "Error: " << e.what() << std::endl;
    }
    return EXIT_FAILURE;
}
Output:
% ./mac_vendor_lookup 0c:4d:e9:00:00:00
Apple, Inc.

Common Lisp

(quicklisp:quickload :Drakma)            ; or load it in another way

(defun mac-vendor (mac)
  (check-type mac string "A MAC address as a string")
  (multiple-value-bind (vendor status)
    (drakma:http-request (format nil "http://api.macvendors.com/~a" mac))
    (if (= 200 status)
      (format t "~%Vendor is ~a" vendor)
      (error "~%Not a MAC address: ~a" mac))))

Delphi

Library: IdHttp
program MAC_Vendor_Lookup;

{$APPTYPE CONSOLE}

uses
  System.SysUtils,
  IdHttp;

function macLookUp(mac: string): string;
begin
  Result := '';
  with TIdHTTP.Create(nil) do
  begin
    try
      Result := Get('http://api.macvendors.com/' + mac);

    except
      on E: Exception do
        Writeln(e.Message);
    end;
    Free;
  end;
end;

begin
  Writeln(macLookUp('FC-A1-3E'));
  sleep(1000);
  Writeln(macLookUp('FC:FB:FB:01:FA:21'));
  sleep(1000);
  Writeln(macLookUp('BC:5F:F4'));
  readln;
end.
Output:
Samsung Electronics Co.,Ltd
Cisco Systems, Inc
ASRock Incorporation

Factor

USING: accessors calendar continuations http.client io kernel
sequences threads ;

: mac-vendor ( str -- str )
    "http://api.macvendors.com/" prepend
    [ http-get nip ] [ nip response>> message>> ] recover ;

"FC-A1-3E"
"FC:FB:FB:01:FA:21"
"10-11-22-33-44-55-66"
[ mac-vendor print 1 seconds sleep ] tri@
Output:
Samsung Electronics Co.,Ltd
Cisco Systems, Inc
Not Found

FreeBASIC

Function pipeout(Byval s As String = "") Byref As String
    Var f = Freefile
    Dim As String tmp
    Open Pipe s For Input As #f 
    s = ""
    Do Until Eof(f)
        Line Input #f, tmp
        s &= tmp
    Loop
    Close #f
    Return s
End Function 

Function lookupvendor(webpage As String, mac As String) As String
    Return pipeout("powershell " + "(Invoke-WebRequest " + webpage + mac + ")")
End Function

Dim As String macs(1 To 4) = {"FC-A1-3E","FC:FB:FB:01:FA:21","88:53:2E:67:07:BE","D4:F4:6F:C9:EF:8D"}

For i As Integer = 1 To Ubound(macs)
    Var d = lookupvendor("api.macvendors.com/", macs(i))
    Var e = Instr(d, "RawContent")
    Print Mid(d, 66, e-66)
Next i
Sleep
Output:
Samsung Electronics Co.,Ltd
Cisco Systems, Inc
Intel Corporate
Apple, Inc.

Free Pascal

program MACVendorLookup;

uses
  fphttpclient;

var
  res: String;
begin
  if paramCount > 0 then begin

    With TFPHttpClient.Create(Nil) do
    try
      allowRedirect := true;
      try
        res := Get('http://api.macvendors.com/' + ParamStr(1));
        writeLn(res);
      except
        writeLn('N/A');
      end;
    finally
      Free;
    end;
  end;
end.
Output:
./MACVendorLookup 10-11-22-33-44-55-66
N/A

./MACVendorLookup 00-11-22-33-44-55-66
CIMSYS Inc

Go

package main

import (
	"net/http"
	"fmt"
	"io/ioutil"
)

func macLookUp(mac string) (res string){
	resp, _ := http.Get("http://api.macvendors.com/" + mac)
	body, _ := ioutil.ReadAll(resp.Body)
	res = string(body)
	return
}

func main()  {
	fmt.Println(macLookUp("FC-A1-3E"))
	fmt.Println(macLookUp("FC:FB:FB:01:FA:21"))
	fmt.Println(macLookUp("BC:5F:F4"))
}
Output:
Samsung Electronics Co.,Ltd
Cisco Systems, Inc
ASRock Incorporation

Haskell

Works with: GHC version 8.0.2
Library: http-client
#!/usr/bin/env stack
{- stack
  script
  --resolver lts-9.0
  --package bytestring
  --package http-client
  --package http-types
-}

{-# LANGUAGE MultiWayIf #-}

import Control.Exception (try)
import Control.Monad (forM_)
import qualified Data.ByteString.Lazy.Char8 as L8 (ByteString, unpack)
import Network.HTTP.Client
  (Manager, parseRequest, httpLbs, responseStatus, responseBody,
   newManager, defaultManagerSettings, Response, HttpException)
import Network.HTTP.Types.Status (statusIsSuccessful, notFound404)
import System.Environment (getArgs)
import Text.Printf (printf)

fetchURL :: Manager
         -> String
         -> IO (Either HttpException (Response L8.ByteString))
fetchURL mgr url = try $ do
  req <- parseRequest url
  httpLbs req mgr

lookupMac :: Manager -> String -> IO String
lookupMac mgr mac = do
  eth <- fetchURL mgr $ "http://api.macvendors.com/" ++ mac
  return $ case eth of
             Left _ -> "null"
             Right resp -> let body = responseBody resp
                               status = responseStatus resp
                           in if | status == notFound404 -> "N/A"
                                 | not (statusIsSuccessful status) -> "null"
                                 | otherwise -> L8.unpack body

main :: IO ()
main = do
  args <- getArgs
  mgr <- newManager defaultManagerSettings
  forM_ args $ \mac -> do
    putStr $ printf "%-17s" mac ++ " = "
    vendor <- lookupMac mgr mac
    putStrLn vendor
Output:
$ ./RosettaMac.hs 00:15:ed:f0:00:00 ff:ff:ff:ff:ff:ff 88:53:2E:67:07:BE FC:FB:FB:01:FA:21 D4:F4:6F:C9:EF:8D banana
00:15:ed:f0:00:00 = Fulcrum Microsystems, Inc.
ff:ff:ff:ff:ff:ff = N/A
88:53:2E:67:07:BE = Intel Corporate
FC:FB:FB:01:FA:21 = Cisco Systems, Inc
D4:F4:6F:C9:EF:8D = Apple, Inc.
banana            = N/A

J

Solution

require 'web/gethttp'
lookupMACvendor=: [: gethttp 'http://api.macvendors.com/'&,

Example Usage

   addr=: '88:53:2E:67:07:BE';'FC:FB:FB:01:FA:21';'D4:F4:6F:C9:EF:8D';'23:45:67'
   (,&'   ' , lookupMACvendor)&> addr
88:53:2E:67:07:BE   Intel Corporate   
FC:FB:FB:01:FA:21   Cisco Systems, Inc
D4:F4:6F:C9:EF:8D   Apple, Inc.       
23:45:67   Vendor not found

Java

package com.jamesdonnell.MACVendor;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

/** MAC Vendor Lookup class.
 * www.JamesDonnell.com
 * @author James A. Donnell Jr. */
public class Lookup {
	/** Base URL for API. The API from www.macvendors.com was chosen. */
	private static final String baseURL = "http://api.macvendors.com/";

	/** Performs lookup on MAC address(es) supplied in arguments.
	 * @param args MAC address(es) to lookup. */
	public static void main(String[] args) {
		for (String arguments : args)
			System.out.println(arguments + ": " + get(arguments));
	}

	/** Performs lookup on supplied MAC address.
	 * @param macAddress MAC address to lookup.
	 * @return Manufacturer of MAC address. */
	private static String get(String macAddress) {
		try {
			StringBuilder result = new StringBuilder();
			URL url = new URL(baseURL + macAddress);
			HttpURLConnection conn = (HttpURLConnection) url.openConnection();
			conn.setRequestMethod("GET");
			BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
			String line;
			while ((line = rd.readLine()) != null) {
				result.append(line);
			}
			rd.close();
			return result.toString();
		} catch (FileNotFoundException e) {
			// MAC not found
			return "N/A";
		} catch (IOException e) {
			// Error during lookup, either network or API.
			return null;
		}
	}
}

Java 11

 
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.List;
import java.util.concurrent.TimeUnit;

public final class MacVendorLookup {

	public static void main(String[] aArgs) throws InterruptedException, IOException {		
		for ( String macAddress : macAddresses ) {
			HttpResponse<String> response = getMacVendor(macAddress);
			System.out.println(macAddress + "  " + response.statusCode() + "  " + response.body());
			
			TimeUnit.SECONDS.sleep(2);
		}		
	}

	private static HttpResponse<String> getMacVendor(String aMacAddress) throws IOException, InterruptedException {				
		URI uri = URI.create(BASE_URL + aMacAddress);
		HttpClient client = HttpClient.newHttpClient();
		HttpRequest request = HttpRequest
			.newBuilder()
		    .uri(uri)
		    .header("accept", "application/json")
		    .GET()
		    .build();
		
		HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
		
		return response;
	}
	
	private static final String BASE_URL = "http://api.macvendors.com/";
	
	private static final List<String> macAddresses = List.of("88:53:2E:67:07:BE",
															 "D4:F4:6F:C9:EF:8D",
															 "FC:FB:FB:01:FA:21",
															 "4c:72:b9:56:fe:bc",
															 "00-14-22-01-23-45"
															 );	
	
}
Output:
88:53:2E:67:07:BE  200  Intel Corporate
D4:F4:6F:C9:EF:8D  200  Apple, Inc.
FC:FB:FB:01:FA:21  200  Cisco Systems, Inc
4c:72:b9:56:fe:bc  200  PEGATRON CORPORATION
00-14-22-01-23-45  200  Dell Inc.

JavaScript

var mac = "88:53:2E:67:07:BE";
function findmac(){
	window.open("http://api.macvendors.com/" + mac);
}

findmac();
Output:
Intel Corporate

Julia

# v0.6.0

using Requests

function getvendor(addr::String)
    try
        get("http://api.macvendors.com/$addr") |> readstring
    catch e
        nothing
    end
end

for addr in ["88:53:2E:67:07:BE", "FC:FB:FB:01:FA:21", "D4:F4:6F:C9:EF:8D", "23:45:67"]
    println("$addr -> ", getvendor(addr))
end
Output:
88:53:2E:67:07:BE -> Intel Corporate
FC:FB:FB:01:FA:21 -> Cisco Systems, Inc
D4:F4:6F:C9:EF:8D -> Apple, Inc.
23:45:67 -> Vendor not found

Kotlin

// version 1.1.2

import java.net.URL

fun lookupVendor(mac: String) = URL("http://api.macvendors.com/" + mac).readText()

fun main(args: Array<String>) {
    val macs = arrayOf("FC-A1-3E", "FC:FB:FB:01:FA:21", "88:53:2E:67:07:BE", "D4:F4:6F:C9:EF:8D")
    for (mac in macs) println(lookupVendor(mac))
}
Output:
Samsung Electronics Co.,Ltd
Cisco Systems, Inc
Intel Corporate
Apple, Inc.

Works with: UCB Logo
make "api_root "http://api.macvendors.com/
make "mac_list [88:53:2E:67:07:BE D4:F4:6F:C9:EF:8D FC:FB:FB:01:FA:21
                4c:72:b9:56:fe:bc 00-14-22-01-23-45]

to lookup_vendor :mac
  output first shell (sentence [curl -s] (word :api_root :mac) [&& echo])
end

print lookup_vendor first :mac_list
foreach butfirst :mac_list [
  wait 90
  print lookup_vendor ?
]
bye
bye
Output:
Intel Corporate
Apple, Inc.
Cisco Systems, Inc
PEGATRON CORPORATION
Dell Inc.

Lua

-- Requires LuaSocket extension by Lua
-- Created by James A. Donnell Jr.
-- www.JamesDonnell.com

local baseURL = "http://api.macvendors.com/"

local function lookup(macAddress)
	http = require "socket.http"
	result, statuscode, content = http.request(baseURL .. macAddress)
	return result
end

local macAddress = "FC-A1-3E-2A-1C-33"
print(lookup(macAddress))

M2000 Interpreter

Module Checkit {
      httpGet$=lambda$  (url$, timeout=500)->{
            declare htmldoc "WinHttp.WinHttpRequest.5.1"
            Method htmldoc "SetTimeouts", timeout, timeout, timeout, timeout
            Method htmldoc "open","GET", url$, false
            Method htmldoc "setRequestHeader","Content-Type", "application/x-www-form-urlencoded"
            Method htmldoc "send"
            With  htmldoc, "responseText" as ready$ 
            res$=trim$(ready$)
            if left$(res$,1)="{" then 
                  ="N/A"
            else
                   =res$
            end if
            declare htmldoc nothing
      }
       Urls=("88:53:2E:67:07:BE", "FC:FB:FB:01:FA:21", "D4:F4:6F:C9:EF:8D", "BC:5F:F4")
       url=each(URLs)
       While Url {
             Print Array$(URL),@(20), httpGet$("https://api.macvendors.com/"+Array$(URL))
             Wait 1500
      }
}
Checkit

Mathematica/Wolfram Language

macLookup[mac_String] := Quiet[Check[Import["http://api.macvendors.com/" <> mac], "N/A"]]

Examples:

macLookup["00-14-22-01-23-45"]

Outputs:

Dell Inc.

MiniScript

This implementation is for use with the Mini Micro version of MiniScript.

macList = ["88:53:2E:67:07:BE", "FC:FB:FB:01:FA:21", "00:02:55:00:00:00",
           "D4:F4:6F:C9:EF:8D", "23:45:67", "18:93:D7", "1C:A6:81"]

for mac in macList
	ret = http.get("http://api.macvendors.com/"+mac)
	if ret == "HTTP/1.1 404 Not Found" then ret = "N/A"
	print ret
	wait 1
end for
Output:
Intel Corporate
Cisco Systems, Inc
IBM Corp
Apple, Inc.
N/A
Texas Instruments
HUAWEI TECHNOLOGIES CO.,LTD

Nim

import httpclient

for mac in ["FC-A1-3E", "FC:FB:FB:01:FA:21", "BC:5F:F4"]:
  echo newHttpClient().getContent("http://api.macvendors.com/"&mac)
Output:
Samsung Electronics Co.,Ltd
Cisco Systems, Inc
ASRock Incorporation

Nu

let mactable = http get "http://standards-oui.ieee.org/oui/oui.csv" | from csv --no-infer

def get-mac-org [] {
	let assignment = $in | str upcase | str replace --all --regex "[^A-Z0-9]" "" | str substring 0..6
	$mactable | where Assignment == $assignment | try {first | get "Organization Name"} catch {"N/A"}
}

# Test cases from the Ada entry
let macs = [
	# Should succeed
	"88:53:2E:67:07:BE"
	"D4:F4:6F:C9:EF:8D"
	"FC:FB:FB:01:FA:21"
	"4c:72:b9:56:fe:bc"
	"00-14-22-01-23-45"
	# Should fail
	"23-45-67"
	"foobar"
]

$macs | each {{MAC: $in, Vendor: ($in | get-mac-org)}}
Output:
╭───┬───────────────────┬──────────────────────╮
│ # │        MAC        │        Vendor        │
├───┼───────────────────┼──────────────────────┤
│ 0 │ 88:53:2E:67:07:BE │ Intel Corporate      │
│ 1 │ D4:F4:6F:C9:EF:8D │ Apple, Inc.          │
│ 2 │ FC:FB:FB:01:FA:21 │ Cisco Systems, Inc   │
│ 3 │ 4c:72:b9:56:fe:bc │ PEGATRON CORPORATION │
│ 4 │ 00-14-22-01-23-45 │ Dell Inc.            │
│ 5 │ 23-45-67          │ N/A                  │
│ 6 │ foobar            │ N/A                  │
╰───┴───────────────────┴──────────────────────╯

OCaml

(* build with ocamlfind ocamlopt -package netclient -linkpkg macaddr.ml -o macaddr *)

open Printf
open Nethttp_client.Convenience
open Unix

(* example vendors, including a nonsense one *)

let vendors = ["FF:FF:FF:67:07:BE"; "D4:F4:6F:C9:EF:8D"; "FC:FB:FB:01:FA:21"; "88:53:2E:67:07:BE"]

let get_vendor addr =
  sleep 3; (* built-in delay to handle rate-limiting at macvendors.com *)
  
  let client = http_get_message ("http://api.macvendors.com/" ^ addr) in
  match client # response_status_code with
  | 200 -> client # response_body # value
  | 404 -> "N/A"
  | _ -> "NULL"
             
let rec parse_vendors vendors =
  match vendors with
  | [] -> []
  | hd::tl -> get_vendor hd :: parse_vendors tl

let rec print_vendors vendor_list =
  match vendor_list with
  | [] -> ""
  | hd::tl -> printf "%s\n" hd; print_vendors tl
  
let main =
  let vendor_list = parse_vendors vendors in
  print_vendors vendor_list
Output:
N/A
Apple, Inc.
Cisco Systems, Inc
Intel Corporate


Perl

#!/usr/bin/env perl -T
use v5.18.2;
use warnings;
use LWP;
use Time::HiRes qw(sleep);

our $VERSION = 1.000_000;

my $ua = LWP::UserAgent->new;

no warnings 'qw';
my @macs = qw(
    FC-A1-3EFC:FB:FB:01:FA:21 00,0d,4b
    Rhubarb                   00-14-22-01-23-45
    10:dd:b1                  D4:F4:6F:C9:EF:8D
    FC-A1-3E                  88:53:2E:67:07:BE
    23:45:67                  FC:FB:FB:01:FA:21
    BC:5F:F4
);

while (my $mac = shift @macs) {
    my $vendor = get_mac_vendor($mac);
    if ($vendor) {
        say "$mac = $vendor";
    }
    sleep 1.5 if @macs;
}

sub get_mac_vendor {
    my $s = shift;

    my $req = HTTP::Request->new( GET => "http://api.macvendors.com/$s" );
    my $res = $ua->request($req);

    # A error related to the network connectivity or the API should
    # return a null result.
    if ( $res->is_error ) {
        return;
    }

    # A MAC address that does not return a valid result should
    # return the String "N/A".
    if (  !$res->content
        or $res->content eq 'Vendor not found' )
    {
        return 'N/A';
    }

    return $res->content;
}

# IEEE 802:
#  Six groups of two hexadecimal digits separated by hyphens or colons,
#    like 01-23-45-67-89-ab or 01:23:45:67:89:ab
#  Three groups of four hexadecimal digits separated by dots (.),
#    like 0123.4567.89ab
#sub validmac {
#    my $s = shift;
#
#    my $hex    = qr{ [A-Fa-f[:digit:]] }xms;
#    my $hex2ws = qr{ [-:] $hex{2} }xms;
#
#    if (   $s =~ m{\A $hex{2} $hex2ws{5} \z}xms
#        or $s =~ m{\A $hex{4} [.] $hex{4}  [.] $hex{4} \z}xms )
#    {
#        return 'true';
#    }
#    return;
#}
Output:
FC-A1-3EFC:FB:FB:01:FA:21 = Samsung Electronics Co.,Ltd
00,0d,4b = Roku, Inc.
00-14-22-01-23-45 = Dell Inc.
10:dd:b1 = Apple, Inc.
D4:F4:6F:C9:EF:8D = Apple, Inc.
FC-A1-3E = Samsung Electronics Co.,Ltd
88:53:2E:67:07:BE = Intel Corporate
FC:FB:FB:01:FA:21 = Cisco Systems, Inc
BC:5F:F4 = ASRock Incorporation

Phix

Library: Phix/libcurl
without js -- libcurl
string test = "00-11-22-33-44-55-66"     -- CIMSYS Inc
--string test = "10-11-22-33-44-55-66"      -- N/A
include builtins/libcurl.e
curl_global_init()
atom curl = curl_easy_init()
string url = sprintf("http://api.macvendors.com/%s",{test})
curl_easy_setopt(curl, CURLOPT_URL, url)
object res = curl_easy_perform_ex(curl)
if string(res) then
    if res="Vendor not found"
    or res=`{"errors":{"detail":"Not Found"}}` then
        res = "N/A"
    end if
    ?res
else
    ?{"error",res}
end if
curl_easy_cleanup(curl)
curl_global_cleanup()
Output:
CIMSYS Inc

PHP

Translation of: AppleScript
<?php
$apiRoot = "https://api.macvendors.com";
$macList = array("88:53:2E:67:07:BE", "D4:F4:6F:C9:EF:8D", 
		 "FC:FB:FB:01:FA:21", "4c:72:b9:56:fe:bc", "00-14-22-01-23-45");

$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
foreach ($macList as $burger) {
  curl_setopt($curl, CURLOPT_URL, "$apiRoot/$burger");
  echo(curl_exec($curl));
  echo("\n");
  sleep(2);
}
curl_close($curl);
?>
Output:
Intel Corporate
Apple, Inc.
Cisco Systems, Inc
PEGATRON CORPORATION
Dell Inc.

PowerShell

Translation of: AppleScript
$apiRoot = "http://api.macvendors.com"
$macAddresses = @("88:53:2E:67:07:BE", "D4:F4:6F:C9:EF:8D",
                  "FC:FB:FB:01:FA:21", "4c:72:b9:56:fe:bc",
                  "00-14-22-01-23-45")

$macAddresses | % {
  (Invoke-WebRequest "$apiRoot/$_").Content
  Start-Sleep 1.5
}
Output:
Intel Corporate
Apple, Inc.
Cisco Systems, Inc
PEGATRON CORPORATION
Dell Inc.

Python

Library: requests
import requests

for addr in ['88:53:2E:67:07:BE', 'FC:FB:FB:01:FA:21',
        'D4:F4:6F:C9:EF:8D', '23:45:67']:
    vendor = requests.get('http://api.macvendors.com/' + addr).text
    print(addr, vendor)
Output:
88:53:2E:67:07:BE Intel Corporate
FC:FB:FB:01:FA:21 Cisco Systems, Inc
D4:F4:6F:C9:EF:8D Apple, Inc.
23:45:67 Vendor not found

Racket

#lang racket

(require net/url)

(define (lookup-MAC-address addr)
  (port->string
   (get-pure-port
    (url "http" #f "api.macvendors.com" #f #t (list (path/param addr null)) null #f))))

(module+ test
(for ((i (in-list '("88:53:2E:67:07:BE"
                    "FC:FB:FB:01:FA:21"
                    "D4:F4:6F:C9:EF:8D"))))
  (printf "~a\t~a~%" i (lookup-MAC-address i))))
Output:
88:53:2E:67:07:BE	Intel Corporate
FC:FB:FB:01:FA:21	Cisco Systems, Inc
D4:F4:6F:C9:EF:8D	Apple, Inc.

Raku

(formerly Perl 6)

Works with: Rakudo version 2018.03

Apparently there is some rate limiting on place now, sleep a bit between requests.

use HTTP::UserAgent;
 
my $ua = HTTP::UserAgent.new;
 
$ua.timeout = 10; # seconds
 
my $server = 'http://api.macvendors.com/';
 
sub lookup ($mac) {
    my $response = $ua.get: "$server+$mac";
    sleep 1;
    return $response.is-success ?? $response.content !! 'N/A';
 
    CATCH {             # Normally you would report some information about what
        default { Nil } # went wrong, but the task specifies to ignore errors.
    }
}
 
for <
BC:5F:F4
FC-A1-3E
10:dd:b1
00:0d:4b
23:45:67
> -> $mac { say lookup $mac }
Output:
ASRock Incorporation
Samsung Electronics Co.,Ltd
Apple, Inc.
Roku, Inc.
N/A

Red

print read rejoin [http://api.macvendors.com/ ask "MAC address: "]
Output:
MAC address: 88:53:2E:67:07:BE
Intel Corporate

REXX

This REXX version only works under Microsoft Windows and Regina REXX.

/*REXX pgm shows a network device's manufacturer based on the Media Access Control addr.*/
win_command         = 'getmac'                   /*name of the Microsoft Windows command*/
win_command_options = '/v /fo list'              /*options  of     "        "       "   */
?3= 'Network Adapter:'                           /*search keywords for Network Adapter. */
?4= 'Physical Address:'                          /*   "       "     "  Physical Address.*/
upper ?3 ?4                                      /*uppercase in case for capitol letters*/
@.=;            @.0= 0                           /*just─in─case values for the keywords.*/
rc= 0                                            /*  "   "   "  value for the returnCode*/
address system win_command win_command_options   with   output stem @.  /*issue command.*/
if rc\==0  then do                               /*display an error if not successful.  */
                say
                say '***error*** from command: '     win_command     win_command_options
                say 'Return code was: '    rc
                say
                exit rc
                end
MACaddr=.                                        /*just─in─case value for the keyword.  */
maker=.                                          /*  "   "   "    "    "   "     "      */
           do j=1  for @.0;  $= @.j;  upper $    /*parse each of the possible responses.*/
           if left($, length(?3))=?3  then maker=   subword(@.j, 3)   /*is this the one?*/
           if left($, length(?4))=?4  then MACaddr= word(@.j, 3)      /* "   "   "   "  */
           end   /*k*/
                                                 /* [↑]  Now, display good or bad stuff.*/
if maker=. | MACaddr==.  then say 'MAC address manufacturer not found.'
                         else say 'manufacturer for MAC address  '  MACaddr "  is  " maker
exit 0                                           /*stick a fork in it,  we're all done. */
output   when using the default input:
manufacturer for MAC address   00-16-17-F9-C8-AA    is    Broadcom NetLink (TM) Gigabit Ethernet

Ring

# Project: MAC Vendor Lookup

load "stdlib.ring"
macs = ["FC-A1-3E","FC:FB:FB:01:FA:21","88:53:2E:67:07:BE","D4:F4:6F:C9:EF:8D"]
for mac = 1 to len(macs)
     lookupvendor(macs[mac])
next

func lookupvendor(mac)
       url = download("api.macvendors.com/" + mac)
       see url + nl

Output:

Samsung Electronics Co.,Ltd
Cisco Systems, Inc
Intel Corporate
Apple, Inc.

Ruby

require 'net/http'

arr = ['88:53:2E:67:07:BE', 'FC:FB:FB:01:FA:21', 'D4:F4:6F:C9:EF:8D', '23:45:67']

arr.each do |addr|
  vendor = Net::HTTP.get('api.macvendors.com', "/#{addr}/") rescue nil
  puts "#{addr}  #{vendor}" 
end
Output:
88:53:2E:67:07:BE  Intel Corporate
FC:FB:FB:01:FA:21  Cisco Systems, Inc
D4:F4:6F:C9:EF:8D  Apple, Inc.
23:45:67  Vendor not found

Rust

extern crate reqwest;

use std::{thread, time};

fn get_vendor(mac: &str) -> Option<String> {
    let mut url = String::from("http://api.macvendors.com/");
    url.push_str(mac);
    let url_ref = &url;
    match reqwest::get(url_ref) {
        Ok(mut res) => match res.text() {
            Ok(text) => {
                if text.contains("Not Found") {
                    Some("N/A".to_string())
                } else {
                    Some(text)
                }
            }
            Err(e) => {
                println!("{:?}", e);
                None
            }
        },
        Err(e) => {
            println!("{:?}", e);
            None
        }
    }
}

fn main() {
    let duration = time::Duration::from_millis(1000);
    match get_vendor("88:53:2E:67:07:BE") {
        None => println!("Error!"),
        Some(text) => println!("{}", text),
    }
    thread::sleep(duration);
    match get_vendor("FC:FB:FB:01:FA:21") {
        None => println!("Error!"),
        Some(text) => println!("{}", text),
    }
    thread::sleep(duration);
    match get_vendor("FC-A1-3E") {
        None => println!("Error!"),
        Some(text) => println!("{}", text),
    }
    thread::sleep(duration);
    match get_vendor("abcdefg") {
        None => println!("Error!"),
        Some(text) => println!("{}", text),
    }
}

Output:

Intel Corporate
Cisco Systems, Inc
Samsung Electronics Co.,Ltd
N/A

Scala

object LookUp extends App {
  val macs = Seq("FC-A1-3E", "FC:FB:FB:01:FA:21", "88:53:2E:67:07:BE", "D4:F4:6F:C9:EF:8D")

  def lookupVendor(mac: String) =
    scala.io.Source.fromURL("""http://api.macvendors.com/""" + mac, "UTF-8").mkString

  macs.foreach(mac => println(lookupVendor(mac)))
}

Scheme

Translation of: Applescript
Works with: Chicken Scheme
Library: http-client
(import http-client (chicken io))
(define api-root "http://api.macvendors.com")
(define mac-addresses '("88:53:2E:67:07:BE" "D4:F4:6F:C9:EF:8D"
                        "FC:FB:FB:01:FA:21" "4c:72:b9:56:fe:bc"
                        "00-14-22-01-23-45"))

(define get-vendor (lambda (mac-address)
  (with-input-from-request (string-append api-root "/" mac-address)
      #f read-string)))

(display (get-vendor (car mac-addresses)))
(newline)
(map (lambda (burger) (sleep 2) (display (get-vendor burger)) (newline))
     (cdr mac-addresses))
Output:
Intel Corporate
Apple, Inc.
Cisco Systems, Inc
PEGATRON CORPORATION
Dell Inc.

Tcl

package require http

# finally is a bit like go's defer
proc finally args {
    tailcall trace add variable :#finally#: unset [list apply [list args $args]]
}

# basic wrapper for http::geturl
proc geturl {url} {
    set tok [::http::geturl $url]
    finally ::http::cleanup $tok
    ::http::data $tok
}   
proc maclookup {mac} {
    geturl http://api.macvendors.com/$mac
}

foreach mac {00-14-22-01-23-45 88:53:2E:67:07:BE} {
    puts "$mac\t[maclookup $mac]"
}
Output:
00-14-22-01-23-45       Dell Inc.
88:53:2E:67:07:BE       Intel Corporate

UNIX Shell

Translation of: AppleScript
Works with: Bourne Again SHell
Works with: Korn Shell version 93+
Works with: Z Shell

Surprising that nobody had implemented the Bash / Shell version yet.

macList=(88:53:2E:67:07:BE D4:F4:6F:C9:EF:8D FC:FB:FB:01:FA:21
         4c:72:b9:56:fe:bc 00-14-22-01-23-45)

lookup() {
  curl -s "http://api.macvendors.com/$1" && echo
}

lookup "${macList[0${ZSH_VERSION:++1}]}"
for burger in "${macList[@]:1}"; do
  sleep 2
  lookup "$burger"
done

It can be made to work in a pure-POSIX shell without array variables:

Works with: Bourne Shell
Works with: Almquist Shell
set -- 88:53:2E:67:07:BE D4:F4:6F:C9:EF:8D FC:FB:FB:01:FA:21 \
       4c:72:b9:56:fe:bc 00-14-22-01-23-45

lookup() {
  curl -s "http://api.macvendors.com/$1" && echo
}

lookup "$1"
shift
for burger; do
  sleep 2
  curl -s "http://api.macvendors.com/$burger" && echo
done

And hey, just for completeness, let's toss in a [t]csh version:

Works with: C Shell
set macList=(88:53:2E:67:07:BE D4:F4:6F:C9:EF:8D FC:FB:FB:01:FA:21 \
             4c:72:b9:56:fe:bc 00-14-22-01-23-45)

alias lookup curl -s "http://api.macvendors.com/!":1 "&&" echo

lookup "$macList[1]"
foreach burger ($macList[2-]:q)
  sleep 2
  lookup "$burger"
end
Output:

All the above versions have identical output:

Intel Corporate
Apple, Inc.
Cisco Systems, Inc
PEGATRON CORPORATION
Dell Inc.

VBScript

a=array("00-20-6b-ba-d0-cb","00-40-ae-04-87-86")
set WebRequest = CreateObject("WinHttp.WinHttpRequest.5.1")

for each MAC in a 
  if b<>0 then   wscript.echo "Spacing next request...": wscript.sleep 2000
  WebRequest.Open "GET", "http://api.macvendors.com/"& mac,1
  WebRequest.Send()
  WebRequest.WaitForResponse 
  b=b+1
  wscript.echo mac & " -> " & WebRequest.ResponseText
next

Output:

00-20-6b-ba-d0-cb -> KONICA MINOLTA HOLDINGS, INC.
Spacing next request...
00-40-ae-04-87-86 -> DELTA CONTROLS, INC.

V (Vlang)

import net.http
import time

const macs = 
('
FC-A1-3E
FC:FB:FB:01:FA:21
D4:F4:6F:C9:EF:8D
')

fn main() {
    for line in macs.split('\n') {
        if line !='' {
            println(mac_lookup(line))
            time.sleep(2 * time.second) // considerate delay between attempts
        }
    }
}

fn mac_lookup(mac string) string {
    resp := http.get("http://api.macvendors.com/" + mac) or {return 'No data from server'}
    return resp.body.str()
}
Output:
Samsung Electronics Co.,Ltd
Cisco Systems, Inc
Apple, Inc.

Visual Basic .NET

Based on the C# sample but works with .Net versions prior to Framework 4.5.
Expects the address to be on the command line, if not specified, it defaults to 88:53:2E:67:07:BE.

' MAC Vendor lookup - based on the C# sample.

Imports System
Imports System.Net

Module LookupMac

    Public Sub Main(args() As String)

        Dim macAddress As String = If(args.Length < 1, "88:53:2E:67:07:BE", args(0))
        Dim uri As New Uri("http://api.macvendors.com/" & WebUtility.UrlEncode(macAddress))
        Dim wc As New WebClient()
        Console.Out.WriteLine(macAddress & "    " & wc.DownloadString(uri))

    End Sub

End Module
Output:

With no address on the command line:

88:53:2E:67:07:BE    Intel Corporate

With FC:FB:FB:01:FA:21 on the command line:

FC:FB:FB:01:FA:21    Cisco Systems, Inc

Wren

Wren CLI doesn't currently expose a way to look up a MAC address.

However, if Wren is embedded in (say) a suitable Go program, then we can ask the latter to do it for us.

/* MAC_vendor_lookup.wren */
class MAC {
    foreign static lookup(address)
}

System.print(MAC.lookup("FC:FB:FB:01:FA:21"))
for (i in 1..1e8) {} // slow down request
System.print(MAC.lookup("23:45:67"))

which we embed in the following Go program and run it.

Library: WrenGo
/* MAC_vendor_lookup.go */
package main

import (
    wren "github.com/crazyinfin8/WrenGo"
    "io/ioutil"
    "net/http"
)

type any = interface{}

func macLookup(vm *wren.VM, parameters []any) (any, error) {
    mac := parameters[1].(string)
    resp, err := http.Get("http://api.macvendors.com/" + mac)
    if err != nil {
        return nil, nil
    }
    body, err := ioutil.ReadAll(resp.Body)
    if err != nil {
        return nil, nil
    }
    var vendor = string(body)
    if vendor == `{"errors":{"detail":"Not Found"}}` {
        return "N/A", nil
    }
    return vendor, nil
}    

func main() {
    vm := wren.NewVM()
    fileName := "MAC_vendor_lookup.wren"
    methodMap := wren.MethodMap{"static lookup(_)": macLookup}
    classMap := wren.ClassMap{"MAC": wren.NewClass(nil, nil, methodMap)}
    module := wren.NewModule(classMap)
    vm.SetModule(fileName, module)
    vm.InterpretFile(fileName)
    vm.Free()
}
Output:
Cisco Systems, Inc
N/A

zkl

Translation of: Lua

Uses libcurl (the multiprotocol file transfer library) to do the web query

var [const] CURL=Import("zklCurl");   // libcurl
const MAC_VENDORS="http://api.macvendors.com/";

fcn lookUp(macAddress){
   httpAddr:=MAC_VENDORS + macAddress;
   vender:=CURL().get(httpAddr); //-->(Data,bytes of header,bytes of trailer)
   vender=vender[0].del(0,vender[1]);  // remove HTTP header
   vender.text;		// Data --> String (Data is a byte bucket)
}
lookUp("FC-A1-3E-2A-1C-33").println();
lookUp("4c:72:b9:56:fe:bc").println();
lookUp("foobar").println();
Output:
Samsung Electronics Co.,Ltd
PEGATRON CORPORATION
Vendor not found

Zoea

program: mac_vendor_lookup

data: 'http://api.macvendors.com/'

input: 'D4:F4:6F:C9:EF:8D'
derive: 'http://api.macvendors.com/D4:F4:6F:C9:EF:8D'
output: 'Apple, Inc.'

Zoea Visual

MAC Vendor Lookup