REST API that integrates external transportation services for carrier lookup, debtor data, Gmail workflows, and ELD driver operations.
Integration Utility API is a FastAPI service that centralizes external integrations used by transportation operations. It exposes a unified interface for broker verification, debtor lookup, email automation, and ELD driver management.
- SAFER Carrier Lookup — Query FMCSA SAFER data for carrier verification.
- TAFS Debtor Lookup — Retrieve debtor information from TAFS.
- Gmail Workflows — Send, search, manage attachments, and handle contacts via Google service accounts.
- ELD Driver Operations — Full CRUD and activation/deactivation of ELD drivers.
| Layer | Technology |
|---|---|
| Language | Python 3.12+ |
| Framework | FastAPI |
| Validation | Pydantic v2 |
| HTTP / Scraping | Requests + BeautifulSoup |
| Testing | Pytest |
app/
├── main.py # App entrypoint
├── core/ # Shared models, routers, and utilities
└── services/
├── safer/ # SAFER integration
├── tafs/ # TAFS integration
├── googleCloud/ # Gmail integration
└── eld/ # ELD authentication and driver operations
tests/ # Unit and API tests
docs/
└── API_METHODS.md # Full method reference
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env
uvicorn app.main:app --reloadAPI base URL: http://localhost:8000
All configuration is environment-driven. The .env file is for local development only.
- Never commit secrets or
.envto version control. - All required keys are documented in
.env.examplewith placeholder values.
| Interface | URL |
|---|---|
| Swagger UI | http://localhost:8000/docs |
| ReDoc | http://localhost:8000/redoc |
| Method Reference | docs/API_METHODS.md |
Gmail integration runs via a Google service account with domain-wide delegation — no user OAuth flow is required.
| Operation | Description |
|---|---|
| Send | Send emails on behalf of a delegated user |
| Search | Query the mailbox using Gmail search syntax |
| Attachments | Upload, download, and manage email attachments |
| Contacts | Read and manage Google Contacts for a delegated user |
- Create a service account in Google Cloud Console.
- Enable the Gmail API under APIs & Services → Library.
- Grant domain-wide delegation to the service account in the Google Workspace Admin Console.
- Assign the following OAuth scopes in the Admin Console under Security → API Controls → Domain-wide Delegation:
https://www.googleapis.com/auth/gmail.send
https://www.googleapis.com/auth/gmail.readonly
https://www.googleapis.com/auth/gmail.modify
https://www.googleapis.com/auth/contacts
- Download the service account key JSON and set the path in your
.env:
| Error | Cause | Fix |
|---|---|---|
failedPrecondition / Mail service not enabled |
Gmail disabled for the account or Workspace OU | Enable Gmail in Google Admin Console → Apps → Google Workspace → Gmail |
Precondition check failed |
Account has never logged into Gmail or ToS not accepted | Sign into mail.google.com with the account once |
insufficientPermissions |
Missing OAuth scope | Add required scopes in Admin Console domain-wide delegation settings |
invalid_grant |
Stale or revoked token | Regenerate the service account key and update .env |
pytest -qBefore pushing to any remote repository:
-
.envis listed in.gitignoreand not tracked by git -
.env.examplecontains only placeholder values (no real secrets) - No personal emails, usernames, or passwords exist in tests or fixtures
- All tests pass locally (
pytest -q) - Service account key files are excluded from version control