monday.com API Python examples: Connecting to external databases and custom dashboards
Our dev team is building custom dashboards that pull data from monday.com API. Using Python with the monday-sdk. Need advice on: - Authentication best practices - Rate limiting handling - Webhook vs polling for real-time updates - Error handling patterns - Connecting to PostgreSQL for historical analysis
2 Answers
Here's our production Python setup for monday.com API: ```python import monday from monday import MondayClient import os # Use environment variables for API key monday_client = MondayClient(os.environ['MONDAY_API_KEY']) # Rate limiting: monday allows 10 requests/second, 10,000/day # We implemented exponential backoff: def query_with_retry(query, variables, max_retries=3): for attempt in range(max_retries): try: result = monday_client.execute_query(query, variables) return result except RateLimitError: wait_time = 2 ** attempt time.sleep(wait_time) raise Exception("Max retries exceeded") # Webhooks > polling for real-time. Register webhook for board updates: # POST to https://api.monday.com/v2/webhooks # Point to your endpoint that validates payload signature ``` Key tips: Use GraphQL queries (not REST), batch items in queries of 100 max, cache board schema, use webhooks for updates instead of polling.
Adding to Maria's code - we use the monday-query-language package for complex queries. Also recommend storing API responses in PostgreSQL for historical analysis. One gotcha: item IDs change when moving between boards. Always use unique external IDs as your primary key, not monday.com item IDs.