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.3.tar.gz (7.5 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.3-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: surfercid_client-0.1.3.tar.gz
  • Upload date:
  • Size: 7.5 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.3.tar.gz
Algorithm Hash digest
SHA256 78731e6b03788eae0d04d43685a24cbe5a20ca909804aae94d312eebdc04a34b
MD5 4300ef76e9390fcf88ec75c4dc010898
BLAKE2b-256 021566d1f970df04299d716b06ab71c5f026ef1b69e26059180186cf91d73025

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for surfercid_client-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8354bb4c516c368fc7ae92679b12d488aa7d2b1449878c390dfeafc6b6c0656c
MD5 8d480b058dbd00f627f656766b4d197e
BLAKE2b-256 5f014aafcee56b2d911860e06ab81eb87e6b204d34a9ae2c145a9260a3724079

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