dustinlange / LaunchLibraryAPI

Swift package for consuming the Launch Library API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LaunchLibraryAPI

Build Status codecov Swift Package Manager Compatible

Swift package for consuming the Launch Library API (http://launchlibrary.net/docs/1.4.1/api.html)

What is Launch Library?

Launch Library is a free-of-charge REST API for accessing information regarding past and future rocket launches. The service is maintained by a team of volunteers who use first-party sources to validate information.

http://launchlibrary.net

Installation

Swift Package Manager

Add this as a dependency to your Packages.swift:

import PackageDescription

let package = Package(
    name: "MyPackage",
        dependencies: [
        // Other dependencies
        .Package(url: "https://github.com/dustinlange/LaunchLibraryAPI.git", majorVersion: 1)
    ]
)

Usage

import LaunchLibraryAPI

// ...

let params: [APIParameter: String] = [.mode: "verbose", .next: "30"]
let request = PaginatedRequest<Launch>(.launch, params)

request.fetch() { [weak self] result in
    guard let strongSelf = self else { return }
    
    switch result {
    case .success(let response):
        let launches = strongSelf.response?.results
        print(launches)
    case .failure(_):
        break
    }
}

About

Swift package for consuming the Launch Library API

License:MIT License


Languages

Language:Swift 100.0%