Skip to content

Latest commit

 

History

History
431 lines (302 loc) · 16.9 KB

CategoriesApi.md

File metadata and controls

431 lines (302 loc) · 16.9 KB

ynab.CategoriesApi

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

Method HTTP request Description
get_categories GET /budgets/{budget_id}/categories List categories
get_category_by_id GET /budgets/{budget_id}/categories/{category_id} Single category
get_month_category_by_id GET /budgets/{budget_id}/months/{month}/categories/{category_id} Single category for a specific budget month
update_category PATCH /budgets/{budget_id}/categories/{category_id} Update a category
update_month_category PATCH /budgets/{budget_id}/months/{month}/categories/{category_id} Update a category for a specific month

get_categories

CategoriesResponse get_categories(budget_id, last_knowledge_of_server=last_knowledge_of_server)

List categories

Returns all categories grouped by category group. Amounts (budgeted, activity, balance, etc.) are specific to the current budget month (UTC).

Example

  • Bearer Authentication (bearer):
import ynab
from ynab.models.categories_response import CategoriesResponse
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.CategoriesApi(api_client)
    budget_id = 'budget_id_example' # str | The id of the budget. \"last-used\" can be used to specify the last used budget and \"default\" can be used if default budget selection is enabled (see: https://api.ynab.com/#oauth-default-budget).
    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:
        # List categories
        api_response = api_instance.get_categories(budget_id, last_knowledge_of_server=last_knowledge_of_server)
        print("The response of CategoriesApi->get_categories:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling CategoriesApi->get_categories: %s\n" % e)

Parameters

