Swiftpack.co -  Econa77/Pixela.swift as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
Pixela API client for Swift
.package(url: "https://github.com/Econa77/Pixela.swift.git", from: "v1.2.0")


Actions Status Release version License: MIT Version Platform Carthage compatible SPM supported

Pixela API client for Swift.


  • Swift 5.0 or later
  • iOS 11.0 or later
  • macOS 10.12 or later

Getting started

Setting user configuration

To make a request other than the registration API, it is necessary to set configuration.

Pixela.shared.configuration = Configuration(username: "username", token: "secret-token")

User registration

Pixela.shared.createUser(token: "secret-token", username: "username", isAgreeTermsOfService: true, isNotMinor: true, thanksCode: "thanks-code") { result in
    switch result {
    case let .success(configuration):
        // Succeed new user registration
        Pixela.shared.configuration = configuration
    case let .failure(error)
        // Failed registration

Other APIs

This library supports all Pixela API as of May 6, 2020. Check here for a list of Pixela APIs. (https://docs.pixe.la/)

Pixela.shared.configuration = Configuration(username: "username", token: "secret-token")
Pixela.shared.getGraphs { result in
    switch result {
    case let .success(graphs):
    case let .failure(error):

Multi account handling

Instead of using a shared instance, can use a Pixela instance for multiple accounts by manage it yourself.

let user1 = Pixela(configuration: Configuration(username: "user1", token: "user1-secret-token"))

let user2 = Pixela(configuration: nil)
user2.configuration = Configuration(username: "user2", token: "user2-secret-token")

Enterprise support

Change APIConfiguration to connect to the Enterprise version of Pixela.

Pixela.shared.apiConfiguration = APIConfiguration(baseURL: URL(string: "https://custom.pixe.la")!)

let pixela = Pixela(configuration: Configuration(username: "user1", token: "user1-secret-token"))
pixela.apiConfiguration = APIConfiguration(baseURL: URL(string: "https://custom-domain-pixela.com")!)

Error cases

All errors in the library will return a PixelaError. PixelaError is the next 3 cases:

  • PixelaError.requestFailed: Error while creating URLRequest from Request. (some APIKit.SessionTaskError.requestError)
  • PixelaError.connectionFailed: Error of networking backend stack. (some APIKit.SessionTaskError.connectionError)
  • PixelaError.responseFailed(ResponseErrorReason): Error while handling response.


  1. Fork it ( https://github.com/Econa77/Pixela.swift/fork )
  2. Update git submodule (carthage checkout --no-build --use-submodules or git submodule init && git submodule update)
  3. Create your feature branch (git checkout -b my-new-feature)
  4. Commit your changes (git commit -am 'Add some feature')
  5. Push to the branch (git push origin my-new-feature)
  6. Create a new Pull Request


Stars: 4
Last commit: 3 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

1 year ago

Breaking Changes

  • Renamed ErrorMessage to Message. ( #13 )


  • Supported for stopwatch request in Pixe.la v1.18.0. ( #13 )

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