Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
YNAB Alert via AWS Lambda
from botocore.vendored import requests
import json
import boto3
def lambda_handler(event, context):
api_key = "[YOUR API KEY]"
url = "{}".format(category1)
# Create an SNS client
sns = boto3.client('sns')
payload = ""
headers = {
'Accept': "application/json",
'Authorization': "Bearer {}".format(api_key),
'cache-control': "no-cache",
response = requests.request("GET", url, data=payload, headers=headers)
data = response.json()
name = data['data']['category']['name']
balance = data['data']['category']['balance'] / 1000
print("{}: ${:,.2f}\nTime to categorize your transactions!".format(name, balance))
# Publish a simple message to the specified SNS topic
response = sns.publish(
TopicArn='[YOUR TOPIC ARN]',
Message="{}: ${:,.2f}\nTime to categorize your transactions!".format(name, balance),
return {
'statusCode': 200,
'body': json.dumps("MessageId: {}\n{}: ${:,.2f}\nTime to categorize your transactions!".format(response['MessageId'], name, balance))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment