Quickstart
Get up and running with OneFive. By the end of this guide you will have a project, products in your catalog, and a frontend fetching them.
1. Create a project
Sign up at admin.myhydrastore.com and create your first store. You will receive two types of API key:
- A secret key (
sk_...) for server-side requests with full read/write access - A publishable key (
pk_...) for client-side requests with read-only access
Keep your secret key private. Never expose it in client-side code or commit it to version control.
2. Install the SDK
bash
npm install @onefive/hydraInitialize the client with your API key:
typescript
import { createClient } from '@onefive/hydra'
// Server-side: use your secret key for full access
const hydra = createClient({ apiKey: 'sk_your_secret_key' })
// Client-side: use your publishable key for read-only access
const hydra = createClient({ apiKey: 'pk_your_key' })3. Add a product
Create a product with variants using the API. Only title is required. Prices are in the smallest currency unit (cents for USD).
typescript
const { data: product } = await hydra.products.create({
title: 'Classic Cotton T-Shirt',
handle: 'classic-cotton-t-shirt',
status: 'active',
variants: [
{
title: 'Black / M',
sku: 'CCT-BLK-M',
price: 2999,
inventory_quantity: 100,
options: { Color: 'Black', Size: 'M' }
},
{
title: 'White / M',
sku: 'CCT-WHT-M',
price: 2999,
inventory_quantity: 75,
options: { Color: 'White', Size: 'M' }
}
],
options: [
{ name: 'Color', values: ['Black', 'White'], position: 0 },
{ name: 'Size', values: ['M'], position: 1 }
]
})
console.log(product.id) // prod_abc123You can also add products through the admin panel without writing any code.
4. Fetch products
List products with the SDK. Responses use cursor-based pagination.
typescript
const { data: products, pagination } = await hydra.products.list({
limit: 10,
expand: ['variants', 'images']
})
for (const product of products) {
console.log(product.title, product.variants[0].price)
}
if (pagination.has_more) {
// Fetch the next page
const next = await hydra.products.list({
limit: 10,
cursor: pagination.cursor,
expand: ['variants', 'images']
})
}Or with plain fetch:
typescript
const res = await fetch('https://api.hydrajs.dev/v1/products?limit=10&expand=variants,images', {
headers: {
Authorization: 'Bearer pk_your_key'
}
})
const { data: products, pagination } = await res.json()5. Display on a page
Here is a minimal example using HTML and the SDK. This works with any framework.
typescript
import { createClient } from '@onefive/hydra'
const hydra = createClient({ apiKey: 'pk_your_key' })
const { data: products } = await hydra.products.list({
limit: 20,
status: 'active',
expand: ['variants', 'images']
})
for (const product of products) {
const variant = product.variants[0]
const image = product.images?.[0]
const price = (variant.price / 100).toFixed(2)
console.log(`${product.title} - $${price}`)
if (image) {
console.log(`Image: ${image.url}`)
}
}