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.
Metadata
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 | Provenance | Actions |
|---|---|---|---|---|
| netinterfaces-0.1.0.tar.gz | 2.3 kB | Without provenance | Details for netinterfaces-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| netinterfaces-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for netinterfaces-0.1.0-py3-none-any.whl |
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
|
Security for netinterfaces 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.