Latest 1.0.0
License MIT
Platforms ios 9.0

license MIT

A convenient way to make REST API calls and parse data from JSON responses.


  • Xcode 8
  • Swift 3.0
  • iOS 9.0+


CocoaPods. Please use the latest CocoaPods as this framework is using Swift 3


pod 'APNetworking'


Use JsonRequestto create post, get, put or delete request. Create your own parser confirming to GenericResponseParser, set it for the request using angle brackets and get fully parsed object back.


Say you have an API call that returns JSON of photos:

    "albumId": 1,
    "id": 1,
    "title": "accusamus beatae ad facilis cum similique qui sunt",
    "url": "",
    "thumbnailUrl": ""
    "albumId": 1,
    "id": 2,
    "title": "reprehenderit est deserunt velit ipsam",
    "url": "",
    "thumbnailUrl": ""

1) Create an object that represents a single photo:

struct Photo {
    let albumId: Int
    let id: Int
    let title: String
    let url: String
    let thumbnailUrl: String

2) Create a parser that will be responsible of parsing the response:

struct GetPhotosParser: GenericResponseParser {

    typealias GenericReponseEntity = [Photo]

    func parse(json: Json?) -> [Photo]? {

        guard  let posts = json as? [[String : Any]] else {
            return nil

        return posts.flatMap { return parsePhoto($0)}

   private func parsePhoto(_ node: [String: Any]) -> Photo? {

        guard let albumId = node["albumId"] as? Int,
            let id = node["id"] as? Int,
            let title = node["title"] as? String,
            let url = node["url"] as? String,
            let thumbnailUrl = node["thumbnailUrl"] as? String
            else {

            return nil

        return Photo(albumId: albumId, id: id, title: title, url: url, thumbnailUrl: thumbnailUrl)

3) Make the call:

let url = URL(string: "")!
let request = JsonRequest<GetPhotosParser>()

request.get(url: url, success: { photos in    
    for photo in photos {
}) { (error) in     
Same way you can make post, get, put or delete requests. You can also pass custom headers to the call.


APNetworking is released under an MIT License. See LICENSE for details.

Latest podspec

    "name": "APNetworking",
    "version": "1.0.0",
    "summary": "A convenient way to make Rest API calls.",
    "description": "A convenient way to make Rest API calls and parse data from JSON responses.",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": "Aleksandrs Proskurins",
    "platforms": {
        "ios": "9.0"
    "source": {
        "git": "",
        "tag": "1.0.0"
    "source_files": "APNetworking/*.swift",
    "pushed_with_swift_version": "3.0"

Pin It on Pinterest

Share This