Implementation:Mage ai Mage ai Front Client
| Knowledge Sources | |
|---|---|
| Domains | Data_Integration, Front, API |
| Last Updated | 2026-02-09 00:00 GMT |
Overview
Concrete HTTP client for making authenticated requests to the Front API, provided by the Mage Front source connector.
Description
The Client class manages all HTTP communication with the Front API at https://api2.frontapp.com. It authenticates via Bearer token from the config token field. The client implements sophisticated rate limiting by tracking X-Ratelimit-Remaining and X-Ratelimit-Reset response headers, sleeping when the rate limit is exhausted. It uses the backoff library with exponential backoff (max 10 tries, factor 2) for automatic retry on RateLimitException (HTTP 429 and 503). A separate MetricsRateLimitException is raised for HTTP 423 responses. The client maintains a persistent requests.Session for connection pooling. It provides convenience get and post methods.
Usage
Used internally by Front stream classes to fetch data from the Front API. Requires a token in the config dictionary.
Code Reference
Source Location
- Repository: mage-ai
- File:
mage_integrations/mage_integrations/sources/front/client.py - Lines: 1-77
Signature
class Client(object):
BASE_URL = 'https://api2.frontapp.com'
def __init__(self, config, logger):
Import
from mage_integrations.sources.front.client import Client
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| config | dict | Yes | Configuration dictionary containing token for Bearer authentication
|
| logger | Logger | Yes | Logger instance for diagnostic output |
Outputs
| Name | Type | Description |
|---|---|---|
| response | dict | Parsed JSON API response from the Front API |
Key Methods
| Method | Description |
|---|---|
request(method, path, url, **kwargs) |
Core request method with backoff retry on rate limits. Handles authorization headers and rate limit tracking. |
get(path, url, **kwargs) |
Convenience wrapper for GET requests. |
post(path, url, data, **kwargs) |
Convenience wrapper for POST requests with JSON body serialization. |
url(path) |
Constructs full URL from BASE_URL and path; passes through already-complete URLs. |
Usage Examples
from mage_integrations.sources.front.client import Client
config = {
'token': 'your_front_api_token',
}
client = Client(config, logger)
conversations = client.get(path='/conversations')