updated docs

This commit is contained in:
2025-05-31 21:17:52 +05:00
parent 247eece2a2
commit 9fae6face0

View File

@@ -1,9 +1,7 @@
# MAC Address Vendor Lookup API # MAC Address Vendor Lookup API
A FastAPI service that identifies network device manufacturers from MAC addresses using a three-tier lookup strategy for optimal performance and reliability. A FastAPI service that identifies network device manufacturers from MAC addresses using a three-tier lookup strategy for optimal performance and reliability.
## Features ## Features
- **Multi-format MAC address support**: Accepts various formats (with/without separators) - **Multi-format MAC address support**: Accepts various formats (with/without separators)
- **Partial MAC lookup**: Works with full addresses or just the first 6 digits (OUI) - **Partial MAC lookup**: Works with full addresses or just the first 6 digits (OUI)
- **Three-tier lookup strategy**: - **Three-tier lookup strategy**:
@@ -13,18 +11,18 @@ A FastAPI service that identifies network device manufacturers from MAC addresse
- **Standardized output**: Returns MAC addresses in dash-separated format - **Standardized output**: Returns MAC addresses in dash-separated format
## Supported MAC Address Formats ## Supported MAC Address Formats
All of these formats are accepted: All of these formats are accepted:
- `000000` (OUI only) - `000000` (OUI only)
- `00:00:01` - `00:00:01`
- `00-00-02-AB-CD-EF` - `00-00-02-AB-CD-EF`
- `000003ABCDEF` - `000003ABCDEF`
- `00 00 04 12 34 56` - `00 00 04 12 34 56`
- `70-2A:54` (mixed formats)
- `702A-54` (partial mixed)
## How to Deploy ## How to Deploy
### Using Docker Compose ### Using Docker Compose
```yml ```yml
services: services:
api: api:
@@ -34,7 +32,6 @@ services:
``` ```
### Using Docker ### Using Docker
```bash ```bash
# Pull and run # Pull and run
docker run -p 5000:8000 git.shihaam.dev/shihaam/macvendors docker run -p 5000:8000 git.shihaam.dev/shihaam/macvendors
@@ -44,7 +41,6 @@ docker run -p 5000:8000 -v $(pwd)/mac_list.txt:/app/mac_list.txt git.shihaam.dev
``` ```
### Local Development ### Local Development
```bash ```bash
# Install dependencies # Install dependencies
pip install fastapi uvicorn httpx pip install fastapi uvicorn httpx
@@ -56,13 +52,11 @@ uvicorn macvendorapi:app --host 0.0.0.0 --port 8000
## API Usage ## API Usage
### Endpoint ### Endpoint
``` ```
GET /lookup/{mac_address} GET /lookup/{mac_address}
``` ```
### Examples ### Examples
```bash ```bash
# Basic lookup # Basic lookup
curl http://localhost:5000/lookup/70-22-FE curl http://localhost:5000/lookup/70-22-FE
@@ -73,51 +67,60 @@ curl http://localhost:5000/lookup/70:22:FE
curl http://localhost:5000/lookup/70-22-FE-12-34-56 curl http://localhost:5000/lookup/70-22-FE-12-34-56
``` ```
### Expected Response ## Response Format
### Success Response (HTTP 200)
When a vendor is found:
```json ```json
{ {
"mac_address": "70-22-FE", "mac_address": "70-22-FE",
"vendor": "Apple, Inc." "vendor": "Apple, Inc.",
"detail": null
} }
``` ```
### Error Responses ### Not Found Response (HTTP 404)
When MAC address is valid but vendor is not found:
**Invalid MAC address:**
```json ```json
{ {
"mac_address": "70-22-54",
"vendor": null,
"detail": "Vendor not found"
}
```
### Error Response (HTTP 400)
When MAC address format is invalid:
```json
{
"mac_address": "70-22-HI",
"vendor": null,
"detail": "Invalid MAC address format" "detail": "Invalid MAC address format"
} }
``` ```
**Unknown vendor:** ## HTTP Status Codes
```json - **200 OK**: Valid MAC address with vendor found
{ - **400 Bad Request**: Invalid MAC address format
"mac_address": "FF-FF-FF", - **404 Not Found**: Valid MAC address but vendor not found
"vendor": "Unknown"
}
```
## Local MAC Vendor File ## Local MAC Vendor File
To improve performance, you can provide a local `mac_list.txt` file in the same format as the [IEEE OUI database](https://gist.githubusercontent.com/aallan/b4bb86db86079509e6159810ae9bd3e4/raw/846ae1b646ab0f4d646af9115e47365f4118e5f6/mac-vendor.txt): To improve performance, you can provide a local `mac_list.txt` file in the same format as the [IEEE OUI database](https://gist.githubusercontent.com/aallan/b4bb86db86079509e6159810ae9bd3e4/raw/846ae1b646ab0f4d646af9115e47365f4118e5f6/mac-vendor.txt):
``` ```
000000 Officially Xerox 000000 Officially Xerox
000001 SuperLAN-2U 000001 SuperLAN-2U
000002 BBN (was internal usage only, no longer used) 000002 BBN (was internal usage only, no longer used)
000003 XEROX CORPORATION
``` ```
## Lookup Strategy ## Lookup Strategy
1. **Local File**: Checks `mac_list.txt` first (fastest, no network calls) 1. **Local File**: Checks `mac_list.txt` first (fastest, no network calls)
2. **GitHub Database**: Falls back to the official IEEE OUI database 2. **GitHub Database**: Falls back to the official IEEE OUI database
3. **External API**: Uses macvendors.com API as final fallback 3. **External API**: Uses macvendors.com API as final fallback
4. **Unknown**: Returns "Unknown" if no matches found 4. **Not Found**: Returns vendor not found if no matches are found
## Building from Source ## Building from Source
```bash ```bash
# Clone repository # Clone repository
git clone <repository-url> git clone <repository-url>
@@ -131,7 +134,6 @@ docker run -p 8000:8000 mac-vendor-api
``` ```
## Health Check ## Health Check
```bash ```bash
curl http://localhost:5000/ curl http://localhost:5000/
``` ```