Skip to content

Instantly share code, notes, and snippets.

@t0mdicks0n
Last active March 22, 2019 09:00
Show Gist options
  • Save t0mdicks0n/b0335b4dd1b31d3e7e4a0e458b013e8d to your computer and use it in GitHub Desktop.
Save t0mdicks0n/b0335b4dd1b31d3e7e4a0e458b013e8d to your computer and use it in GitHub Desktop.
Small post on how interacting with Tink's excellent API works.

Step 0: Create a developer account at Tink

I was very surprised to find out how easy this was. Cudos to Tink for creating an amazing developer experience!

Step 1: Trigger Tink Link to let user verify Moneypenny as a reader of financial information.

  1. Display the UI
https://oauth.tink.com/0.4/authorize/?client_id=<insert client_id here>&redirect_uri=http://localhost:3000/callback&market=SE&locale=en_US&scope=accounts:read,user:read,credentials:read,transactions:read,investments:read,statistics:read
  1. Get the code in the final url: Code:

Step 2: Retrieve a access token based on the code from step 1

curl -v -X POST https://api.tink.se/api/v1/oauth/token \
-d 'code=<the code from above>' \
-d 'client_id=<insert client_id here>' \
-d 'client_secret=<insert client_secret here>' \
-d 'grant_type=authorization_code'

The result for SHB being:

{
  "token_type" : "bearer",
  "expires_in" : 7200,
  "access_token" : "<the access_token you receive>",
  "refresh_token" : "<the refresh_token you receive>",
  "scope" : "accounts:read,user:read,credentials:read,transactions:read,investments:read,statistics:read"
}

Step 3: Get data via the API

Do a request on all the accounts list on SHB

curl -v https://api.tink.se/api/v1/accounts/list \
-H 'Authorization: Bearer <the access_token you receive>'

The result:

