Swiftpack.co - Package - jdisho/TinyNetworking

TinyNetworking is a simple network abstraction layer written in Swift.

  • 🌯 Just a thin wrapper around NSURLSession.
  • ✌️ Supports CRUD methods.
  • 🚦 Compile-time checking for correct API endpoint accesses.
  • 🐍 (Optional) RxSwift extensions to the API.
  • ❤️ Inspired by Moya.
  • 🎉 No external dependencies.

🛠 Installation


To integrate TinyNetworking into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'TinyNetworking'
pod 'TinyNetworking/RxSwift' # for the RxSwift extentions

Then, run the following command:

$ pod install


Coming Soon

Swift Package Manager

Add the following as a dependency to your Package.swift:

.package(url: "https://github.com/jdisho/TinyNetworking.git", .upToNextMajor(from: "3.0.0"))


If you prefer not to use any of the dependency managers, you can integrate TinyNetworking into your project manually, by downloading the source code and placing the files on your project directory.

👨🏻‍💻 Usage

Set up an enum with all of your API resources like this example:

enum Unsplash {
  case me
  case photo(id: String)
  case collection(id: String)
  case likePhoto(id: String)

Extend enum and confom to ResourceType protocol.

extension Unsplash: ResourceType {
  var baseURL: URL {
    guard let url = URL(string: "https://api.unsplash.com") else {
      fatalError("FAILED: https://api.unsplash.com")
    return url
  var endpoint: Endpoint {
    switch self {
    case .me:
      return .get(path: "/me")
    case let .photo(id):
      return .get(path: "/photos/\(id)")
    case let .collection(id):
      return .get(path: "/collections/\(id)")
    case let .likePhoto(id):
      return .post(path: "/photos/\(id)/like")
  var task: Task {
    var params: [String: Any] = [:]
    return .requestWithParameters(params, encoding: URLEncoding())
  var headers: [String: String] {
    return ["Authorization": "Bearer xxx"]
  var cachePolicy: URLRequest.CachePolicy {
    return .useProtocolCachePolicy

⚙️ Making and handling a request

import TinyNetworking

let tinyNetworking = TinyNetworking<Unsplash>()

tinyNetworking.request(.photo("1234")) { response in
  switch response {
    case let .success(result):
      let photo = try? result.map(to: Photo.self)
    case let .error(error):

🔥 Reactive Extensions

Reactive extensions are cool. TinyNetworking provides reactive extensions for RxSwift and soon for ReactiveSwift.


return tinyNetworking.rx
     .request(resource: .photo(id: id))
     .map(to: Photo.self)

✨ Example

See Papr

🐨 Author

This tiny library is created with ❤️ by Joan Disho at QuickBird Studios

📃 License

TinyNetworking is released under an MIT license. See License.md for more information.


Stars: 69
Help us keep the lights on


Used By

Total: 0


3.0.0 - Aug 3, 2019

  1. Replace TinyNetworkingResult with Result.
  2. Rename TinyNetworkingError to Error.
  3. Support URLRequest.CachePolicy.

1.1.2 - Oct 2, 2018