hubspot-warehouse-sync
Sync HubSpot CRM data to a data warehouse (BigQuery, Snowflake, or Postgres) for analytics and reporting. Covers initial backfill of millions of records under the 500K/day rate limit, incremental CDC polling via hs_lastmodifieddate, schema-drift detection with ALTER TABLE generation, association sync for contacts/deals/companies, and idempotent upsert patterns that prevent duplicate rows on retry. Use when building a HubSpot → warehouse pipeline, resyncing after a schema change, debugging duplicate rows or missing CDC updates, or recovering from a rate-limit burnout mid-backfill. Trigger with "hubspot warehouse sync", "hubspot bigquery", "hubspot snowflake", "hubspot postgres etl", "hubspot backfill", "hubspot cdc", "hubspot schema drift", "hubspot duplicate rows", "hubspot to data warehouse".
What this skill does
# HubSpot Warehouse Sync
## Overview
Move HubSpot CRM data to BigQuery, Snowflake, or Postgres in a way that survives production — not just the demo. This is not a connector walkthrough. It is the extraction and load code your pipeline runs when a 2M-contact backfill burns through the 500K daily call quota at noon, when CDC misses three days of deal updates because association changes do not update `hs_lastmodifieddate`, when a portal admin adds a custom property and your warehouse table schema silently drifts, and when a network timeout at record 45,000 causes your retry to insert 100 duplicate rows.
The six production failures this skill prevents:
1. **Backfill exhausting the daily rate limit before completing** — 2M contacts at 100 records/call is 20,000 calls. At 100 calls/10s the math says 33 minutes, but that burns your entire 500K daily quota before noon and takes every other integration down with it. Token bucket rate limiting with a configurable daily ceiling is non-optional.
2. **CDC missing association changes** — HubSpot's `hs_lastmodifieddate` is updated when any property on the contact record changes, but not when an association is created or deleted. A contact-to-deal link added by a sales rep is invisible to a lastmodifieddate-based incremental poll. Association CDC requires a separate poll strategy.
3. **Schema drift causing silent extraction failures** — when a portal admin adds or removes a custom property, the warehouse table schema and the extraction property list become misaligned. New properties are dropped on the floor. Removed properties cause KeyError on row construction. Neither failure raises an alarm without explicit schema validation.
4. **Duplicate rows on batch retry** — a network failure mid-batch causes the batch to be re-sent. Without a proper upsert key the warehouse gets duplicate rows that are invisible until an analyst notices double-counted revenue. The correct upsert key for contacts is `id` (HubSpot object ID), not a composite of name/email.
5. **Large payload failures on associated object inline pulls** — contacts with thousands of engagement records cause payload sizes that exceed HTTP response limits when associations are pulled inline. Associations must be fetched in a separate batch read pass.
6. **Timezone inconsistency in aggregations** — HubSpot stores all timestamps as Unix milliseconds in UTC. If the warehouse session timezone is set to a local timezone, `DATE(created_at)` aggregations produce different daily totals depending on where the analyst runs the query.
## Prerequisites
- Python 3.10+
- HubSpot private app token with scopes: `crm.objects.contacts.read`, `crm.objects.companies.read`, `crm.objects.deals.read`, `crm.associations.read`, `crm.schemas.contacts.read`
- Target warehouse credentials:
- BigQuery: service account JSON with `bigquery.dataEditor` role
- Snowflake: user/password or key-pair auth, warehouse + database + schema
- Postgres: connection string with write access to the target schema
- Python packages: `requests`, `pandas`, `pyarrow`, `google-cloud-bigquery` (BigQuery) or `snowflake-connector-python` (Snowflake) or `psycopg2-binary` (Postgres)
- A secret store the runtime can read (env vars, GCP Secret Manager, AWS Secrets Manager)
## Instructions
Build in this order. Each section neutralizes one production failure mode.
### 1. Token bucket rate limiter (neutralizes backfill quota burnout)
Naive extraction loops call the API as fast as possible. At 100 calls/10s with 20K calls needed, you burn 200K of your 500K daily quota in 33 minutes — and that is before any CDC polling or webhook processing. A production backfill must budget its calls over the full day so other integrations still have headroom.
The token bucket strategy: set a `daily_budget` ceiling below the account limit (e.g., 400K of 500K), compute how many calls per second that allows over 24 hours, and enforce a minimum interval between calls. Burn-rate is checked against live rate-limit headers on every response.
```python
import time
import threading
from dataclasses import dataclass, field
@dataclass
class TokenBucket:
"""
Token bucket rate limiter for HubSpot API calls.
daily_budget: max calls to spend per 24h window (stay below 500K limit)
burst_limit: max calls per 10s window (100 for most tiers)
"""
daily_budget: int = 400_000
burst_limit: int = 95 # leave 5 calls headroom per 10s window
_lock: threading.Lock = field(default_factory=threading.Lock)
_calls_today: int = 0
_window_calls: int = 0
_window_start: float = field(default_factory=time.monotonic)
_day_start: float = field(default_factory=time.monotonic)
def acquire(self) -> None:
with self._lock:
now = time.monotonic()
# Reset daily counter
if now - self._day_start >= 86_400:
self._calls_today = 0
self._day_start = now
# Reset 10s window counter
if now - self._window_start >= 10.0:
self._window_calls = 0
self._window_start = now
# Hard stop if daily budget exhausted — do not burn other integrations
if self._calls_today >= self.daily_budget:
seconds_left = 86_400 - (now - self._day_start)
raise DailyBudgetExhausted(
f"Daily call budget of {self.daily_budget:,} reached. "
f"Resuming in {seconds_left/3600:.1f}h."
)
# Burst window throttle — sleep until window resets if full
if self._window_calls >= self.burst_limit:
sleep_s = 10.0 - (now - self._window_start) + 0.1
time.sleep(max(0, sleep_s))
self._window_calls = 0
self._window_start = time.monotonic()
self._calls_today += 1
self._window_calls += 1
def update_from_headers(self, headers: dict) -> None:
"""Adjust pacing from live rate-limit headers on each response."""
remaining = int(headers.get("X-HubSpot-RateLimit-Daily-Remaining", self.daily_budget))
if remaining < 50_000:
# Emergency throttle: burn rate is too high, cut burst limit in half
with self._lock:
self.burst_limit = max(10, self.burst_limit // 2)
class DailyBudgetExhausted(Exception):
pass
RATE_LIMITER = TokenBucket()
```
### 2. Full backfill with cursor pagination (contacts search API)
The search API (`POST /crm/v3/objects/contacts/search`) supports cursor pagination via `after`. It returns a maximum of 100 records per page and up to 10,000 records total per search. For tables larger than 10K records, use the `lastmodifieddate` range-slicing strategy: paginate within 30-day windows, sliding forward from the earliest `hs_createdate` in the portal.
```python
import requests
import json
BASE_URL = "https://api.hubapi.com"
def fetch_contacts_page(
token: str,
after: str | None,
properties: list[str],
rate_limiter: TokenBucket,
) -> tuple[list[dict], str | None]:
"""Fetch one page of contacts. Returns (records, next_cursor)."""
RATE_LIMITER.acquire()
body = {
"limit": 100,
"properties": properties,
"sorts": [{"propertyName": "hs_lastmodifieddate", "direction": "ASCENDING"}],
}
if after:
body["after"] = after
resp = requests.post(
f"{BASE_URL}/crm/v3/objects/contacts/search",
headers={"Authorization": f"Bearer {token}", "Content-Type": "application/json"},
json=body,
timeout=30,
)
rate_limiter.update_from_headers(dict(resp.headers))
if resp.status_code == 429:
retry_after = int(resp.headers.get("Retry-After", 10))
time.sleep(retry_after)
return fetch_contacts_page(token, after, properties, rate_limiter) # one retry
resp.raise_for_status()
data = resp.json()
results = data.get("resRelated in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.