NAV Navbar
Swift Java Kotlin
  • Introduction
  • Getting Started
  • Authentication
  • Account
  • Transactions
  • Errors
  • Introduction

    Welcome to the Spar Nord SDK documentation! You can use our SDK to access Spar Nord API endpoints, which can get information on accounts and transactions.

    We have an SDK for iOS and Android! You can view code examples in the dark area to the right, and you can switch the programming language (Swift, Java or Kotlin) of the examples with the tabs in the top right.

    Getting Started

    The Spar Nord SDK is available for iOS and Android. To make it easy for you to get started the SDK can be installed using CocoaPods for iOS or Gradle for Android.

    The SDKs for Android and iOS can be downloaded here:

    Requirements:

    iOS:

    Android:

    The Android SDK is written in Kotlin, so your Android project may require Kotlin Support.

    iOS

    CocoaPods

    To integrate Spar Nord SDK into your Xcode project, specify it in your Podfile:

    platform :ios '11.0'
    use_frameworks!
    
    # Replace "<Your Target Name>" with the name of your target.
    target '<Your Target Name>' do
      pod 'SparNordSDK', '~> 1.0'
    end
    

    After specifying it in your Podfile run the following command:

    $ pod install
    

    CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command in your terminal:

    $ gem install cocoapods

    Manual

    If you don't want to use CocoaPods you can download the SDK and add it to your iOS project.

    Android

    To use the Android SDK you will have to download the SDK and add it as a module in your Android project.

    Follow these steps to import the SDK as a module in Android Studio:

    1. Download Android SDK
    2. Go to File -> New -> Import Module...
    3. Select the source directory of the SparNordSDK module and click Finish.
    4. Open Project Structure and open Module Settings for your project.
    5. Open the Dependencies tab.
    6. Click the (+) icon and select Module Dependency. Select the SparNordSDK module and click Ok.
    7. Open your build.gradle file and check that the module is now listed under dependencies.

    Authentication

    Register

    To register the user, use this code:

    SparNordManager.shared.register(cpr: "2412820000", pincode: "1234") { json, error in
     // Check if register succeeded.
    }
    
    SparNordManager.getInstance(context).register("2412820000", "1234", new Function2<JSONObject, SNError, Unit>() {
      @Override
      public Unit invoke(JSONObject jsonObject, SNError snError) {
        // Check if register succeeded.
        return null;
      }
    });
    
    SparNordManager.getInstance(context).register("2412820000", "1234") { json, error ->
      // Check if register succeeded.
    }
    

    Before make requests using the Spar Nord SDK you will need to authenticate the user.

    Register using the users CPR number and allow the user to create a pincode for making it easy to log on the next time the user wants to use the app.

    Use one of the following CPR numbers for registering:

    Test Customers Account
    2412820000 4574000000
    2412820001 4574000001
    2412820002 4574000002
    2412820003 4574000003
    2412820004 4574000004

    Parameters

    Parameter Description
    cpr The CPR number (civil registration number) of the user.
    pincode Pincode specified by user, which is used when logging in.

    Login

    After the user has been registered, login like this:

    SparNordManager.shared.login(pincode: "123456") { json, error in
      // Check if login succeeded.
    }
    
    SparNordManager.getInstance(context).login("1234", new Function2<JSONObject, SNError, Unit>() {
      @Override
      public Unit invoke(JSONObject jsonObject, SNError snError) {
        // Check if login succeeded.
        return null;
      }
    });
    
    SparNordManager.getInstance(context).login("1234") { json, error ->
      // Check if login succeeded.
    }
    

    If the user is already registered you should login the user to access information.

    Account

    Get Accounts

    Get all accounts for the logged in user:

    SparNordManager.shared.getAccounts { json, error in
      // The JSON contains all the accounts.
    }
    
    SparNordManager.getInstance(context).getAccounts(new Function2<JSONObject, SNError, Unit>() {
      @Override
      public Unit invoke(JSONArray jsonArray, SNError snError) {
        // The jsonArray contains all the accounts.
        return null;
      }
    });
    
    SparNordManager.getInstance(context).getAccounts { jsonArray, error ->
      // The jsonArray contains all the accounts.
    }
    

    Example of JSON response for accounts:

    [
      {
        "_id": "4574000000",
        "accountOwner": "2412820000",
        "accountStatus": "ACTIVE",
        "balance": 10231.74,
        "creditMax": 0
      },
      {
        "_id": "4574000001",
        "accountOwner": "2412820001",
        "accountStatus": "ACTIVE",
        "balance": 131.52,
        "creditMax": 0
      }
    ]
    

    Retrieves the list of accounts for the user.

    Response

    Property Description
    _id The account id used to identify accounts within Spar Nord.
    accountOwner The owner of the account.
    accountStatus Status of account.
    balance The account balance.
    creditMax Credit limit.

    Get a Specific Account

    Get a specific account for the logged in user:

    SparNordManager.shared.getSpecificAccount(accountId: "4574000000") { json, error in
      // JSON contains the requested account.
    }
    
    SparNordManager.getInstance(context).getSpecificAccount("4574000000", new Function2<JSONObject, SNError, Unit>() {
      @Override
      public Unit invoke(JSONObject jsonObject, SNError snError) {
        // jsonObject contains the requested account.
        return null;
      }
    });
    
    SparNordManager.getInstance(context).getSpecificAccount("4574000000") { json, error ->
      // json contains the requested account.
    }
    

    Example of JSON response for a specific account:

    {
      "_id": "4574000000",
      "accountOwner": "2412820000",
      "accountStatus": "ACTIVE",
      "balance": 10231.74,
      "creditMax": 0
    }
    

    Retrieves a specific account.

    See Get Accounts for response documentation.

    Parameters

    Parameter Description
    accountId Id of a specific account.

    Get Account Balance

    Get balance for account:

    SparNordManager.shared.getAccountBalance(accountId: "4574000000") { json, error in
      // JSON contains account balance.
    }
    
    SparNordManager.getInstance(context).getAccountBalance("4574000000", new Function2<JSONObject, SNError, Unit>() {
      @Override
      public Unit invoke(JSONObject jsonObject, SNError snError) {
        // jsonObject contains account balance.
        return null;
      }
    });
    
    SparNordManager.getInstance(context).getAccountBalance("4574000000") { json, error ->
      // json contains account balance.
    }
    

    Example of JSON response for account balance:

    {
        "balance": 2512.76,
        "currency": "DKK"
    }
    

    Retrieves only the book balance of a specific account.

    Parameters

    Parameter Description
    accountId Id of a specific account.

    Response

    Property Description
    balance The current book balance of the account in the base currency.
    currency The base currency of the account.

    Create Account

    Creates a new account.

    Create new account:

    SparNordManager.shared.createAccount(name: "Opsparing") { json, error in
        // JSON contains data for the new account.
    }
    
    SparNordManager.getInstance(context).createAccount("Opsparing", new Function2<JSONObject, SNError, Unit>() {
      @Override
      public Unit invoke(JSONObject jsonObject, SNError snError) {
        // jsonObject contains data for the new account.
        return null;
      }
    });
    
    SparNordManager.getInstance(context).createAccount("Opsparing") { json, error ->
      // json contains data for the new account.
    }
    

    Example of JSON response for a new account:

    {
      "_id": "4574000010",
      "accountOwner": "2412820000",
      "accountStatus": "ACTIVE",
      "balance": 10231.74,
      "creditMax": 0
    }
    

    Parameters

    Parameter Description
    accountName The user-given name of the account.

    Transactions

    Get Transactions

    Get transactions between two dates:

    let startDate = Date(timeIntervalSince1970: 1437696000) // 2015-07-24
    SparNordManager.shared.getTransactions(accountId: "4574000000", startPostingDate: startDate, endPostingDate: Date()) { json, error
      // JSON contains all transactions between start and end date.
    }
    
    SparNordManager.getInstance(context).getTransactions("4574000000", startDate, endDate, new Function2<JSONArray, SNError, Unit>() {
      @Override
      public Unit invoke(JSONArray JSONArray, SNError snError) {
        // jsonArray contains all transactions between start and end date.
        return null;
      }
    });
    
    SparNordManager.getInstance(context).getTransactions("4574000000", startDate, now) { json, error ->
      // json contains all transactions between start and end date.
    }
    

    Example of JSON response for transactions:

    [
      {
        "_id": {
          "$oid": "56d46992f4c700149de12151"
        },
        "accountNumber": "4574000000",
        "amount": 150,
        "merchantCategoryCode": "4829",
        "paymentMedia": "CARD_ISO",
        "postingText": "MobilePay, Koebenhavn K Nota nr. C01245",
        "reconciled": false,
        "timestamp": {
          "$date": "2015-09-19T05:45:45.546Z"
        }
      },
      {
        "_id": {
          "$oid": "56d46995f4c700149de13a0e"
        },
        "accountNumber": "4574000000",
        "amount": -2017.83,
        "merchantCategoryCode": "",
        "paymentMedia": "NO_MEDIA",
        "postingText": "Betalingsservice A/B KJELLERUPSGADE 21 A \u0026 B Aftalenr. 801234567",
        "reconciled": false,
        "timestamp": {
          "$date": "2015-09-01T03:02:43.684Z"
        }
      },
      {
        "_id": {
          "$oid": "56d46995f4c700149de13d3d"
        },
        "accountNumber": "4574000000",
        "amount": 20.0,
        "merchantCategoryCode": "",
        "paymentMedia": "NO_MEDIA",
        "postingText": "MobilePay: Villum Petersen",
        "reconciled": false,
        "timestamp": {
          "$date":  "2015-12-16T12:02:50.231Z"
        }
      }
    ]
    

    Retrieves the transactions that matches the given parameters.

    Parameters

    Parameter Description
    accountId Id of a specific account.
    start-posting-date Specify the start transaction posting date to start retrieving transaction posting entries for.
    end-posting-date Specify the end transaction posting date to stop retrieving transaction posting entries for.

    Response

    Property Description
    _id The ID of the transaction posting entry.
    accountNumber Account number.
    amount The amount of the transaction posting entry (negative indicates withdrawal).
    merchantCategoryCode Merchant category code for the transaction.
    paymentMedia Media type for transaction.
    postingText The posting text (a.k.a. description) of the transaction.
    reconciled Indicates if the transaction is reconciled or not.
    timestamp Timestamp for transaction. Example: 2015-10-14T16:05:54.295Z

    Create Transaction

    Create a new transaction:

    SparNordManager.shared.createTransaction(amount: 100, executionDate: Date(),
                                                  debtorAccountId: "4574000000",
                                                  creditorAccountId: "4574000001",
                                                  serviceLevel: .immediate,
                                                  debtorsPostingEntryDescription: "Udlæg",
                                                  creditorsPostingEntryDescription: "Udlæg - Emily Christensen") { json, error in
                                                    // JSON contains data from the new transaction.
    }
    
    SparNordManager.getInstance(context).createTransaction(100, date, "4574000000", "4574000001", ServiceLevel.IMMEDIATE, "Udlæg", "Udlæg - Emily Christensen", new Function2<JSONObject, SNError, Unit>() {
      @Override
      public Unit invoke(JSONObject jsonObject, SNError snError) {
        // jsonObject contains data from the new transaction.
        return null;
      }
    });
    
    SparNordManager.getInstance(context).createTransaction(100.0, now, "123", "1234", ServiceLevel.IMMEDIATE, "Test", "Test") { json, error ->
      // json contains data from the new transaction.
    }
    

    Creates an transaction, i.e. transfers money between two accounts.

    Request

    Property Optional Description
    amount false The amount to transfer from the creditor to the debtor.
    requestedExecutionDate false The date on which the transfer should occur. Note, this must be a valid bank date!
    debtorAccountId false The account ID of the debtor account.
    creditorAccountId false The account ID of the creditor account.
    serviceLevel false Specifies when the payment is available to creditor. See Service Level Values
    debtorsPostingEntryDescription false The posting text (a.k.a. description) of the posting regarding the debtor account. Note, there is a maximum length.
    creditorsPostingEntryDescription false The posting text (a.k.a. description) of the posting regarding the creditor account. Note, there is a maximum length.
    standingOrder true Repeated transfers.
    endDate true End date of the standing order.
    eventCount true The number of payment instructions that are to be generated by the standing order money scheduler.
    frequency false The frequency with which payment instruction are created by the money scheduler. See Frequency Values

    Service Level Values

    Value Description
    IMMEDIATE The payment will be received by the creditor within seconds. If the creditor is within the same bank as debtor it becomes an internal bank transfer. If the creditor is outside the bank a clearing transaction is created.
    SAME_DAY The payment will be send to clearing at the time slots 0900, 1200 and 1400. There is a cut off time 2 hours before each clearing cycle which mean that e.g an instruction must be send to clearing before 1200 to be included in the 1400 clearing cycle. If later than 1200 (and no execution date later than today’s date is requested) then the payment will be available to creditor the next banking day.
    DK_STD The payment will be in the danish national nightly clearing and will be available to the creditor the next banking day.

    Frequency Values

    Value Description
    FDIM First banking day in month.
    15IM The 15th in month (if not banking day, next banking day is chosen - if next banking day is next month, prior banking day is used).
    LDIM Once a week (if not banking day, next banking day is chosen - if next banking day is next month, prior banking day is used).
    2WEK Once every second week (if not banking day, next banking day is chosen - if next banking day is next month, prior banking day is used).
    MNTH Once a month (if not banking day, next banking day is chosen - if next banking day is next month, prior banking day is used).
    QART Quarterly (if not banking day, next banking day is chosen - if next banking day is next month, prior banking day is used).
    HLFY Every half year (if not banking day, next banking day is chosen - if next banking day is next month, prior banking day is used).
    YEAR Every year (if not banking day, next banking day is chosen - if next banking day is next month, prior banking day is used).

    Errors

    The Spar Nord SDK uses the following errors:

    Error Meaning
    Unauthorized Not authorized.
    Request failed The server could not understand the request.
    Not found The requested resource could not be found.
    Parse error Parsing of response failed.