{"id":13695262,"url":"https://github.com/ameliaikeda/monzo-php","last_synced_at":"2025-05-03T13:31:41.701Z","repository":{"id":56946973,"uuid":"82849326","full_name":"ameliaikeda/monzo-php","owner":"ameliaikeda","description":"PHP Library for use with https://monzo.com","archived":true,"fork":false,"pushed_at":"2018-03-22T22:45:46.000Z","size":132,"stargazers_count":21,"open_issues_count":2,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-08-03T18:19:25.221Z","etag":null,"topics":["api","api-client","laravel","monzo","php","socialite"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ameliaikeda.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-22T20:29:04.000Z","updated_at":"2024-06-28T08:21:32.000Z","dependencies_parsed_at":"2022-08-21T03:10:25.317Z","dependency_job_id":null,"html_url":"https://github.com/ameliaikeda/monzo-php","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ameliaikeda%2Fmonzo-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ameliaikeda%2Fmonzo-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ameliaikeda%2Fmonzo-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ameliaikeda%2Fmonzo-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ameliaikeda","download_url":"https://codeload.github.com/ameliaikeda/monzo-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224364261,"owners_count":17299039,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","api-client","laravel","monzo","php","socialite"],"created_at":"2024-08-02T18:00:20.421Z","updated_at":"2024-11-12T23:30:18.245Z","avatar_url":"https://github.com/ameliaikeda.png","language":"PHP","readme":"\u003ch1 align=\"center\"\u003eMonzo PHP Client\u003c/h1\u003e\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://travis-ci.org/ameliaikeda/monzo-php\"\u003e\n    \u003cimg src=\"https://travis-ci.org/ameliaikeda/monzo-php.svg?branch=master\" alt=\"\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://scrutinizer-ci.com/g/ameliaikeda/monzo-php/?branch=master\"\u003e\n    \u003cimg src=\"https://scrutinizer-ci.com/g/ameliaikeda/monzo-php/badges/quality-score.png?b=master\" alt=\"\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://styleci.io/repos/82849326\"\u003e\n    \u003cimg src=\"https://styleci.io/repos/82849326/shield?branch=master\" alt=\"\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://codeclimate.com/github/ameliaikeda/monzo-php/maintainability\"\u003e\n    \u003cimg src=\"https://api.codeclimate.com/v1/badges/576fcd402d7bfbe7c043/maintainability\"\u003e\n\u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003eThis library allows access to the \u003ca href=\"https://monzo.com\"\u003eMonzo\u003c/a\u003e API in PHP. This library requires PHP 7.1+.\u003c/p\u003e\n\n\n## Installation\n\n```\ncomposer require amelia/monzo-php\n```\n\nIf you don't already have your own access tokens from completing oauth yourself, you'll need to also `composer require laravel/socialite`.\n\nYou should set the following variables in your `.env` (or otherwise):\n\n- `MONZO_CLIENT_ID`\n- `MONZO_CLIENT_SECRET`\n- `MONZO_REDIRECT_URI`\n\nYou can create an application at [https://developers.monzo.com](https://developers.monzo.com).\n\n## Laravel integration\n\n`Amelia\\Monzo\\MonzoServiceProvider::class` is registered automatically in Laravel 5.5.\n\nA future version of this package will include automatic webhook handling per-user, and full automatic socialite integration.\n\nThe environment variables that control these will be:\n\n- `MONZO_WEBHOOKS=true`\n- `MONZO_SOCIALITE=true`\n\n### Socialite integration\n\nTo automatically add callbacks for socialite, this package provides an optional authentication system.\n\n\u003e **Caveat**\n\u003e This assumes you are adding existing users to an app on monzo.\n\u003e If you are not doing this, you'll need to set up your own routes to create/manage users based on API responses from socialite.\n\nFirst, add the `MonzoCredentials` trait to your `Authenticatable` user model.\n\n```php\n\u003c?php\n\nnamespace App;\n\nuse Amelia\\Monzo\\MonzoCredentials;\nuse Amelia\\Monzo\\Contracts\\HasMonzoCredentials;\nuse Illuminate\\Database\\Eloquent\\Model;\n\nclass User extends Model implements HasMonzoCredentials\n{\n    use MonzoCredentials;\n}\n```\n\nThis adds a bunch of setters/getters to your user model for handling monzo credentials.\n\nYou can customise the columns used by adding methods to your user model:\n\n```php\n\u003c?php\n\nuse Amelia\\Monzo\\MonzoCredentials;\nuse Amelia\\Monzo\\Contracts\\HasMonzoCredentials;\n\nclass User implements HasMonzoCredentials {\n    \n    use MonzoCredentials;\n    \n    protected function getMonzoAccessTokenColumn()\n    {\n        return 'monzo_access_token';\n    }\n\n    protected function getMonzoRefreshTokenColumn()\n    {\n        return 'monzo_refresh_token';\n    }\n\n    protected function getMonzoUserIdColumn()\n    {\n        return 'monzo_user_id';\n    }\n}\n```\n\n### Socialite migrations\n\nAssuming your users table is named `users`, you can simply run `php artisan vendor:publish --tag=monzo`.\n\nThis will create a migration in your `migrations` directory that can be edited.\n\nRun `php artisan migrate` to run this.\n\n\n## Usage\n\n**Caveat**\nIf not using Laravel, you'll need to set up an instance of `Amelia\\Monzo\\Monzo` and inject an `Amelia\\Monzo\\Contracts\\Client` instance into it, as follows:\n\n```php\n\u003c?php\n\n$client = new Amelia\\Monzo\\Client(\n    new GuzzleHttp\\Client,\n    getenv('MONZO_CLIENT_ID') ?: null,\n    getenv('MONZO_CLIENT_SECRET') ?: null\n);\n\n$monzo = new Amelia\\Monzo\\Monzo($client);\n\n// Amelia\\Monzo\\Monzo::setAccessToken($token) for single user mode\n```\n\n**If using Laravel**, you only need to inject `Amelia\\Monzo\\Monzo` via the service container, using `resolve()` or `app()`.\n\nUsing the API is pretty simple.\n\nIn general, you'll need an access token or a user object.\n\n## Examples\n\n\n### Grab a user's accounts.\n\n```php\n\u003c?php\n\n$user = User::findOrFail($id);\n\n$accounts = $monzo-\u003eas($user)-\u003eaccounts();\n```\n\n### Grab the last 100 transactions for a user account\n\n```php\n\u003c?php\n\n$user = User::findOrFail($id);\n\n$transactions = $monzo-\u003eas($user)-\u003etransactions('acc_12341243');\n```\n\n### Grab the last 100 transactions for a user's default account\n\n```php\n\u003c?php\n\n$user = User::findOrFail($id);\n\n// will query accounts first, then use the default to query transactions.\n$transactions = $monzo-\u003eas($user)-\u003etransactions();\n```\n\n### Grab a paginator instance for a user's transactions\n\n```php\n\u003c?php\n\n$user = User::findOrFail($id);\n\n$transactions = $monzo-\u003eas($user)-\u003epaginate(50)-\u003etransactions('acc_12341243');\n```\n\n### Expand (and hydrate) relations in the API\n\n```php\n\u003c?php\n\n$user = User::findOrFail($id);\n\n$transactions = $monzo-\u003eas($user)\n    -\u003epaginate(50)\n    -\u003eexpand('account')\n    -\u003etransactions('acc_12341243');\n```\n\n### See a user's balance\n\n```php\n\u003c?php\n\n$user = User::findOrFail($id);\n\n$balance = $monzo-\u003eas($user)-\u003ebalance();\n```\n\n","funding_links":[],"categories":["Code \u0026 Client Libraries"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fameliaikeda%2Fmonzo-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fameliaikeda%2Fmonzo-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fameliaikeda%2Fmonzo-php/lists"}