ma

monzo-api

Easy interaction with monzo-api made for node

Showing:

Popularity

Downloads/wk

12

GitHub Stars

5

Maintenance

Last Commit

4yrs ago

Contributors

4

Package

Dependencies

2

Size (min+gzip)

14.5KB

License

MIT

Type Definitions

Tree-Shakeable

Yes?

Categories

Readme

monzo-api

Node Monzo API easy integration

Instalation

npm i monzo-api -S

Usage

import MonzoApi from 'monzo-api';

const clientId = 'your-app-client-id';
const clientSecret = 'your-app-client-secret';
const verificationCode = 'code-that-server-gets-after-the-redirection';
const verificationStateToken = 'state-token-received-in-query-string-after-redirection';
const monzoApi = new MonzoApi(clientId, clientSecret);

monzoApi.redirectUrl = 'http://127.0.0.1/monzo-validation';

console.log('Redirect the user to', monzoApi.authorizationUrl);

monzoApi.authenticate(code, 'exampleStateToken')
        .then((res) => {
            console.log("Congrats, you're logged in", res);
        })
        .catch((err) => {
            console.error('Uh Oh! Something wrong happened. :(');
            console.error(err);
        });

Documentation

new MonzoApi(clientId, clientSecret)

Create a monzo api instance.

ParamTypeDescription
clientIdstringThe client id value.
clientSecretstringThe client secret value.

monzoApi.clientId

Set the clientId value.

Kind: instance property of MonzoApi

ParamTypeDescription
valuestringThe clientId value.

monzoApi.clientId ⇒ string

Get the clientId value.

Kind: instance property of MonzoApi Returns: string - The clientId value.

monzoApi.clientSecret

Set the clientSecret value.

Kind: instance property of MonzoApi

ParamTypeDescription
valuestringThe clientSecret value.

monzoApi.clientSecret ⇒ string

Get the clientSecret value.

Kind: instance property of MonzoApi Returns: string - The clientSecret value.

monzoApi.redirectUrl

Set the redirectUrl value.

Kind: instance property of MonzoApi

ParamTypeDescription
valuestringThe redirectUrl value.

monzoApi.redirectUrl ⇒ string

Get the redirectUrl value.

Kind: instance property of MonzoApi Returns: string - The redirectUrl value.

monzoApi.refreshToken

Set the refreshToken value.

Kind: instance property of MonzoApi

ParamTypeDescription
valuestringThe refreshToken value.

monzoApi.refreshToken ⇒ string

Get the refreshToken value.

Kind: instance property of MonzoApi Returns: string - The refreshToken value.

monzoApi.accessToken

Set the accessToken value.

Kind: instance property of MonzoApi

ParamTypeDescription
valuestringThe accessToken value.

monzoApi.accessToken ⇒ string

Get the accessToken value.

Kind: instance property of MonzoApi Returns: string - The accessToken value.

monzoApi.code ⇒ string

Get the code value. It will be set when authenticate method gets called

Kind: instance property of MonzoApi Returns: string - The code value.

monzoApi.stateToken ⇒ string

Get the stateToken value. Value that will be matched against the one provided when a user authenticates. The values must match otherwise the authentication won't proceed

Kind: instance property of MonzoApi Returns: string - The stateToken value.

monzoApi.stateToken ⇒ string

Set the stateToken

Kind: instance property of MonzoApi Returns: string - The stateToken value.

monzoApi.authorizationUrl ⇒ string

Get the authorizationUrl value. The user needs to be redirected to this url in order to authenticate

Kind: instance property of MonzoApi Returns: string - The authorizationUrl value.

monzoApi.generateStateToken() ⇒ String

Create a state token that gets send on the authorizationUrl

Kind: instance method of MonzoApi Returns: String - The token value that was stored and needs to be compared on authorization

monzoApi.authenticate(code, stateToken, [verifyStateToken]) ⇒ Promise.<object, Error>

Authenticate the user given the code and the stateToken found in the query string of the redirectUrl

Kind: instance method of MonzoApi Returns: Promise.<object, Error> - A promise that returns an object if resolved, or an Error if rejected.

ParamTypeDefaultDescription
codestringThe code value.
stateTokenstringThe state token value.
[verifyStateToken]stringfalseUse this token instead of the one registered in the API.

monzoApi.refreshAccess([refreshToken]) ⇒ Promise.<object, Error>

Refreshes the user access token using the refresh one

Kind: instance method of MonzoApi Returns: Promise.<object, Error> - A promise that returns an object if resolved, or an Error if rejected.

ParamTypeDescription
[refreshToken]stringToken to refresh the access

monzoApi.ping([acessToken]) ⇒ Promise.<object, Error>

Pings the API to check whether everything is correct

Kind: instance method of MonzoApi Returns: Promise.<object, Error> - A promise that returns an object if resolved, or an Error if rejected.

ParamTypeDescription
[acessToken]stringThe accessToken for the request.

monzoApi.accounts([acessToken]) ⇒ Promise.<object, Error>

Returns the accounts for the authenticated user

Kind: instance method of MonzoApi Returns: Promise.<object, Error> - A promise that returns an object if resolved, or an Error if rejected.

ParamTypeDescription
[acessToken]stringThe accessToken for the request.

monzoApi.balance(accountId, [acessToken]) ⇒ Promise.<object, Error>

Reads the balance

Kind: instance method of MonzoApi Returns: Promise.<object, Error> - A promise that returns an object if resolved, or an Error if rejected.

ParamTypeDescription
accountIdstringThe account id to check the balance in.
[acessToken]stringThe accessToken for the request.

monzoApi.transaction(transactionId, [expanded], [acessToken]) ⇒ Promise.<object, Error>

Returns an individual transaction, fetched by its id.

