Skip to main content

Add API key auth and billing to your Python API in one line. Harbor handles validation so your users can authenticate with keys they manage from the Harbor dashboard.

Project description

harbor-sdk for Python

Add API key auth and billing to your Python API in one line.

Install

pip install harbor-sdk

Quick Start

Flask

from flask import Flask, jsonify, g
from harbor_sdk import harbor

app = Flask(__name__)

@app.route("/data")
@harbor(project_id="proj_harbor_xyz")
def data():
    plan = g.harbor.plan  # 'free' | 'pro' | 'scale'
    return jsonify({"data": "protected", "plan": plan})

FastAPI

from fastapi import FastAPI, Request
from harbor_sdk import HarborMiddleware

app = FastAPI()
app.add_middleware(HarborMiddleware, project_id="proj_harbor_xyz")

@app.get("/data")
async def data(request: Request):
    plan = request.state.harbor.plan
    return {"data": "protected", "plan": plan}

Manual validation

from harbor_sdk import validate

info = validate(request.headers.get("X-Harbor-Key"))
if not info:
    return {"error": "Invalid API key"}, 401
print(info.plan)         # 'pro'
print(info.key_id)       # 'key_abc123'
print(info.project_id)   # 'proj_harbor_xyz'

Your users pass their key in the header

curl -H "X-Harbor-Key: hbr_live_..." https://your-api.com/data

Get your Project ID

  1. Sign up at harbor-black.vercel.app
  2. Create a project in your dashboard
  3. Copy your Project ID

Full docs: harbor-black.vercel.app/docs

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

harbor_client-0.1.0.tar.gz (3.9 kB view details)

Uploaded Source

File details

Details for the file harbor_client-0.1.0.tar.gz.

File metadata

  • Download URL: harbor_client-0.1.0.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for harbor_client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 78a63e5bcf8a81f3ccd50eac49eddd59db9dc558df2be8580ba437d0fbdfb1cf
MD5 a8e33bc8f1fd920a9a71f7e70fd809e0
BLAKE2b-256 d0deeec342e4739272bf6192790b41e324c513a87d4b1007fa5f63d18264ae81

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page