Python SDK [community]
SDK de la comunidad
Este SDK es mantenido completamente por la comunidad.
Remnawave Python SDK es una biblioteca para la interacción cómoda con los tipos de RestAPI.
✨ Características principales
- Diseño basado en controladores: Divide la funcionalidad en controladores separados para mayor flexibilidad. ¡Usa solo lo que necesitas!
- Modelos Pydantic: Solicitudes y respuestas fuertemente tipadas para mayor fiabilidad.
- Serialización rápida: Impulsado por orjson para un manejo eficiente de JSON.
- Uso modular: Importa controladores individuales o el SDK completo según sea necesario.
- Soporte para cliente HTTP personalizado: Puedes pasar tu propio httpx.AsyncClient con cabeceras personalizadas para evitar varias comprobaciones.
- Integración de token Caddy: Soporte directo para pasar el caddy_token durante la inicialización del SDK.
Instalación
pip install remnawave
Uso
Ejemplo de uso
import os
import asyncio
from remnawave import RemnawaveSDK # Updated import for new package
from remnawave.models import ( # Updated import path
UsersResponseDto,
UserResponseDto,
GetAllConfigProfilesResponseDto,
CreateInternalSquadRequestDto
)
async def main():
# URL to your panel (ex. https://vpn.com or http://127.0.0.1:3000)
base_url: str = os.getenv("REMNAWAVE_BASE_URL")
# Bearer Token from panel (section: API Tokens)
token: str = os.getenv("REMNAWAVE_TOKEN")
# Initialize the SDK
remnawave = RemnawaveSDK(base_url=base_url, token=token)
# Fetch all users
response: UsersResponseDto = await remnawave.users.get_all_users()
total_users: int = response.total
users: list[UserResponseDto] = response.users
print("Total users: ", total_users)
print("List of users: ", users)
if __name__ == "__main__":
asyncio.run(main())
Ejemplo de uso con Caddy como servidor web
import os
import asyncio
from remnawave import RemnawaveSDK # Updated import for new package
from remnawave.models import ( # Updated import path
UsersResponseDto,
UserResponseDto,
GetAllConfigProfilesResponseDto,
CreateInternalSquadRequestDto
)
async def main():
# URL to your panel (ex. https://vpn.com or http://127.0.0.1:3000)
base_url: str = os.getenv("REMNAWAVE_BASE_URL")
# Bearer Token from panel (section: API Tokens)
token: str = os.getenv("REMNAWAVE_TOKEN")
# Bearer Token for Caddy Auth
caddy_token = os.getenv("CADDY_TOKEN_AUTH")
# Initialize the SDK
remnawave = RemnawaveSDK(base_url=base_url, token=token, caddy_token=caddy_token)
# Fetch all users
response: UsersResponseDto = await remnawave.users.get_all_users()
total_users: int = response.total
users: list[UserResponseDto] = response.users
print("Total users: ", total_users)
print("List of users: ", users)
if __name__ == "__main__":
asyncio.run(main())
Ejemplo de uso con cliente personalizado
import os
import asyncio
import httpx
from remnawave import RemnawaveSDK
async def main():
base_url = os.getenv("REMNAWAVE_BASE_URL")
token = os.getenv("REMNAWAVE_TOKEN")
# Custom client with headers
async with httpx.AsyncClient(headers={"hello": "world"}) as client:
# Initialize SDK with a custom client
remnawave = RemnawaveSDK(base_url=base_url, token=token, client=client)
# Fetch all users
response = await remnawave.users.get_all_users_v2()
print("Total users:", response.total)
asyncio.run(main())
Enlaces del proyecto
- Repositorio GitHub: Remnawave API en GitHub
- Autores: Artem (sm1ky), Kesevone