A robust and easy-to-use Go SDK for interacting with the ZenMoney API. This SDK provides a type-safe way to work with ZenMoney's financial data synchronization API, including accounts, transactions, budgets, and more.
- 🚀 Easy-to-use, idiomatic Go API
- 🔒 Built-in retry mechanism with configurable policies
- 💪 Full type safety for all ZenMoney entities
- 🛡️ Comprehensive error handling
- ⚡ Support for all ZenMoney API operations
- 📚 Extensive documentation and examples
go get github.com/nemirlev/zenmoney-go-sdk
package main
import (
"context"
"log"
"github.com/nemirlev/zenmoney-go-sdk/v2/api"
)
func main() {
// Create a new client
client, err := api.NewClient("your-token-here")
if err != nil {
log.Fatalf("Failed to create client: %v", err)
}
// Perform full sync
ctx := context.Background()
resp, err := client.FullSync(ctx)
if err != nil {
log.Fatalf("Sync failed: %v", err)
}
// Work with the data
for _, account := range resp.Account {
log.Printf("Account: %s, Balance: %.2f", account.Title, *account.Balance)
}
}
The SDK supports various configuration options through the functional options pattern:
client, err := api.NewClient(
"your-token-here",
api.WithTimeout(45*time.Second),
api.WithRetryPolicy(5, 2*time.Second),
api.WithBaseURL("https://custom-api.zenmoney.ru/v8/"),
)
- Full synchronization
- Incremental synchronization from a specific timestamp
- Force sync specific entities
- Custom sync with specific parameters
- Suggestions for categories and operation merchants
The SDK provides structured error types for better error handling:
if err != nil {
var apiErr *errors.Error
if errors.As(err, &apiErr) {
switch apiErr.Code {
case errors.ErrInvalidToken:
// Handle authentication error
case errors.ErrServerError:
// Handle server error
case errors.ErrNetworkError:
// Handle network error
}
}
}
Check out the examples directory for more detailed usage examples:
- Basic usage
- Configuration options
- Sync operations
- Error handling
- Working with budgets
- Working with merchants
For detailed API documentation, visit the Go package documentation.
For ZenMoney API documentation, visit the official API documentation.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Thanks to the ZenMoney team for providing the API
- Inspired by other excellent Go SDKs in the community