Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
import { createAdminClient } from '@spree/admin-sdk'
const client = createAdminClient({
baseUrl: 'https://your-store.com',
secretKey: 'sk_xxx',
})
declare const token: string
const _exp = await client.exports.get('exp_xxx')
// The download endpoint only returns a URL once the export is `done`; narrow
// the type for the example so callers don't have to handle the null branch.
const exp = _exp as { download_url: string; filename: string }
// region:example
// Fetch with the Bearer token, then drive the browser download:
const res = await fetch(exp.download_url, {
headers: { Authorization: `Bearer ${token}` },
})
const blob = await res.blob()
const url = URL.createObjectURL(blob)
const a = Object.assign(document.createElement('a'), {
href: url,
download: exp.filename,
})
a.click()
URL.revokeObjectURL(url)
// endregion:example