IEEE OUI Database
oui-data provides the IEEE Organizationally Unique Identifier (OUI) database as a static JSON file, enabling programmatic access to MAC address vendor information. The current stable version is 1.1.571. This package primarily serves as a data source, with updates typically tied to upstream IEEE OUI registry changes and dependency bumps, implying an as-needed release cadence rather than a fixed schedule. Its key differentiator is simplicity and direct JSON export, making it easy to consume in environments that support JSON module imports or require/import raw JSON. It eschews any processing logic or API, focusing solely on delivering the raw, structured OUI data.
Common errors
-
SyntaxError: Unexpected token 'with'
cause Your JavaScript environment does not support import attributes (`with {type: 'json'}`) or import assertions (`assert {type: 'json'}`).fixFor CommonJS, use `const ouiData = require('oui-data');`. For ESM, check your Node.js version (needs >=17.1 for assertions) or bundler configuration to ensure support for JSON modules. You might need to directly import `oui-data/index.json` and configure your bundler to handle it as raw JSON. -
TypeError: Cannot read properties of undefined (reading 'company')
cause Attempted to access properties of an OUI entry that does not exist in the database, likely due to a mismatch in the OUI string (e.g., wrong case or non-existent OUI).fixVerify that the OUI string you are using is valid and uppercase. Always check if the lookup result is `undefined` before accessing its properties: `const entry = ouiData[oui.toUpperCase()]; if (entry) { /* ... */ }`.
Warnings
- gotcha Importing JSON files in ECMAScript Modules (ESM) requires specific syntax that varies by environment.
- gotcha The package exports a raw JSON object, not a module with functions. Access data directly using bracket notation.
- gotcha The OUI keys in the JSON are uppercase strings (e.g., '203706'). Ensure your lookup keys are also uppercase for correct matching.
Install
-
npm install oui-data -
yarn add oui-data -
pnpm add oui-data
Imports
- ouiData
import ouiData from 'oui-data';
import ouiData from 'oui-data' with {type: 'json'}; - ouiData
const ouiData = require('oui-data'); - ouiData
import { ouiData } from 'oui-data';import data from 'oui-data/index.json';
Quickstart
import ouiData from 'oui-data' with {type: 'json'};
const lookupOUI = (oui) => {
const entry = ouiData[oui.toUpperCase()];
if (entry) {
return `${entry.company} - ${entry.address}\n${entry.city} ${entry.state} ${entry.zipCode}\n${entry.country}`;
} else {
return `OUI '${oui}' not found.`;
}
};
console.log(lookupOUI('203706'));
// Example for an unknown OUI
console.log(lookupOUI('000000'));