Kind: instance method of MonzoApi Returns: Promise.<object, Error> - A promise that returns an object if resolved, or an Error if rejected.

ParamTypeDefaultDescription
transactionIdstringThe transaction id to check details in
[expanded]booleantrueWhether the details for merchant are expanded or not
[acessToken]stringThe accessToken for the request.

monzoApi.transactions(accountId, [expanded], [query], [acessToken]) ⇒ Promise.<object, Error>

List transactions

Kind: instance method of MonzoApi Returns: Promise.<object, Error> - A promise that returns an object if resolved, or an Error if rejected.

ParamTypeDefaultDescription
accountIdstringThe account id to check transactions in
[expanded]booleanfalseWhether the details for merchant are expanded or not
[query]object{}Can be used to add pagination. https://monzo.com/docs/#pagination
[acessToken]stringThe accessToken for the request.

monzoApi.annotate(transactionId, metadata, [acessToken]) ⇒ Promise.<object, Error>

Annotate transaction. You may store your own key-value annotations against a transaction in its metadata.

Kind: instance method of MonzoApi Returns: Promise.<object, Error> - A promise that returns an object if resolved, or an Error if rejected.

ParamTypeDescription
transactionIdstringThe transaction id to add the annotation
metadataobjectThe key values pairs to store in the metadata. Include each key you would like to modify. To delete a key, set its value to an empty string
[acessToken]stringThe accessToken for the request.

monzoApi.feedItem(accountId, [url], [type], [params], [acessToken]) ⇒ Promise.<object, Error>

Creates a new feed item on the user’s feed. Check https://monzo.com/docs/#feed-items for the params details

Kind: instance method of MonzoApi Returns: Promise.<object, Error> - A promise that returns an object if resolved, or an Error if rejected.

ParamTypeDefaultDescription
accountIdstringThe account id to add the feed item
[url]stringA URL to open when the feed item is tapped. If no URL is provided, the app will display a fallback view based on the title & body.
[type]string"basic"Type of feed item.
[params]object{}A map of parameters which vary based on type.
basic type e.g.
{
  title: 'My custom item',
  image_url: 'www.example.com/image.png',
  background_color: '#FCF1EE',
  body_color: '#FCF1EE',
  title_color: '#333',
  body: 'Some body text to display'
}
[acessToken]stringThe accessToken for the request.

monzoApi.registerWebhook(accountId, url, [acessToken]) ⇒ Promise.<object, Error>

Webhooks allow your application to receive real-time, push notification of events in an account. Each time a matching event occurs, monzo will make a POST call to the URL you provide. If the call fails, monzo will retry up to a maximum of 5 attempts, with exponential backoff.

Kind: instance method of MonzoApi Returns: Promise.<object, Error> - A promise that returns an object if resolved, or an Error if rejected.

ParamTypeDescription
accountIdstringThe account id to add the webhook to
urlstringThe url to send notifications to
[acessToken]stringThe accessToken for the request.

monzoApi.webhooks(accountId, [acessToken]) ⇒ Promise.<object, Error>

List the webhooks your application has registered on an account.

Kind: instance method of MonzoApi Returns: Promise.<object, Error> - A promise that returns an object if resolved, or an Error if rejected.

ParamTypeDescription
accountIdstringThe account to list registered webhooks for
[acessToken]stringThe accessToken for the request.

monzoApi.deleteWebhook(webhookId, [acessToken]) ⇒ Promise.<object, Error>

Delete a webhook

Kind: instance method of MonzoApi Returns: Promise.<object, Error> - A promise that returns an object if resolved, or an Error if rejected.

ParamTypeDescription
webhookIdstringThe webhook to delete
[acessToken]stringThe accessToken for the request.

monzoApi.uploadImage(file, fileName, fileType) ⇒ Promise.<object, Error>

Hosts an image in Monzo S3 Bucket. Will try to gzip the contents before uploading it

Kind: instance method of MonzoApi Returns: Promise.<object, Error> - A promise that returns an object if resolved, or an Error if rejected.

ParamTypeDescription
filestring | BufferCan be the file absolute location, a base64 representation or the Buffer content of an image
fileNamestringA meaningful name for the image
fileTypestringThe mime type of the image e.g. image/png

monzoApi.registerAttachment(externalId, fileUrl, fileType, [acessToken]) ⇒ Promise.<object, Error>

Register attachment

Kind: instance method of MonzoApi Returns: Promise.<object, Error> - A promise that returns an object if resolved, or an Error if rejected.

ParamTypeDescription
externalIdstringThe id of the transaction to associate the attachment with.
fileUrlstringThe URL of the uploaded attachment.
fileTypestringThe content type of the attachment. e.g. "image/png"
[acessToken]stringThe accessToken for the request.

monzoApi.deregisterAttachment(attachmentId, [acessToken]) ⇒ Promise.<object, Error>

Deregister attachment

Kind: instance method of MonzoApi Returns: Promise.<object, Error> - A promise that returns an object if resolved, or an Error if rejected.

ParamTypeDescription
attachmentIdstringThe id of the attachment to deregister.
[acessToken]stringThe accessToken for the request.

monzoApi.makeRequest(requestType, requestEndpoint, requestData, [useBearer]) ⇒ Promise.<object, Error>

Makes any request to the Monzo API

Kind: instance method of MonzoApi Returns: Promise.<object, Error> - A promise that returns an object if resolved, or an Error if rejected.

ParamTypeDefaultDescription
requestTypestringCan be 'GET', 'POST', 'PATCH' or 'DELETE'
requestEndpointstringThe path of the API url. e.g. 'ping/whoami'
requestDataobjectAny data that needs to be sent to the server
[useBearer]booleantrueWhether to insert the accessToken into the request header or not

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100