Skip to main content

A Python client for the SurferCID API

Project description

SurferCID API Client

A Python client for interacting with the SurferCID API. This client provides easy access to SurferCID's services including purchasing accounts, checking orders, and managing balance.

Project Structure

surfercid_client/
├── models.py           # Data models and response types
├── surfercid_client.py # Main API client implementation
└── requirements.txt    # Project dependencies

Installation

  1. Clone this repository
  2. Install the required dependencies:
pip install -r requirements.txt

Usage

from surfercid import SurferCIDClient
from surfercid.models import LTokenAccount

# Initialize the client
client = SurferCIDClient(api_key="your_api_key_here")

# Get stock information for a product
stock_info = client.get_stock("Ltoken")
print("Stock Info: ",stock_info)

# Check account balance
balance = client.get_balance()
print("Balance: ",balance)

# Example of working with LToken accounts
ltoken_order = client.purchase(product_name="Ltoken", quantity=1)

for account in ltoken_order.accounts:
    if isinstance(account, LTokenAccount):
        # Refresh token and get new LTokenAccount
        refreshed = client.refresh_token(account)
        print(f"Original token: {account.token}")
        print(f"Refreshed token: {refreshed.token}")
        # RID|MAC|PLATFORM|TOKEN
        print(f"New formatted token: {refreshed.to_format()}") 

Available Methods

  • get_stock(product_name: str) -> Dict[str, Any]: Get stock information for a specific product
  • get_balance() -> float: Get current account balance
  • purchase(product_name: str, quantity: int) -> OrderResponse: Purchase products
  • get_order(order_id: int) -> OrderResponse: Get details of a specific order
  • get_orders(limit: Optional[int] = None) -> List[OrderResponse]: Get list of orders
  • refresh_token(token_data: Union[str, LTokenAccount]) -> LTokenAccount: Refresh an LToken. Returns a new LTokenAccount instance with the refreshed token. Accepts either a formatted token string or an LTokenAccount instance.

Data Models

Account Types

All account types inherit from the base Account class:

CIDAccount

@dataclass
class CIDAccount(Account):
    growid: str
    password: str
    mail: str
    mail_pass: str

MailAccount

@dataclass
class MailAccount(Account):
    mail: str
    password: str

UbiConnectAccount

@dataclass
class UbiConnectAccount(Account):
    email: str
    password: str
    number: str
    secret_code: str
    recovery_codes: List[str]

LTokenAccount

@dataclass
class LTokenAccount(Account):
    created_at: str
    mac: str
    name: str
    platform: str
    rid: str
    token: str

    def to_format(self) -> str:
        """Convert to RID|MAC|PLATFORM|TOKEN format"""
        return f"{self.rid}|{self.mac}|{self.platform}|{self.token}"

OrderResponse

@dataclass
class OrderResponse:
    accounts: List[Account]
    message: str
    success: bool
    cost: float
    order_id: int
    order_date: datetime

Error Handling

The client will raise appropriate HTTP exceptions if the API requests fail. Make sure to handle these exceptions in your code:

from requests.exceptions import RequestException

try:
    # Refresh a token
    refreshed = client.refresh_token(account)
except RequestException as e:
    print(f"API request failed: {e}")
except ValueError as e:
    print(f"Invalid token or unsuccessful response: {e}")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

surfercid_client-0.1.4.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

surfercid_client-0.1.4-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file surfercid_client-0.1.4.tar.gz.

File metadata

  • Download URL: surfercid_client-0.1.4.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for surfercid_client-0.1.4.tar.gz
Algorithm Hash digest
SHA256 492928dda639b941df66aaedd117d8eb7dc8a7a73f4ed697ba5672bdc81aa446
MD5 e6a1e39bf8e10ab9e78b944a5b6ad9e6
BLAKE2b-256 ea3a4f55e04d30e89f693995329d603bd087e9c800fea7de5ce16eb5b4f28500

See more details on using hashes here.

File details

Details for the file surfercid_client-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for surfercid_client-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c4651b2c10efaa0fcf4b639aadf9a67f7c21d2c915fc9af75634998665b58f09
MD5 2c23796add9b5abf176bfd624fb444c9
BLAKE2b-256 3eccce1ac868c93798c28986bf1069edaa1d9cdca7b906f69ed8b8db63213d45

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page