Swiftpack.co -  GroupeMINASTE/APIRequest.swift as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
GroupeMINASTE/APIRequest.swift
A swift package to interact with a REST API
.package(url: "https://github.com/GroupeMINASTE/APIRequest.swift.git", from: "1.3.2")

APIRequest

License Issues Pull Requests Code Size CodeFactor Open Source Helpers

A swift package to interact with a REST API

Installation

Add https://github.com/GroupeMINASTE/APIRequest.swift.git to your Swift Package configuration (or using the Xcode menu: File > Swift Packages > Add Package Dependency)

Usage

// Import the package
import APIRequest

// When your app starts, set the default configuration
APIConfiguration.current = APIConfiguration(host: "api.example.com")

// And then call your API
// This is an equivalent to get `https://api.example.com/path/to/api?custom=parameter` and parse the response from JSON to a dictionary [String: String]
APIRequest("GET", path: "/path/to/api").with(name: "custom", value: "parameter").execute([String: String].self) { data, status in
    // Check the data and status
    if let data = data, status == .ok {
        // Do what you want with your data
        
    } else {
        // Something went wrong, check the value of `status`
        
    }
}

See the full documentation for a complete guide.

Examples

Full example project

Check out the full example project made in a youtube tutorial.

Delta: Math helper

HiberLink

Donate to the developer

Feel free to make a donation to help the developer to make more great content! Donate now

GitHub

link
Stars: 7
Last commit: 2 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

APIRequest.swift v1.3.2
2 weeks ago

Fixing offline detection

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