{
  "accounts" : [ {
    "accountNumber" : "6155-122 960 xxx",
    "availableCredit" : 0.0,
    "balance" : 0.0,
    "bankId" : "1229608xx",
    "certainDate" : null,
    "credentialsId" : "32062608619a44c38cb657cadfbafxxx",
    "excluded" : false,
    "favored" : false,
    "id" : "40480b2e97b34b38a19e04b4d3394xxx",
    "name" : "Används ej",
    "ownership" : 1.0,
    "payload" : null,
    "type" : "CHECKING",
    "userId" : "1d4d6c4837b24a1c9476a9702c7ca3xxx",
    "userModifiedExcluded" : false,
    "userModifiedName" : false,
    "userModifiedType" : false,
    "identifiers" : "[\"se://6155122960xxx\",\"se-internal://122960xxx\"]",
    "transferDestinations" : null,
    "details" : null,
    "images" : {
      "icon" : "https://cdn.tink.se/provider-images/handelsbanken.png",
      "banner" : null
    },
    "holderName" : "Jon Doe",
    "closed" : false,
    "flags" : "[]",
    "accountExclusion" : "NONE"
  }, {
    "accountNumber" : "15-276390-138xxx",
    "availableCredit" : 0.0,
    "balance" : -43571334234.0,
    "bankId" : "15276390138xxx",
    "certainDate" : null,
    "credentialsId" : "32062608619a44c38cb657cadfbafxxx",
    "excluded" : false,
    "favored" : false,
    "id" : "1c7736e4978e4946880651c35dd40xxx",
    "name" : "Stadshypotek",
    "ownership" : 1.0,
    "payload" : null,
    "type" : "LOAN",
    "userId" : "1d4d6c4837b24a1c9476a9702c7cxxxx",
    "userModifiedExcluded" : false,
    "userModifiedName" : false,
    "userModifiedType" : false,
    "identifiers" : "[\"se://15276390138xxx\"]",
    "transferDestinations" : null,
    "details" : {
      "interest" : 0.0015,
      "numMonthsBound" : 3,
      "type" : "MORTGAGE",
      "nextDayOfTermsChange" : 1556661600000
    },
    "images" : {
      "icon" : "https://cdn.tink.se/provider-images/handelsbanken.png",
      "banner" : null
    },
    "holderName" : null,
    "closed" : false,
    "flags" : "[]",
    "accountExclusion" : "NONE"
  }, {
    "accountNumber" : "15-276390-138xxx",
    "availableCredit" : 0.0,
    "balance" : -378622343245.0,
    "bankId" : "15276390138xxx",
    "certainDate" : null,
    "credentialsId" : "32062608619a44c38cb657cadfbaxxxx",
    "excluded" : false,
    "favored" : false,
    "id" : "a4ae064bdc6b4ed786136fd97b26xxx",
    "name" : "Stadshypotek",
    "ownership" : 1.0,
    "payload" : null,
    "type" : "LOAN",
    "userId" : "1d4d6c4837b24a1c9476a9702c7caxxx",
    "userModifiedExcluded" : false,
    "userModifiedName" : false,
    "userModifiedType" : false,
    "identifiers" : "[\"se://15276390138xxx\"]",
    "transferDestinations" : null,
    "details" : {
      "interest" : 0.02,
      "numMonthsBound" : 60,
      "type" : "MORTGAGE",
      "nextDayOfTermsChange" : 1609282800000
    },
    "images" : {
      "icon" : "https://cdn.tink.se/provider-images/handelsbanken.png",
      "banner" : null
    },
    "holderName" : null,
    "closed" : false,
    "flags" : "[]",
    "accountExclusion" : "NONE"
  }, {
    "accountNumber" : "6155-210 764 xxx",
    "availableCredit" : 0.0,
    "balance" : 25000000.0,
    "bankId" : "210764xxx",
    "certainDate" : null,
    "credentialsId" : "32062608619a44c38cb657cadfbafxxx",
    "excluded" : false,
    "favored" : false,
    "id" : "a0fd2487ce3d4003a7c641c2ba76xxx",
    "name" : "Parkerat",
    "ownership" : 1.0,
    "payload" : null,
    "type" : "SAVINGS",
    "userId" : "1d4d6c4837b24a1c9476a9702c7caxxx",
    "userModifiedExcluded" : false,
    "userModifiedName" : false,
    "userModifiedType" : false,
    "identifiers" : "[\"se://6155210764xxx\",\"se-internal://210764xxx\"]",
    "transferDestinations" : null,
    "details" : null,
    "images" : {
      "icon" : "https://cdn.tink.se/provider-images/handelsbanken.png",
      "banner" : null
    },
    "holderName" : "Jon Doe",
    "closed" : false,
    "flags" : "[]",
    "accountExclusion" : "NONE"
  }, {
    "accountNumber" : "26734xxx",
    "availableCredit" : 0.0,
    "balance" : 0.0,
    "bankId" : "26734xxx",
    "certainDate" : null,
    "credentialsId" : "32062608619a44c38cb657cadfbafxxx",
    "excluded" : false,
    "favored" : false,
    "id" : "9e387c3852b64f3d92f5e9a3a66bdxxx",
    "name" : "Fondinnehav",
    "ownership" : 1.0,
    "payload" : null,
    "type" : "INVESTMENT",
    "userId" : "1d4d6c4837b24a1c9476a9702c7cxxxx",
    "userModifiedExcluded" : false,
    "userModifiedName" : false,
    "userModifiedType" : false,
    "identifiers" : "[]",
    "transferDestinations" : null,
    "details" : null,
    "images" : {
      "icon" : "https://cdn.tink.se/provider-images/handelsbanken.png",
      "banner" : null
    },
    "holderName" : null,
    "closed" : false,
    "flags" : "[]",
    "accountExclusion" : "NONE"
  }]

You can then also access the investements resources

/api/v1/investments

curl -v https://api.tink.se/api/v1/investments \
-H 'Authorization: Bearer <the access_token you receive>'

TODO: Explore this further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment