Swiftpack.co - gionoa/Formula1API as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by gionoa.
gionoa/Formula1API v5.1.22
Swift Package for accessing Formula 1 data from the Ergast API
⭐️ 37
🕓 1 year ago
iOS macOS watchOS
.package(url: "https://github.com/gionoa/Formula1API.git", from: "v5.1.22")

Formula 1 API

This Swift library provides endpoint access to Formula 1 data provided by the Ergast API. By using this library, you won't have to build the interactive layer yourself, and can just start consuming the data.

Installing / Getting started

Formula 1 API supports Swift Package Manager. To use SwiftPM, you should use the most recent version of Xcode to add this project.

Click File -> Swift Packages -> Add Package Dependency, enter Formula1API repo's URL. Or you can login Xcode with your GitHub account and just type Formula1API to search.

After select the package, you can choose the dependency type (tagged version, branch or commit). As of now, since there's no 1.0.0 release yet, choose master branch.

Initial Configuration

No configuration needed!

Deploying / Publishing

You can't run this library in your own server since it interacts with the live network. If you're interested in running your own server to fetch F1 data, check out this repository.

Features

Formula1API provides functions that allow you to access endpoints for data.

Currently, you can fetch:

  • Circuits (all, specified season)
  • Seasons
  • Constructors (all, specified season)
  • Race Schedule (specified season)
  • Race Results (specified season)
  • Qualifying Results (specified season),
  • Pit Stops (specified season),
  • Laps(specified season)

More endpoints will be accessible as development progresses.

Usage

Usage of this library within your app or package is simple.

Access endpoints via the Formula1API object.

Return closure example:

Formula1API.constructors(for: .year(2022)) { result in
    switch result {
    case .success(let constructors):
        print(constructors)
    case .failure(let error):
        print(error)
    }
}

Async-await example:

do {
    let constructors = try await Formula1API.constructors(for: .year(2022))
} catch error {
    print(error)
}

Licensing

The code in this project is licensed under MIT license.

GitHub

link
Stars: 37
Last commit: 1 year ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

Barcelona
1 year ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics