← You Need a Budget + Data Stores integrations

Add or update a single record with Data Stores API on New or Updated Transaction from You Need a Budget API

Pipedream makes it easy to connect APIs for Data Stores, You Need a Budget and 1000+ other apps remarkably fast.

Trigger workflow on
New or Updated Transaction from the You Need a Budget API
Next, do this
Add or update a single record with the Data Stores API
No credit card required
Into to Pipedream
Watch us build a workflow
Watch us build a workflow
7 min
Watch now ➜
Trusted by 250,000+ developers from startups to Fortune 500 companies:
Trusted by 250,000+ developers from startups to Fortune 500 companies

Developers Pipedream

Getting Started

This integration creates a workflow with a You Need a Budget trigger and Data Stores action. When you configure and deploy the workflow, it will run on Pipedream's servers 24x7 for free.

  1. Select this integration
  2. Configure the New or Updated Transaction trigger
    1. Connect your You Need a Budget account
    2. Configure timer
    3. Select a Budget ID
    4. Optional- Configure Since Date
  3. Configure the Add or update a single record action
    1. Connect your Data Stores account
    2. Configure Data Store
    3. Select a Key
    4. Configure Value
  4. Deploy the workflow
  5. Send a test event to validate your setup
  6. Turn on the trigger

Details

This integration uses pre-built, open source components from Pipedream's GitHub repo. These components are developed by Pipedream and the community, and verified and maintained by Pipedream.

To contribute an update to an existing component or create a new component, create a PR on GitHub. If you're new to Pipedream component development, you can start with quickstarts for trigger span and action development, and then review the component API reference.

Trigger

