Swiftpack.co - NathanFallet/APIRequest as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by NathanFallet.
NathanFallet/APIRequest 1.3.5
A swift package/android library to interact with a REST API.
⭐️ 14
🕓 6 days ago
.package(url: "https://github.com/NathanFallet/APIRequest.git", from: "1.3.5")

APIRequest

License Issues Pull Requests Code Size CodeFactor Open Source Helpers

A swift package/android library to interact with a REST API.

Installation

iOS

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

Android

Add the following to your build.gradle file:

repositories {
    mavenCentral()
}

dependencies {
    implementation 'me.nathanfallet.apirequest:apirequest:1.0.4'
}

Usage

iOS

// 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.

Android

// When your app starts, set the default configuration
APIConfiguration.current = APIConfiguration("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
APIRequest("GET", "/path/to/api")
    .with("custom", "parameter")
    .execute { result, status ->
        
    }

See the full documentation for a complete guide.

Examples

Full example project

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

Donate to the developer

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

GitHub

link
Stars: 14
Last commit: 4 days ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

APIRequest.swift v1.3.5
12 weeks ago

Fixing No such module 'FoundationNetworking'

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