Skip to content

Latest commit

 

History

History
255 lines (176 loc) · 8.93 KB

File metadata and controls

255 lines (176 loc) · 8.93 KB

ynab.AccountsApi

All URIs are relative to https://api.ynab.com/v1

Method HTTP request Description
create_account POST /budgets/{plan_id}/accounts Create an account
get_account_by_id GET /budgets/{plan_id}/accounts/{account_id} Get an account
get_accounts GET /budgets/{plan_id}/accounts Get all accounts

create_account

AccountResponse create_account(plan_id, data)

Create an account

Creates a new account

Example

  • Bearer Authentication (bearer):
import ynab
from ynab.models.account_response import AccountResponse
from ynab.models.post_account_wrapper import PostAccountWrapper
from ynab.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to https://api.ynab.com/v1
# See configuration.py for a list of all supported configuration parameters.
configuration = ynab.Configuration(
    host = "https://api.ynab.com/v1"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure Bearer authorization: bearer
configuration = ynab.Configuration(
    access_token = os.environ["BEARER_TOKEN"]
)

# Enter a context with an instance of the API client
with ynab.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = ynab.AccountsApi(api_client)
    plan_id = 'plan_id_example' # str | The id of the plan (\"last-used\" can be used to specify the last used plan and \"default\" can be used if default plan selection is enabled (see: https://api.ynab.com/#oauth-default-plan)
    data = ynab.PostAccountWrapper() # PostAccountWrapper | The account to create.

    try:
        # Create an account
        api_response = api_instance.create_account(plan_id, data)
        print("The response of AccountsApi->create_account:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling AccountsApi->create_account: %s\n" % e)

Parameters

Name Type Description Notes
plan_id str The id of the plan ("last-used" can be used to specify the last used plan and "default" can be used if default plan selection is enabled (see: https://api.ynab.com/#oauth-default-plan)
data PostAccountWrapper The account to create.

Return type

AccountResponse

Authorization

bearer

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status code Description Response headers
201 The account was successfully created -
400 The request could not be understood due to malformed syntax or validation error(s). -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

get_account_by_id

AccountResponse get_account_by_id(plan_id, account_id)

Get an account

Returns a single account

Example

  • Bearer Authentication (bearer):
import ynab
from ynab.models.account_response import AccountResponse
from ynab.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to https://api.ynab.com/v1
# See configuration.py for a list of all supported configuration parameters.
configuration = ynab.Configuration(
    host = "https://api.ynab.com/v1"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure Bearer authorization: bearer
configuration = ynab.Configuration(
    access_token = os.environ["BEARER_TOKEN"]
)

# Enter a context with an instance of the API client
with ynab.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = ynab.AccountsApi(api_client)
    plan_id = 'plan_id_example' # str | The id of the plan. \"last-used\" can be used to specify the last used plan and \"default\" can be used if default plan selection is enabled (see: https://api.ynab.com/#oauth-default-plan).
    account_id = UUID('38400000-8cf0-11bd-b23e-10b96e4ef00d') # UUID | The id of the account

    try:
        # Get an account
        api_response = api_instance.get_account_by_id(plan_id, account_id)
        print("The response of AccountsApi->get_account_by_id:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling AccountsApi->get_account_by_id: %s\n" % e)

Parameters

Name Type Description Notes
plan_id str The id of the plan. "last-used" can be used to specify the last used plan and "default" can be used if default plan selection is enabled (see: https://api.ynab.com/#oauth-default-plan).
account_id UUID The id of the account

Return type

AccountResponse

Authorization

bearer

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 The requested account -
404 The requested account was not found -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

get_accounts

AccountsResponse get_accounts(plan_id, last_knowledge_of_server=last_knowledge_of_server)

Get all accounts

Returns all accounts

Example

  • Bearer Authentication (bearer):
import ynab
from ynab.models.accounts_response import AccountsResponse
from ynab.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to https://api.ynab.com/v1
# See configuration.py for a list of all supported configuration parameters.
configuration = ynab.Configuration(
    host = "https://api.ynab.com/v1"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure Bearer authorization: bearer
configuration = ynab.Configuration(
    access_token = os.environ["BEARER_TOKEN"]
)

# Enter a context with an instance of the API client
with ynab.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = ynab.AccountsApi(api_client)
    plan_id = 'plan_id_example' # str | The id of the plan. \"last-used\" can be used to specify the last used plan and \"default\" can be used if default plan selection is enabled (see: https://api.ynab.com/#oauth-default-plan).
    last_knowledge_of_server = 56 # int | The starting server knowledge.  If provided, only entities that have changed since `last_knowledge_of_server` will be included. (optional)

    try:
        # Get all accounts
        api_response = api_instance.get_accounts(plan_id, last_knowledge_of_server=last_knowledge_of_server)
        print("The response of AccountsApi->get_accounts:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling AccountsApi->get_accounts: %s\n" % e)

Parameters

Name Type Description Notes
plan_id str The id of the plan. "last-used" can be used to specify the last used plan and "default" can be used if default plan selection is enabled (see: https://api.ynab.com/#oauth-default-plan).
last_knowledge_of_server int The starting server knowledge. If provided, only entities that have changed since `last_knowledge_of_server` will be included. [optional]

Return type

AccountsResponse

Authorization

bearer

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 The list of requested accounts -
404 No accounts were found -

[Back to top] [Back to API list] [Back to Model list] [Back to README]