Swiftpack.co - Package - Econa77/Pixela.swift


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 March 16, 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: 2


Used By

Total: 0


v1.1.0 - 2020-03-25 07:38:22

Breaking Changes

  • Changed UserAgent settings to APIConfiguration.


  • Support enterprise pixe.la. ( #11 )

v1.0.0 - 2020-03-16 09:47:09

Breaking Changes

  • None.


  • Carthage compatible. ( #7 )
  • Add graph appearance parameter. ( #8 )
  • Support change User-Agent header. ( #9 )

v0.0.1 - 2020-03-14 15:23:20

Initial beta release 🚀