Description:Emit new event for every new or updated transaction. [See the docs](https://api.youneedabudget.com/v1#/Transactions/getTransactions)
Version:0.0.2
Key:you_need_a_budget-new-or-updated-transaction

Trigger Code

import common from "../common/common.mjs";

export default {
  ...common,
  key: "you_need_a_budget-new-or-updated-transaction",
  name: "New or Updated Transaction",
  description: "Emit new event for every new or updated transaction. [See the docs](https://api.youneedabudget.com/v1#/Transactions/getTransactions)",
  version: "0.0.2",
  type: "source",
  props: {
    ...common.props,
    budgetId: {
      propDefinition: [
        common.props.app,
        "budgetId",
      ],
      withLabel: true,
    },
    sinceDate: {
      propDefinition: [
        common.props.app,
        "date",
      ],
      label: "Since Date",
      optional: true,
    },
  },
  methods: {
    ...common.methods,
    generateMeta(event, isUpdate = false) {
      const {
        id,
        date,
        amount,
      } = event;
      const spent = this.app.convertFromMilliunit(amount);
      const ts = Date.parse(date);
      const summary = isUpdate
        ? `Updated transaction in ${this.budgetId.label}: ${spent}`
        : `New transaction in ${this.budgetId.label}: ${spent}`;
      return {
        id,
        summary,
        ts,
      };
    },
  },
  async run() {
    const lastKnowledgeOfServer = this.getLastKnowledgeOfServer();
    const emittedTransactions = this.getEmittedTransactions();

    const {
      server_knowledge: serverKnowledge,
      transactions = [],
    } = await this.app.getTransactions({
      budgetId: this.budgetId.value,
      sinceDate: this.sinceDate || undefined,
      lastKnowledgeOfServer,
    });

    this.setLastKnowledgeOfServer(serverKnowledge);

    for (const transaction of transactions) {
      let isUpdate;
      if (emittedTransactions[transaction.id]) {
        isUpdate = true;
      } else {
        emittedTransactions[transaction.id] = true;
      }
      const meta = this.generateMeta(transaction, isUpdate);
      this.$emit(transaction, meta);
    }

    this.setEmittedTransactions(emittedTransactions);
  },
};

Trigger Configuration

This component may be configured based on the props defined in the component code. Pipedream automatically prompts for input values in the UI and CLI.
LabelPropTypeDescription
You Need a BudgetappappThis component uses the You Need a Budget app.
N/Adb$.service.dbThis component uses $.service.db to maintain state between component invocations.
timer$.interface.timer
Budget IDbudgetIdstringSelect a value from the drop down menu.
Since DatesinceDatestring

E.g. 2021-11-29

Trigger Authentication

You Need a Budget uses OAuth authentication. When you connect your You Need a Budget account, Pipedream will open a popup window where you can sign into You Need a Budget and grant Pipedream permission to connect to your account. Pipedream securely stores and automatically refreshes the OAuth tokens so you can easily authenticate any You Need a Budget API.

Pipedream requests the following authorization scopes when you connect your account:

About You Need a Budget

Money doesn’t have to be messy. The YNAB budgeting app and its simple four-rule method will help you organize your finances, demolish your debt, save piles of cash, and reach your financial goals faster.

Action

Description:Add or update a single record in your [Pipedream Data Store](https://pipedream.com/data-stores/).
Version:0.0.8
Key:data_stores-add-update-record

Data Stores Overview

With the Data Stores API, you can build applications that:

  • Store data for later retrieval
  • Retrieve data from a store
  • Update data in a store
  • Delete data from a store

Action Code

import app from "../../data_stores.app.mjs";

export default {
  key: "data_stores-add-update-record",
  name: "Add or update a single record",
  description: "Add or update a single record in your [Pipedream Data Store](https://pipedream.com/data-stores/).",
  version: "0.0.8",
  type: "action",
  props: {
    app,
    dataStore: {
      propDefinition: [
        app,
        "dataStore",
      ],
    },
    key: {
      propDefinition: [
        app,
        "key",
        ({ dataStore }) => ({
          dataStore,
        }),
      ],
      description: "Enter a key for the record you'd like to create or select an existing key to update.",
    },
    value: {
      propDefinition: [
        app,
        "value",
      ],
    },
  },
  async run({ $ }) {
    const {
      key,
      value,
    } = this;
    const exists = await this.dataStore.has(key);
    const parsedValue = this.app.parseValue(value);
    await this.dataStore.set(key, parsedValue);
    // eslint-disable-next-line multiline-ternary
    $.export("$summary", `Successfully ${exists ? "updated the record for" : "added a new record with the"} key, \`${key}\`.`);
    return {
      key,
      value: parsedValue,
    };
  },
};

Action Configuration

This component may be configured based on the props defined in the component code. Pipedream automatically prompts for input values in the UI.

LabelPropTypeDescription
Data StoresappappThis component uses the Data Stores app.
Data StoredataStoredata_store

Select an existing Data Store or create a new one.

KeykeystringSelect a value from the drop down menu.
Valuevalueany

Enter a string, object, or array.

Action Authentication

The Data Stores API does not require authentication.

About Data Stores

Use Pipedream Data Stores to manage state throughout your workflows.

More Ways to Connect Data Stores + You Need a Budget

Delete All Records with Data Stores API on Category Overspent from You Need a Budget API
You Need a Budget + Data Stores
 
Try it
List keys with Data Stores API on Category Overspent from You Need a Budget API
You Need a Budget + Data Stores
 
Try it
Delete All Records with Data Stores API on Low Account Balance from You Need a Budget API
You Need a Budget + Data Stores
 
Try it
List keys with Data Stores API on Low Account Balance from You Need a Budget API
You Need a Budget + Data Stores
 
Try it
Delete All Records with Data Stores API on New or Updated Transaction from You Need a Budget API
You Need a Budget + Data Stores
 
Try it
Category Overspent from the You Need a Budget API

Emit new event when a category budget is overspent

 
Try it
Low Account Balance from the You Need a Budget API

Emit new event when an account balance drops below a certain amount

 
Try it
Low Category Balance from the You Need a Budget API

Emit new event when a category balance drops below a certain amount

 
Try it
New or Updated Transaction from the You Need a Budget API

Emit new event for every new or updated transaction. See the docs

 
Try it
New Spending In Account from the You Need a Budget API

Emit new event for every spending in an account. See the docs

 
Try it
Create Transaction with the You Need a Budget API

Creates a single transaction. See the docs

 
Try it
Update Category Budget with the You Need a Budget API

Update a category budget for a specific month. See the docs

 
Try it
Add or update a single record with the Data Stores API

Add or update a single record in your Pipedream Data Store.

 
Try it
Add or update multiple records with the Data Stores API

Add or update multiple records to your Pipedream Data Store.

 
Try it
Check for existence of key with the Data Stores API

Check if a key exists in your Pipedream Data Store or create one if it doesn't exist.

 
Try it