zaim_api library

A Dart client for the Zaim REST API v2.1.0.

Zaim (zaim.net) is a Japanese personal household-accounting service. This library wraps its OAuth 1.0a API: the three-legged token dance, money record CRUD, the user's categories, genres, and accounts, and the public master data endpoints that need no credentials at all.

Two things about the API are worth knowing before you start:

  • Only records the user entered by hand are exposed. Rows Zaim imported automatically from a linked bank or card are not returned.
  • Unless the app was registered as permanently accessible, the permission a user grants expires after 24 hours.

Example

import 'package:zaim_api/zaim_api.dart';

Future<void> main() async {
  final client = ZaimClient(
    credentials: const ZaimCredentials(
      consumerKey: 'YOUR_CONSUMER_KEY',
      consumerSecret: 'YOUR_CONSUMER_SECRET',
      accessToken: 'USER_ACCESS_TOKEN',
      accessTokenSecret: 'USER_ACCESS_TOKEN_SECRET',
    ),
  );
  try {
    final me = await client.user.verify();
    print('Hello, ${me.name}');
  } finally {
    client.close();
  }
}

Classes

AccountApi
The /v2/home/account endpoint.
CategoryApi
The /v2/home/category endpoint.
DefaultAccount
An account from Zaim's public account master, GET /v2/account.
DefaultApi
Zaim's public master data: /v2/account, /v2/category, /v2/genre, and /v2/currency.
DefaultCategory
A category from Zaim's public category master, GET /v2/category.
DefaultGenre
A genre from Zaim's public genre master, GET /v2/genre.
GenreApi
The /v2/home/genre endpoint.
MoneyApi
The /v2/home/money* endpoints: reading, creating, updating, and deleting the user's money records.
MoneyRecord
One money record — a payment, an income, or a transfer — as returned by GET /v2/home/money.
MoneyWriteResult
What Zaim returns from every money create, update, and delete.
UserApi
The /v2/home/user/* endpoints.
ZaimAccount
One of the user's own accounts, from GET /v2/home/account.
ZaimAuthFlow
Drives Zaim's three-legged OAuth 1.0a flow.
ZaimCategory
One of the user's own categories, from GET /v2/home/category.
ZaimClient
The entry point for every authenticated Zaim call.
ZaimCredentials
The four values needed to sign every authenticated Zaim request: the app's consumer key and secret, plus the user's access token and secret.
ZaimCurrency
A currency from Zaim's public currency master, GET /v2/currency.
ZaimGenre
One of the user's own genres, from GET /v2/home/genre.
ZaimOAuthEndpoints
Zaim's OAuth 1.0a endpoints.
ZaimPlace
A place Zaim recorded alongside a money record.
ZaimRequestToken
The short-lived token pair from step 1 of the OAuth 1.0a dance.
ZaimUser
The authenticated Zaim user, as returned by GET /v2/home/user/verify.
ZaimUserCounters
The user object every money create/update/delete response carries.

Enums

MoneyMode
The kind of money record: a payment, an income, or a transfer between two of the user's own accounts.
MoneyOrder
The sort key for GET /v2/home/money.

Exceptions / Errors

ZaimApiException
Thrown when the Zaim API answers with a non-success HTTP status, or with a body that cannot be understood.
ZaimAuthException
Thrown for HTTP 401 responses: the credentials are missing, expired, or the app was not granted the scope the call needs.