Giter Site home page Giter Site logo

zachasme / nordigen-ruby Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nordigen/nordigen-ruby

0.0 0.0 0.0 471 KB

Ruby library for the Nordigen API.

License: MIT License

Shell 0.20% JavaScript 5.68% Ruby 79.87% CSS 1.09% HTML 12.34% SCSS 0.82%

nordigen-ruby's Introduction

Nordigen Ruby Library

This is official Ruby client library for Nordigen.

For a full list of endpoints and arguments, see the docs.

Before starting to use API you will need to create a new secret and get your SECRET_ID and SECRET_KEY from the Nordigen's Open Banking Portal.

Requirements

  • Ruby 2.6+

Installation

Install library

gem install nordigen-ruby

Example application

Example code can be found in main.rb file and Ruby on Rails example application can be found in example directory

Quickstart

require 'securerandom'
require 'nordigen-ruby'

# Get secret_id and secret_key from ob.nordigen.com portal and pass to NordigenClient or load from .env file
client = Nordigen::NordigenClient.new(
  secret_id: "SECRET_ID",
  secret_key: "SECRET_KEY"
)

# Generate new access token. Token is valid for 24 hours
token_data = client.generate_token()

# Use existing token
client.set_token("YOUR_TOKEN")

# Get access and refresh token
# Note: access_token is automatically injected to other requests after you successfully obtain it
access_token = token_data["access"]
refresh_token = token_data["refresh"]

# Exchange refresh token. Refresh token is valid for 30 days
refresh_token = client.exchange_token(refresh_token)

# Get all institution by providing country code in ISO 3166 format
institutions = client.institution.get_institutions("LV")

# Institution id can be gathered from get_institutions response.
# Example Revolut ID
id = "REVOLUT_REVOGB21"

# Initialize bank authorization session
# Returns requisition_id and link to initiate authorization with a bank
init = client.init_session(
  # redirect url after successful authentication
  redirect_url: "https://nordigen.com",
  # institution id
  institution_id: id,
  # a unique user ID of someone who's using your services, usually it's a UUID
  reference_id: SecureRandom.uuid
)

link = init["link"] # bank authorization link
requisition_id = init["id"] # requisition id that is needed to get an account_id
puts link

After successful authorization with a bank you can fetch your data (details, balances, transactions)

Fetching account metadata, balances, details and transactions

# Get account id after you have completed authorization with a bank.
requisition_data = client.requisition.get_requisition_by_id(requisition_id)
# Get account id from list
account_id =  accounts["accounts"][0]

# Instantiate account object
account = client.account_api(account_id)

# Fetch account metadata
meta_data = account.get_metadata()
# Fetch details
details = account.get_details()
# Fetch balances
balances = account.get_balances()
# Fetch transactions
transactions = account.get_transactions()
# Filter transactions by specific date range
transactions = account.get_transactions(date_from: "2021-12-01", date_to: "2022-01-30")

Development

Run all tests in a directory

ruby -Itest tests/tests.rb

Support

For any inquiries please contact support at [email protected] or create an issue in repository.

nordigen-ruby's People

Contributors

dipo avatar nathanberthier avatar victory-sokolov avatar zachasme avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.