Name Type Description Notes
budget_id str The id of the budget. "last-used" can be used to specify the last used budget and "default" can be used if default budget selection is enabled (see: https://api.ynab.com/#oauth-default-budget).
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

CategoriesResponse

Authorization

bearer

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 The categories grouped by category group -
404 No categories were found -
0 An error occurred -

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

get_category_by_id

CategoryResponse get_category_by_id(budget_id, category_id)

Single category

Returns a single category. Amounts (budgeted, activity, balance, etc.) are specific to the current budget month (UTC).

Example

  • Bearer Authentication (bearer):
import ynab
from ynab.models.category_response import CategoryResponse
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.CategoriesApi(api_client)
    budget_id = 'budget_id_example' # str | The id of the budget. \"last-used\" can be used to specify the last used budget and \"default\" can be used if default budget selection is enabled (see: https://api.ynab.com/#oauth-default-budget).
    category_id = 'category_id_example' # str | The id of the category

    try:
        # Single category
        api_response = api_instance.get_category_by_id(budget_id, category_id)
        print("The response of CategoriesApi->get_category_by_id:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling CategoriesApi->get_category_by_id: %s\n" % e)

Parameters

Name Type Description Notes
budget_id str The id of the budget. "last-used" can be used to specify the last used budget and "default" can be used if default budget selection is enabled (see: https://api.ynab.com/#oauth-default-budget).
category_id str The id of the category

Return type

CategoryResponse

Authorization

bearer

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 The requested category -
404 The category not was found -
0 An error occurred -

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

get_month_category_by_id

CategoryResponse get_month_category_by_id(budget_id, month, category_id)

Single category for a specific budget month

Returns a single category for a specific budget month. Amounts (budgeted, activity, balance, etc.) are specific to the current budget month (UTC).

Example

  • Bearer Authentication (bearer):
import ynab
from ynab.models.category_response import CategoryResponse
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.CategoriesApi(api_client)
    budget_id = 'budget_id_example' # str | The id of the budget. \"last-used\" can be used to specify the last used budget and \"default\" can be used if default budget selection is enabled (see: https://api.ynab.com/#oauth-default-budget).
    month = '2013-10-20' # date | The budget month in ISO format (e.g. 2016-12-01) (\"current\" can also be used to specify the current calendar month (UTC))
    category_id = 'category_id_example' # str | The id of the category

    try:
        # Single category for a specific budget month
        api_response = api_instance.get_month_category_by_id(budget_id, month, category_id)
        print("The response of CategoriesApi->get_month_category_by_id:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling CategoriesApi->get_month_category_by_id: %s\n" % e)

Parameters

Name Type Description Notes
budget_id str The id of the budget. "last-used" can be used to specify the last used budget and "default" can be used if default budget selection is enabled (see: https://api.ynab.com/#oauth-default-budget).
month date The budget month in ISO format (e.g. 2016-12-01) ("current" can also be used to specify the current calendar month (UTC))
category_id str The id of the category

Return type

CategoryResponse

Authorization

bearer

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 The requested month category -
404 The month category was not was found -
0 An error occurred -

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

update_category

SaveCategoryResponse update_category(budget_id, category_id, data)

Update a category

Update a category

Example

  • Bearer Authentication (bearer):
import ynab
from ynab.models.patch_category_wrapper import PatchCategoryWrapper
from ynab.models.save_category_response import SaveCategoryResponse
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.CategoriesApi(api_client)
    budget_id = 'budget_id_example' # str | The id of the budget. \"last-used\" can be used to specify the last used budget and \"default\" can be used if default budget selection is enabled (see: https://api.ynab.com/#oauth-default-budget).
    category_id = 'category_id_example' # str | The id of the category
    data = ynab.PatchCategoryWrapper() # PatchCategoryWrapper | The category to update

    try:
        # Update a category
        api_response = api_instance.update_category(budget_id, category_id, data)
        print("The response of CategoriesApi->update_category:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling CategoriesApi->update_category: %s\n" % e)

Parameters

Name Type Description Notes
budget_id str The id of the budget. "last-used" can be used to specify the last used budget and "default" can be used if default budget selection is enabled (see: https://api.ynab.com/#oauth-default-budget).
category_id str The id of the category
data PatchCategoryWrapper The category to update

Return type

SaveCategoryResponse

Authorization

bearer

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 The category was successfully updated -
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]

update_month_category

SaveCategoryResponse update_month_category(budget_id, month, category_id, data)

Update a category for a specific month

Update a category for a specific month. Only budgeted amount can be updated.

Example

  • Bearer Authentication (bearer):
import ynab
from ynab.models.patch_month_category_wrapper import PatchMonthCategoryWrapper
from ynab.models.save_category_response import SaveCategoryResponse
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.CategoriesApi(api_client)
    budget_id = 'budget_id_example' # str | The id of the budget. \"last-used\" can be used to specify the last used budget and \"default\" can be used if default budget selection is enabled (see: https://api.ynab.com/#oauth-default-budget).
    month = '2013-10-20' # date | The budget month in ISO format (e.g. 2016-12-01) (\"current\" can also be used to specify the current calendar month (UTC))
    category_id = 'category_id_example' # str | The id of the category
    data = ynab.PatchMonthCategoryWrapper() # PatchMonthCategoryWrapper | The category to update.  Only `budgeted` amount can be updated and any other fields specified will be ignored.

    try:
        # Update a category for a specific month
        api_response = api_instance.update_month_category(budget_id, month, category_id, data)
        print("The response of CategoriesApi->update_month_category:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling CategoriesApi->update_month_category: %s\n" % e)

Parameters

Name Type Description Notes
budget_id str The id of the budget. "last-used" can be used to specify the last used budget and "default" can be used if default budget selection is enabled (see: https://api.ynab.com/#oauth-default-budget).
month date The budget month in ISO format (e.g. 2016-12-01) ("current" can also be used to specify the current calendar month (UTC))
category_id str The id of the category
data PatchMonthCategoryWrapper The category to update. Only `budgeted` amount can be updated and any other fields specified will be ignored.

Return type

SaveCategoryResponse

Authorization

bearer

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 The month category was successfully updated -
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]