Skip to content
This repository was archived by the owner on Feb 17, 2026. It is now read-only.

Repository files navigation

SmsHubAPI Swift Library

SmsHubAPI is a Swift library that provides an easy-to-use interface for interacting with the SmsHub API. With this library, you can access various SmsHub services, such as getting your account balance, purchasing a phone number, setting and retrieving the status of an activation, and more.

Buy me a coffee

Features

  • Swift concurrency support with async/await
  • Simple, protocol-based API
  • Lightweight and modular

Requirements

  • iOS 15.0+
  • Swift 5.6+

Installation

Add the library to your project using Swift Package Manager:

  1. Open your project in Xcode.
  2. Go to File > Swift Packages > Add Package Dependency.
  3. Enter the repository URL https://github.com/DeveloperZelentsov/SMSHubAPI for the SmsHubAPI library and click Next.
  4. Choose the latest available version and click Next.
  5. Select the target where you want to use SmsHubAPI and click Finish.

Usage

First, import the SmsHubAPI library in your Swift file:

import SmsHubAPI

To start using the library, create an instance of SmsHubAPI with your API key:

letsmsHubAPI=SmsHubAPI(apiKey:"your_api_key_here")

Now, you can call the methods provided by the SmsHubAPI protocol:

Get Account Balance

do{letbalance=tryawait smsHubAPI.getBalance()print("Account balance: \(balance)")}catch{print("Error: \(error)")}

Purchase Phone Number

letgetNumber=GetNumberRequest(service:.nextdoor, country:.usa)do{let(id, phone)=tryawait smsHubAPI.purchasePhoneNumber(by: getNumber)print("Purchased phone number: \(phone) with ID: \(id)")}catch{print("Error: \(error)")}

Wait for Code

The waitForCode method can be used to conveniently retrieve the SMS verification code for an activation. This method will repeatedly check the activation status until the code is received or the specified number of attempts is exhausted.

do{letactivationId=12345letcode=tryawait smsHubAPI.waitForCode(id: activationId, attempts:20, setStatusAfterCompletion:true)print("Received code: \(code)")}catch{print("Error: \(error)")}

Set Activation Status

do{letresponse=tryawait smsHubAPI.setStatus(id: activationId, status:.smsSent)print("Status set response: \(response)")}catch{print("Error: \(error)")}

Get Activation Status

do{let(status, code)=tryawait smsHubAPI.getStatus(id: activationId)print("Activation status: \(status)")iflet code = code {print("Activation code: \(code)")}}catch{print("Error: \(error)")}

For more information on the available methods and their parameters, refer to the ISmsHubAPI protocol and the library's source code.

License

This project is released under the MIT License.

About

SmsHubAPI Swift Library

Topics

Resources

Stars

6 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages