class RemarkableConfig
A dataclass that stores configuration constants for interacting with the reMarkable cloud API, including API endpoints and local file paths for device tokens.
/tf/active/vicechatdev/e-ink-llm/cloudtest/auth.py
24 - 33
simple
Purpose
This configuration class centralizes all necessary URLs and file paths required to authenticate and communicate with the reMarkable cloud service. It provides EU Tectonic endpoints for API access and defines both primary and fallback locations for storing device authentication tokens. The class serves as a single source of truth for reMarkable API configuration, making it easy to modify endpoints or paths without changing code throughout an application.
Source Code
class RemarkableConfig:
"""Configuration for reMarkable cloud API"""
# EU Tectonic endpoints (working endpoints from network capture)
BASE_URL: str = "https://eu.tectonic.remarkable.com"
USER_TOKEN_URL: str = "https://webapp-prod.cloud.remarkable.engineering/token/json/2/user/new"
# Local paths - look in current directory first, then fallback to home
DEVICE_TOKEN_FILE: Path = Path(__file__).parent / "remarkable_device_token.txt"
FALLBACK_DEVICE_TOKEN_FILE: Path = Path.home() / ".remarkable" / "device_token.txt"
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
- | - |
Parameter Details
bases: This is a dataclass decorator parameter, not a constructor parameter. The dataclass decorator automatically generates __init__, __repr__, and other methods based on class attributes. No explicit parameters are needed for instantiation as all attributes have default values.
Return Value
Instantiating this class returns a RemarkableConfig object with all configuration attributes set to their default values. The class itself doesn't have methods that return values, but provides access to configuration constants through its attributes.
Class Interface
Methods
__init__() -> None
Purpose: Automatically generated constructor that initializes all attributes with their default values
Returns: None - initializes a new RemarkableConfig instance
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
BASE_URL |
str | The base URL for the reMarkable EU Tectonic API endpoint used for primary API operations | class |
USER_TOKEN_URL |
str | The URL endpoint for generating new user authentication tokens in the reMarkable cloud service | class |
DEVICE_TOKEN_FILE |
Path | Primary location for storing the device authentication token, relative to the module's directory | class |
FALLBACK_DEVICE_TOKEN_FILE |
Path | Fallback location for the device token in the user's home directory at ~/.remarkable/device_token.txt | class |
Dependencies
pathlibdataclasses
Required Imports
from pathlib import Path
from dataclasses import dataclass
Usage Example
from pathlib import Path
from dataclasses import dataclass
@dataclass
class RemarkableConfig:
BASE_URL: str = "https://eu.tectonic.remarkable.com"
USER_TOKEN_URL: str = "https://webapp-prod.cloud.remarkable.engineering/token/json/2/user/new"
DEVICE_TOKEN_FILE: Path = Path(__file__).parent / "remarkable_device_token.txt"
FALLBACK_DEVICE_TOKEN_FILE: Path = Path.home() / ".remarkable" / "device_token.txt"
# Instantiate the config
config = RemarkableConfig()
# Access configuration values
api_url = config.BASE_URL
token_url = config.USER_TOKEN_URL
token_file = config.DEVICE_TOKEN_FILE
# Check if device token file exists
if config.DEVICE_TOKEN_FILE.exists():
with open(config.DEVICE_TOKEN_FILE, 'r') as f:
device_token = f.read().strip()
elif config.FALLBACK_DEVICE_TOKEN_FILE.exists():
with open(config.FALLBACK_DEVICE_TOKEN_FILE, 'r') as f:
device_token = f.read().strip()
# Use in API requests
import requests
headers = {'Authorization': f'Bearer {device_token}'}
response = requests.get(config.BASE_URL, headers=headers)
Best Practices
- This is a dataclass with only class-level attributes, so all instances share the same default values
- The class is designed to be instantiated once and used as a configuration container throughout an application
- DEVICE_TOKEN_FILE uses Path(__file__).parent which resolves relative to the module's location, not the current working directory
- The fallback pattern (DEVICE_TOKEN_FILE -> FALLBACK_DEVICE_TOKEN_FILE) should be implemented in code that uses this config
- Consider making this a singleton or using class methods directly if you don't need instance-specific configuration
- All attributes are mutable by default in dataclasses; consider using frozen=True in the decorator if immutability is desired
- The EU Tectonic endpoints are hardcoded; if supporting multiple regions, consider parameterizing the region selection
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class RemarkableAuth 73.7% similar
-
class RemarkableCloudManager 69.4% similar
-
class RemarkableAPIClient 66.6% similar
-
class RemarkableRestClient 64.2% similar
-
class Client 63.0% similar