Cross-platform network interface enumeration
Project description
netinterfaces
A lightweight and cross-platform Python library to retrieve network interface names with a simple API.
Find on PyPI -
Features
- Single-function API – Quickly retrieve network interface names with minimal effort.
- Cross-platform support – Works on Windows, Linux, and macOS.
- No external dependencies – Pure Python implementation with no additional requirements.
- Consistent output format – Provides a uniform list output across different operating systems.
- Handles errors gracefully – Returns an empty list in case of errors instead of crashing.
Installation
Install netinterfaces
using pip
:
pip install netinterfaces
Usage
Import and use get_interfaces
to retrieve network interface names:
from netinterfaces import get_interfaces
interfaces = get_interfaces()
print(interfaces) # Example output: ['eth0', 'wlan0', 'lo']
Platform-Specific Examples
The library adapts to different platforms and returns interface names accordingly:
- Linux:
['lo', 'eth0', 'wlan0']
- Windows:
['Ethernet', 'Wi-Fi', 'Loopback Pseudo-Interface']
- macOS:
['lo0', 'en0', 'en1']
API Documentation
get_interfaces()
def get_interfaces() -> list:
"""
Retrieves a list of network interface names available on the system.
Returns:
list: A list of network interface names (e.g., ['eth0', 'wlan0', 'lo']).
If an error occurs, an empty list is returned.
"""
Returns
- List of strings: Each string represents a network interface name.
- Empty list: Returned in case of an error (e.g., lack of permissions, unexpected system behavior).
Contributing
Contributions are welcome! To contribute:
- Fork the repository.
- Create a new branch (
feature-branch
). - Implement your changes and write tests if necessary.
- Submit a pull request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
If you encounter any issues or have feature requests, please open an issue on the GitHub repository.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file netinterfaces-0.1.0.tar.gz
.
File metadata
- Download URL: netinterfaces-0.1.0.tar.gz
- Upload date:
- Size: 2.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
7999d30ec698d105b0de669e0908fa8d429a86b813fb2bcce3974ef7dc3d39ff
|
|
MD5 |
65bec8901e0b35d0ede46a18742eee12
|
|
BLAKE2b-256 |
014081b5a7f21e4f18130798da631f1b25db8137a4e044a7632a7086117a134e
|
File details
Details for the file netinterfaces-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: netinterfaces-0.1.0-py3-none-any.whl
- Upload date:
- Size: 2.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
856623047ce676f83840c12ae23d88bd5a457d49bb4db142ce0550e2f078515d
|
|
MD5 |
d680fb37ff41f5efcdf9658451bf0e1c
|
|
BLAKE2b-256 |
4809b733ce6a9b2943b1567e6913472b8925d75927bcf7424a4bdc5b4e91647b
|