thetaclient

Introduction

Welcome to the ThetaClient documentation! Here, you will find everything you need to know about using the ThetaClient framework for your iOS applications. ThetaClient is a powerful and flexible library that allows you to easily communicate with the Theta API.

Installation

To install ThetaClient, you can use CocoaPods, a popular dependency manager for iOS projects. Simply add the following line to your project’s Podfile:

pod 'ThetaClient'

Then, run pod install command in Terminal, and you’re all set!

Getting Started

Once you have installed ThetaClient, you can start using it in your project. Below, you will find a basic guide to get started with ThetaClient:

Configuration

To begin using ThetaClient, you will need an API key. You can obtain an API key by signing up for a Theta Developer account on the official Theta API website. Once you have your API key, you can configure ThetaClient in your app by using the following code:

“`swift
import ThetaClient

let apiKey = “YOUR_API_KEY”
ThetaClient.shared.configure(apiKey: apiKey)
“`

Making API Requests

ThetaClient provides a set of methods to interact with the Theta API. Below are a few examples to get you started:

Example 1: Get Live Streams

To retrieve a list of live streams, you can use the following code:

“`swift
ThetaClient.shared.getLiveStreams { (result) in
switch result {
case .success(let streams):
// Handle the list of live streams
for stream in streams {
print(stream)
}
case .failure(let error):
// Handle the error
print(error)
}
}
“`

Example 2: Get Stream Details

If you want to get more information about a specific stream, you can use the following code:

“`swift
let streamId = “YOUR_STREAM_ID”
ThetaClient.shared.getStreamDetail(streamId: streamId) { (result) in
switch result {
case .success(let streamDetail):
// Handle the stream detail
print(streamDetail)
case .failure(let error):
// Handle the error
print(error)
}
}
“`

Customizing Requests

ThetaClient allows you to customize your API requests by specifying additional parameters. For example, you can set the number of results to retrieve, filter by specific categories, or sort the results in a particular order. Below is an example of how you can customize your request:

“`swift
let request = ThetaLiveStreamsRequest()
request.limit = 10
request.category = .education
request.sort = .popular

ThetaClient.shared.getLiveStreams(request: request) { (result) in
switch result {
case .success(let streams):
// Handle the customized list of live streams
for stream in streams {
print(stream)
}
case .failure(let error):
// Handle the error
print(error)
}
}
“`

Conclusion

Congratulations! You have successfully installed and started using ThetaClient in your iOS application. By following the provided examples, you can easily make API requests and retrieve data from the Theta API. Feel free to explore the ThetaClient library further to integrate more advanced features into your app. Happy coding!