do|try|catch

An iOS & Swift development blog by Stuart Breckenridge.

Released: Detailed Products Kit

Today I released DetailedProductsKit. It is an iOS and macOS library written in Swift that manages all interaction with the Franklin Templeton Detailed Products API. You can integrate it into your app via Cocoapods. The source code is available on Github .

Motivation

Twofold:

  • Get up and running with the API in as few lines of code as possible1
  • Make integrating the API into your app (and mine) as simple as possible

Functionality

  • Authentication with the API
  • Data download
  • JSON decoding
  • Error handling
  • Response caching
  • Get up and running three lines of code
  • All v1 API endpoints supported

Usage

Add the following line to your Podfile and then run pod install:

pod 'DetailedProductsKit'

Add the following import declaration to the class where you want to use the API:

import DetailedProductsKit

Create a constant:

let productsAPI = DetailedProductsAPI(key: "CONSUMER_KEY", secret: "CONSUMER_SECRET")

After productsAPI is initialised, you can call any of the supported API endpoints. For example, to get the latest fund NAV data:

productsAPI.getFundNav(fundKey: "US8802081039", fundKeyType: .ISIN) { (fundNav, error) in
    // Your code
}

Example App

An example iOS application is included which demonstrates the various API calls that are available.

  1. Four lines of code, including the changes to the Podfile. ↩︎