Installation
Install the SDK using your preferred package manager.
npm install @brandup/sdk
# or
yarn add @brandup/sdk
# or
pnpm add @brandup/sdkInitialization
Create a client instance with your API key. Never expose your API key in client-side code.
import { BrandUpClient } from '@brandup/sdk'
const client = new BrandUpClient({
apiKey: process.env.BRANDUP_API_KEY,
environment: 'production' // or 'sandbox'
})Shops
Manage shops connected to your account.
// List all shops
const shops = await client.shops.list({
limit: 20,
page: 1
})
// Get a specific shop
const shop = await client.shops.get('shop_abc123')
// Create a new shop
const newShop = await client.shops.create({
name: 'My New Store',
domain: 'mystore.myshopify.com'
})
// Update a shop
await client.shops.update('shop_abc123', {
name: 'Updated Store Name'
})
// Delete a shop
await client.shops.delete('shop_abc123')Weather
Access weather data and get product recommendations.
// Get current weather for a location
const weather = await client.weather.getCurrent({
lat: 53.5511,
lon: 9.9937
})
// Get forecast
const forecast = await client.weather.getForecast({
lat: 53.5511,
lon: 9.9937,
days: 7
})
// Get recommendations based on weather
const recommendations = await client.weather.getRecommendations({
shopId: 'shop_abc123',
conditions: weather.conditions
})Error Handling
The SDK throws typed errors that you can catch and handle appropriately.
import { BrandUpError, RateLimitError } from '@brandup/sdk'
try {
const shop = await client.shops.get('shop_invalid')
} catch (error) {
if (error instanceof RateLimitError) {
console.log('Rate limited. Retry after:', error.retryAfter)
} else if (error instanceof BrandUpError) {
console.log('API Error:', error.code, error.message)
}
}