Overview
Client library for macaddress.io on Python language.
- Free software: MIT
Installation
pip install maclookup
or
git clone https://github.com/CodeLineFi/maclookup-python.git pip install -e /path_to_sdist/
or
cd /path_to_sdist/ python setup.py install
or
cd /path_to_sdist/ easy_install .
Sample code
from maclookup import ApiClient import logging client = ApiClient('Your API key') logging.basicConfig(filename='myapp.log', level=logging.WARNING) print(client.get_raw_data('00A043AAAAAA', 'json')) print(client.get_vendor('BBA043AAAAAA')) print(client.get('BBA043AAAAAA')) response = client.get('00A043AAAAAA') print(response.vendor_details.is_private) print(response.block_details.date_created)
Examples
You may find some examples in the "examples" directory. To run these examples you need to install "maclookup" package. Then you need to create an account on macaddress.io. The last step is defining environment variables with the value of your API key and other settings.
export API_KEY=<Your API key> export LOG_FILENAME=myapp.log export OUTPUT_FILENAME=result.csv
Documentation
maclookup package contains the API client class ApiClient which implements the following functionality
ApiClient methods list:
-
- get(mac): ResponseModel
- Returns ResponseModel object as a parsed API response for a given MAC address or OUI
-
- get_vendor(mac): string
- Returns the company name as text
-
- get_raw_data(mac, output_format): string
- Returns non-parsed API response as string
-
- set_base_url(url)
- Sets base url to url
-
- set_requester(requester)
- Sets instance of Requester
ResponseModel fields:
- vendor_details: VendorDetails
- block_details: BlockDetails
- mac_address_details: MacAddressDetails
VendorDetails fields:
- oui: string
- is_private: boolean (False|True)
- company_name: string
- company_address: string
- country_code: string
BlockDetails fields:
- block_found: boolean (False|True)
- border_left: string (MAC address, may be in the EUI-64)
- border_right: string (MAC address, may be in the EUI-64)
- block_size: int (long long int)
- assignment_block_size: string
- date_created: instance of datetime.datetime
- date_updated: instance of datetime.datetime
MacAddressDetails fields:
- search_term: string
- is_valid: boolean (False|True)
- transmission_type: string
- administration_type: string
If the server returns marker of outdated API version, this library will write a warning to a log.
Development
To install dev requirements, you need to run following commands:
cd /path_to_sdist/ pip install -e .[dev]
To run unit tests, you may use the following command:
cd /path_to_sdist/ python -m unittest discover . "*_test.py"
or this one
cd /path_to_sdist/ tox