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.
Release files for netinterfaces 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| netinterfaces-0.1.0.tar.gz | 2.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| netinterfaces-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 4.6 kB
Release files / netinterfaces-0.1.0.tar.gz
| Download URL | netinterfaces-0.1.0.tar.gz |
|---|---|
| Size | 2.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7999d30ec698d105b0de669e0908fa8d429a86b813fb2bcce3974ef7dc3d39ff
|
|
BLAKE2b-256 checksum How to use checksums |
014081b5a7f21e4f18130798da631f1b25db8137a4e044a7632a7086117a134e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.5
|
Release files / netinterfaces-0.1.0-py3-none-any.whl
| Download URL | netinterfaces-0.1.0-py3-none-any.whl |
|---|---|
| Size | 2.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
856623047ce676f83840c12ae23d88bd5a457d49bb4db142ce0550e2f078515d
|
|
BLAKE2b-256 checksum How to use checksums |
4809b733ce6a9b2943b1567e6913472b8925d75927bcf7424a4bdc5b4e91647b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.5
|