Quickstart
Get up and running with Hydra. By the end of this guide, you’ll have a project created and products displaying on a page.
1. Create a project
Sign up at hydrajs.dev and create your first project. You’ll receive:
- A secret key (
sk_live_...) for server-side requests (full CRUD, checkout, orders, webhooks) - A publishable key (
pk_live_...) for client-side requests (read-only, cart, checkout)
Both keys also have test mode variants (sk_test_..., pk_test_...) that operate on isolated test data.
2. Install the SDK
npm install @gethydra/sdk
Initialize the client with your API key:
import { Hydra } from '@gethydra/sdk';
const hydra = new Hydra({ apiKey: 'sk_live_...' });
See the TypeScript SDK guide for full configuration options.
3. Fetch products
const { data: products } = await hydra.products.list({
limit: 10,
expand: ['variants', 'images'],
});
for (const product of products) {
console.log(product.title, product.variants[0].price);
}
Or with plain fetch:
const res = await fetch('https://api.hydrajs.dev/v1/products?limit=10', {
headers: {
Authorization: 'Bearer pk_live_your_publishable_key',
},
});
const { data: products } = await res.json();
4. Create a cart and add items
const { data: cart } = await hydra.cart.create();
await hydra.cart.addItem(cart.id, {
variant_id: 'var_abc123',
quantity: 1,
});
Or with plain fetch:
const cartRes = await fetch('https://api.hydrajs.dev/v1/cart', {
method: 'POST',
headers: {
Authorization: 'Bearer pk_live_your_publishable_key',
},
});
const { data: cart } = await cartRes.json();
await fetch(`https://api.hydrajs.dev/v1/cart/${cart.id}/items`, {
method: 'POST',
headers: {
Authorization: 'Bearer pk_live_your_publishable_key',
'Content-Type': 'application/json',
},
body: JSON.stringify({
variant_id: 'var_abc123',
quantity: 1,
}),
});
Next steps
- Read the TypeScript SDK guide for pagination, error handling, and webhook verification
- Learn about Authentication and key permissions
- Explore the API Reference for all available endpoints