Latest 0.2.1
Homepage https://github.com/salavert/vainglory-api
License MIT
Platforms ios 10.0
Dependencies Alamofire, ObjectMapper, Treasure, Zip
Authors

Vainglory API in swift

CocoaPods
Build Status
[CocoaPods]()

Installation

With CocoaPods

Open terminal and go to your project root folder, create a Podfile as follows

pod init
vi Podfile

Add pod to target, for example:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!

target 'MYPROJECT' do
    pod 'VaingloryAPI'
end

Now install it and open generated workspace

pod install
open MYPROJECT.xcworkspace

Usage

Request a Vainglory API key and pass it to VainggloryAPI client

import VaingloryAPI

let vaingloryAPI = VaingloryAPIClient(apiKey: "YOUR_VAINGLORY_API_KEY")

Getting players

Player by id

vaingloryAPI.getPlayer(withId: "b7ce178c-bd4b-11e4-8883-06d90c28bf1a", shard: .eu) { player, error in
    if let player = player {
        print("[VaingloryAPI] (player)")
    } else if let error = error {
        print("[VaingloryAPI] (error)")
    }
}

Player by name

vaingloryAPI.getPlayer(withName: "Salavert", shard: .eu) { player, error in
    if let player = player {
        print("[VaingloryAPI] (player)")
    } else if let error = error {
        print("[VaingloryAPI] (error)")
    }
}

Players by name

vaingloryAPI.getPlayers(withNames: ["Salavert", "Facil"], shard: .eu) { players, error in
    if let players = players {
        for player in players {
            print("[VaingloryAPI] (player)")
        }
    } else if let error = error {
        print("[VaingloryAPI] (error)")
    }
}

Getting matches

Match by Id

vaingloryAPI.getMatch(withId: "c481c96a-03fd-11e7-8f17-0266696addef", shard: .eu) { match, error in
    if let match = match {
        print("[VaingloryAPI] (match)")
        // match.rosters
        // match.rosters?.first?.participants
        // match.rosters?.first?.participants?.first?.player
    } else if let error = error {
        print(error)
    }
}

Match by player name

let filters = RouterFilters()
    .playerName("Salavert")
    .limit(5)

vaingloryAPI.getMatches(shard: .eu, filters: filters) { matches, error in
    if let matches = matches {
        for match in matches {
            print("[VaingloryAPI] (match)")
        }
    } else if let error = error {
        print("[VaingloryAPI] (error)")
    }
}

Samples

A sample contains a collection of random matches

Retrieving matches of latest available sample

vaingloryAPI.getSampleMatches(shard: .na) { matches, error in
    if let matches = matches {
        print(matches)
    } else if let error = error {
        print(error)
    }
}

If you prefer to do it manually and have feedback of download progress

let filters = RouterFilters().limit(1)

vaingloryAPI.getSamples(shard: .na, filters: filters) { samples, error in
    if let samples = samples {
        samples.first?.getMatches(
            completionHandler: { matches in
                if let matches = matches {
                    print("Matches count: (matches.count)")
                }
        },
            progressHandler: { progress in
                print("Download Progress: (progress.fractionCompleted)")
        })
    } else if let error = error {
        print(error)
    }
}

Telemetry

let url = "https://gl-prod-us-east-1.s3.amazonaws.com/assets/semc-vainglory/na/2017/03/17/00/43/b900c179-0aaa-11e7-bb12-0242ac110005-telemetry.json"
vaingloryAPI.getTelemetry(url: url) { telemetryList, error in
    print(telemetryList?.count)
}

Features:

  • Player by id or name.
  • Match by id.
  • List of matches based on filters.
  • Telemetry

Latest podspec

{
    "name": "VaingloryAPI",
    "version": "0.2.1",
    "summary": "Api client for Vainglory game",
    "description": "In 2017 Vainglory  game launched its first API in order to provide community a way to share stats of game.nThis API is a swift implementation to obtain its data.",
    "homepage": "https://github.com/salavert/vainglory-api",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Jose Salavert": "[email protected]"
    },
    "platforms": {
        "ios": "10.0"
    },
    "source": {
        "git": "https://github.com/salavert/vainglory-api.git",
        "tag": "0.2.1"
    },
    "source_files": "VaingloryAPI/**/*.{h,m,swift}",
    "pod_target_xcconfig": {
        "SWIFT_VERSION": "3"
    },
    "dependencies": {
        "Alamofire": [
            "~> 4.4"
        ],
        "ObjectMapper": [
            "~> 2.2"
        ],
        "Treasure": [],
        "Zip": [
            "~> 0.7"
        ]
    },
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This