Official SDKs
Use our official client libraries to integrate with the Gridline API in your preferred language. SDKs handle authentication, serialization, retries, and error handling for you.
TS
JavaScript / TypeScript
The official Gridline SDK for Node.js, Deno, and browser environments. Full TypeScript support with generated types from our OpenAPI spec.
Installation
Terminal
npm install @gridline/sdk
# or with yarn
yarn add @gridline/sdk
# or with pnpm
pnpm add @gridline/sdkInitialization
index.tsTypeScript
import { Gridline } from '@gridline/sdk';
const client = new Gridline({
apiKey: process.env.GRIDLINE_API_KEY,
// Optional: override base URL for sandbox
baseUrl: 'https://sandbox-api.gridlinepos.com/v1',
// Optional: set request timeout (default: 30s)
timeout: 10000,
// Optional: set max retries (default: 2)
maxRetries: 3,
});Basic Usage
examples.tsTypeScript
// List orders with pagination
const orders = await client.orders.list({
limit: 20,
status: 'paid',
created_after: '2024-01-01T00:00:00Z',
});
// Create a new order
const order = await client.orders.create({
items: [
{ product_id: 'prod_abc123', quantity: 2 },
],
customer_id: 'cus_xyz789',
payment_method: 'card',
});
// Get customer loyalty balance
const balance = await client.loyalty.getBalance('cus_xyz789');
console.log(`Points: ${balance.points_balance}`);
console.log(`Tier: ${balance.tier.name}`);
// Earn points on an order
const earn = await client.loyalty.earn({
customer_id: 'cus_xyz789',
order_id: order.id,
amount: order.total,
currency: 'CAD',
});
// List products
const products = await client.products.list({ category: 'beverages' });
// Webhook signature verification
import { verifyWebhookSignature } from '@gridline/sdk/webhooks';
const isValid = verifyWebhookSignature(
requestBody,
headers['x-gridline-signature'],
headers['x-gridline-timestamp'],
process.env.WEBHOOK_SECRET
);Error Handling
error-handling.tsTypeScript
import { Gridline, GridlineError, RateLimitError } from '@gridline/sdk';
try {
const order = await client.orders.get('ord_nonexistent');
} catch (error) {
if (error instanceof RateLimitError) {
// Retry after the specified delay
console.log(`Rate limited. Retry after ${error.retryAfter}s`);
} else if (error instanceof GridlineError) {
console.error(`API Error [${error.status}]: ${error.message}`);
console.error(`Error code: ${error.code}`);
}
}Py
Python
The official Gridline SDK for Python 3.8+. Supports both synchronous and async usage with full type annotations.
Installation
Terminal
pip install gridline
# or with poetry
poetry add gridlineInitialization
main.pyPython
import gridline
import os
# Synchronous client
client = gridline.Client(
api_key=os.environ["GRIDLINE_API_KEY"],
# Optional: override base URL for sandbox
base_url="https://sandbox-api.gridlinepos.com/v1",
# Optional: set request timeout (default: 30s)
timeout=10.0,
)
# Async client
async_client = gridline.AsyncClient(
api_key=os.environ["GRIDLINE_API_KEY"],
)Basic Usage
examples.pyPython
# List orders
orders = client.orders.list(limit=20, status="paid")
for order in orders.data:
print(f"Order {order.id}: ${order.total / 100:.2f}")
# Create an order
order = client.orders.create(
items=[
{"product_id": "prod_abc123", "quantity": 2},
],
customer_id="cus_xyz789",
payment_method="card",
)
# Get loyalty balance
balance = client.loyalty.get_balance("cus_xyz789")
print(f"Points: {balance.points_balance}")
print(f"Tier: {balance.tier.name}")
# Earn points
earn = client.loyalty.earn(
customer_id="cus_xyz789",
order_id=order.id,
amount=order.total,
currency="CAD",
)
# Async usage
import asyncio
async def main():
orders = await async_client.orders.list(limit=10)
print(f"Found {orders.pagination.total} orders")
asyncio.run(main())Error Handling
error_handling.pyPython
from gridline.errors import GridlineError, RateLimitError, NotFoundError
try:
order = client.orders.get("ord_nonexistent")
except NotFoundError:
print("Order not found")
except RateLimitError as e:
print(f"Rate limited. Retry after {e.retry_after}s")
except GridlineError as e:
print(f"API Error [{e.status}]: {e.message}")
print(f"Error code: {e.code}")Feature Comparison
| Feature | JavaScript/TS | Python |
|---|---|---|
| Full type safety | Yes | Yes |
| Async support | Yes | Yes |
| Auto-retry | Yes | Yes |
| Webhook helpers | Yes | Yes |
| Pagination helpers | Yes | Yes |
| File uploads | Yes | Yes |
| Browser support | Yes | N/A |
Community SDKs
We welcome community-maintained SDKs in other languages. If you have built a Gridline SDK, open a PR on our GitHub repository to add it to this page. Community SDKs are not officially supported but may be useful for languages we do not yet cover.