Docs/Documentation/Connect framework

Python / Django

Sync vacation rental data with Python using the Repull SDK.

1

Prerequisites

Python 3.8+ installed on your machine.

You also need a Repull API key. Get one from your dashboard.

2

Install

pip install repull-sdk
3

Set up environment variables

Add your credentials to a .env file in your project root:

REPULL_API_KEY=sk_live_YOUR_KEY

There is one key type — sk_live_ — created from /dashboard/keys. It acts on whatever channels your workspace has connected.

4

Make your first API call

Set up the client with your API key, then call any endpoint. The example below lists properties and fetches reservations.

# views.py (Django)
import datetime
import json
import os

from django.http import HttpResponse
from repull import AuthenticatedClient
from repull.api.availability import get_availability, update_availability
from repull.api.properties import list_properties
from repull.api.reservations import list_reservations
from repull.models import AvailabilityWriteRequest, ListReservationsStatus

client = AuthenticatedClient(
    base_url="https://api.repull.dev",
    token=os.environ["REPULL_API_KEY"],
)

def reservations(request):
    """How do I get reservations from all channels with Python?"""
    response = list_reservations.sync_detailed(
        client=client,
        status=ListReservationsStatus.CONFIRMED,
        platform=request.GET.get("platform"),  # airbnb, booking, vrbo
    )
    return HttpResponse(response.content, content_type="application/json")

def availability(request, property_id):
    """How do I check availability with Python?"""
    response = get_availability.sync_detailed(
        property_id=property_id,
        client=client,
        from_=datetime.date.fromisoformat(request.GET["from"]),
        to=datetime.date.fromisoformat(request.GET["to"]),
    )
    return HttpResponse(response.content, content_type="application/json")

def update_pricing(request, property_id):
    """How do I update pricing with Python? Pushes to every connected channel."""
    data = json.loads(request.body)
    response = update_availability.sync_detailed(
        property_id=property_id,
        client=client,
        body=AvailabilityWriteRequest(
            dates=[datetime.date.fromisoformat(d) for d in data["dates"]],
            price=float(data["price"]),
        ),
    )
    return HttpResponse(response.content, content_type="application/json")

# Standalone script
if __name__ == "__main__":
    properties = list_properties.sync(client=client, limit=50)
    print(properties)
AI