A lightweight and efficient Node.js client library for the maclookup.app REST API V2. Easily retrieve vendor and registration information for any MAC address.
- Full MAC Information: Retrieve company name, address, country, block details, and more.
- Built-in Caching: Support for LRU cache to minimize API calls and improve performance.
- Rate Limit Tracking: Automatically parses and provides rate limit information from the API.
- Error Handling: Detailed error messages including API-specific error codes and information.
- Lightweight: Zero-dependency (besides
axiosandlru-cache).
npm install @logocomune/maclookupconst MACLookup = require('@logocomune/maclookup');
// Initialize the client (API key is optional for limited free usage)
const client = new MACLookup('YOUR_API_KEY');
// Recommended: Enable the built-in LRU cache
client.withLRUCache();
client.getMacInfo('00:00:00:01',
(response) => {
const info = response.macInfo;
if (info.found) {
console.log(`Company: ${info.company}`);
console.log(`Country: ${info.country}`);
} else {
console.log('MAC address not found in database.');
}
console.log(`Response Time: ${response.responseTime}ms`);
console.log(`Source: ${response.source}`); // 'api' or 'cache'
console.log(`Remaining Requests: ${response.rateLimit.remaining}`);
},
(error) => {
console.error('An error occurred:', error.msg);
},
() => {
console.log('Lookup completed.');
}
);Creates a new instance of the API client.
apiKey(string): Your API key. Get one at maclookup.app.timeout(number, default: 5000): Request timeout in milliseconds.prefixUrl(string, default: 'https://api.maclookup.app'): Base API URL.
Enables the built-in LRU cache.
max(number, default: 500): Maximum number of items in the cache.ttl(number, default: 3600000): Time-to-live in milliseconds (1 hour default).
Performs a MAC address lookup.
mac(string): The MAC address to look up (formats like00:00:00,00-00-00,00.00.00or000000are supported).successCb(function): Called on successful request. Receives aResponseMACInfoobject.errorCb(function): Called on request error. Receives anErrorMessageobject.alwaysCb(function): Called after the request finishes, regardless of success or failure.
The object returned in the successCb.
status: 'OK' or 'KO'macInfo: Detailed MAC information (see below)rateLimit: Current rate limit statusresponseTime: Time taken for the request in mssource: 'api' or 'cache'
found: booleancompany: string (Company name)address: stringcountry: string (ISO country code)macPrefix: stringblockStart: stringblockEnd: stringblockSize: numberblockType: stringupdated: stringisPrivate: boolean
This project uses Mocha for testing and NYC for coverage.
# Run tests
npm test
# Check coverage
npm run test # Coverage report is displayed after testsThis project is licensed under the MIT License - see the LICENSE file for details.