
Security News
Node.js Drops Bug Bounty Rewards After Funding Dries Up
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.
@embed-ai/sdk
Advanced tools
The core TypeScript package for embed APIs, featuring an Effect-based HTTP client with robust error handling and configurable retry logic for mbd.xyz API.
bun install @embed-ai/sdk effect
Note:
effectis a peer dependency and must be installed alongside@embed-ai/sdk
import { getClient } from "@embed-ai/sdk"
const client = getClient(process.env.API_KEY_EMBED)
const feed = await client.feed.byUserId("16085")
console.log("✅ Success we got:", feed.length, "items")
The @embed-ai/sdk package provides comprehensive error handling with typed errors and automatic retries. Here's everything you need to know.
For simple applications, basic try/catch is sufficient:
import { getClient } from "@embed-ai/sdk"
const client = getClient(process.env.API_KEY_EMBED)
try {
const feed = await client.feed.byUserId("16085")
return feed
} catch (error) {
console.error("API request failed:", error)
throw error // Re-throw or handle as needed
}
The package exports four specific error types for structured error handling:
import {
HttpRequestError, // HTTP response errors (4xx, 5xx)
NetworkError, // Network connection issues
TimeoutError, // Request timeout errors
ParseError // JSON parsing errors
} from "@embed-ai/sdk"
Each error type contains rich information to help you understand and handle the issue:
// HttpRequestError - HTTP response errors
{
status: 401, // HTTP status code
statusText: "Unauthorized", // Status text
url: "https://api.mbd.xyz/...", // Request URL
body: "Invalid API key" // Response body (if available)
}
// NetworkError - Connection issues
{
message: "Failed to fetch", // Error description
cause: Error // Original error
}
// TimeoutError - Request timeouts
{
message: "Request timed out", // Error description
timeoutMs: 30000 // Timeout duration
}
// ParseError - JSON parsing issues
{
message: "Failed to parse JSON", // Error description
cause: SyntaxError // Original parsing error
}
import { getClient, HttpRequestError, NetworkError, TimeoutError } from "@embed-ai/sdk"
const client = getClient(process.env.API_KEY_EMBED)
try {
const feed = await client.feed.byUserId("16085")
console.log("✅ Success:", feed.length, "items")
} catch (error) {
console.error("❌ Error:", error)
// Handle specific error types
if (error instanceof HttpRequestError) {
console.error(`HTTP ${error.status}: ${error.statusText}`)
} else if (error instanceof NetworkError) {
console.error("Network connection failed")
} else if (error instanceof TimeoutError) {
console.error(`Request timed out after ${error.timeoutMs}ms`)
}
}
For production applications, use typed error handling for better control:
import {
getClient,
HttpRequestError,
NetworkError,
TimeoutError,
ParseError
} from "@embed-ai/sdk"
const client = getClient(process.env.API_KEY_EMBED)
async function getFeedWithErrorHandling(userId: string) {
try {
return await client.feed.byUserId(userId)
} catch (error) {
if (error instanceof HttpRequestError) {
switch (error.status) {
case 401:
throw new Error("Invalid API key - please check your credentials")
case 403:
throw new Error("Access denied - check your API permissions")
case 404:
throw new Error("User not found")
case 429:
throw new Error("Rate limit exceeded - please try again later")
case 500:
case 502:
case 503:
case 504:
throw new Error("Server error - please try again later")
default:
throw new Error(`HTTP error ${error.status}: ${error.statusText}`)
}
} else if (error instanceof NetworkError) {
throw new Error("Network connection failed - check your internet connection")
} else if (error instanceof TimeoutError) {
throw new Error(`Request timed out after ${error.timeoutMs}ms`)
} else if (error instanceof ParseError) {
throw new Error("Invalid response from server")
} else {
throw new Error("Unknown error occurred")
}
}
}
Configure retry behavior for your specific needs:
import { getClient } from "@embed-ai/sdk"
const client = getClient(process.env.API_KEY_EMBED, {
retry: {
maxRetries: 5, // Max retry attempts
initialDelay: 1000, // Initial delay in ms
exponentialBackoff: true, // Use exponential backoff
maxDelay: 15000, // Max delay between retries
retryableStatusCodes: [429, 500, 502, 503, 504], // HTTP codes to retry
timeoutMs: 60000 // Request timeout in ms
}
})
// Now all requests will use this retry configuration
const feed = await client.feed.byWalletAddress("0x123...")
When all retry attempts are exhausted, you receive the last error that occurred with full context:
try {
const feed = await client.feed.byUserId("16085")
} catch (error) {
// This error represents the final failure after all retries
if (error instanceof HttpRequestError) {
console.error(`Final HTTP error after retries: ${error.status}`)
console.error(`Request URL: ${error.url}`)
console.error(`Response body: ${error.body}`)
} else if (error instanceof NetworkError) {
console.error(`Final network error after retries: ${error.message}`)
}
}
Error Flow:
NetworkError with original failure details// ✅ Good - Specific error handling
try {
const feed = await client.feed.byUserId(userId)
} catch (error) {
if (error instanceof HttpRequestError) {
// Handle specific HTTP errors
} else if (error instanceof NetworkError) {
// Handle network issues
}
}
// ❌ Avoid - Generic error handling
try {
const feed = await client.feed.byUserId(userId)
} catch (error) {
console.error("Something went wrong:", error) // Too generic
}
function getUserFriendlyError(error: unknown): string {
if (error instanceof HttpRequestError) {
switch (error.status) {
case 401: return "Please check your API key"
case 429: return "Too many requests - please wait a moment"
case 500: return "Server is temporarily unavailable"
default: return "Something went wrong with the request"
}
} else if (error instanceof NetworkError) {
return "Please check your internet connection"
} else if (error instanceof TimeoutError) {
return "Request took too long - please try again"
}
return "An unexpected error occurred"
}
async function getFeedWithCache(userId: string) {
try {
return await client.feed.byUserId(userId)
} catch (error) {
if (error instanceof HttpRequestError && error.status === 404) {
// User not found - return empty feed
return []
} else if (error instanceof NetworkError || error instanceof TimeoutError) {
// Network issues - return cached data if available
return getCachedFeed(userId) || []
}
throw error // Re-throw other errors
}
}
import { getClient, HttpRequestError } from "@embed-ai/sdk"
const client = getClient(process.env.API_KEY_EMBED)
async function getFeedWithLogging(userId: string) {
try {
return await client.feed.byUserId(userId)
} catch (error) {
// Log error details for monitoring
if (error instanceof HttpRequestError) {
console.error("API Error:", {
status: error.status,
url: error.url,
userId,
timestamp: new Date().toISOString()
})
}
throw error
}
}
// Get personalized "For You" feed by user ID
await client.feed.byUserId(userId: string, options?: FeedOptions)
// Get personalized "For You" feed by wallet address
await client.feed.byWalletAddress(walletAddress: string, options?: FeedOptions)
// Feed management to create new feeds and manage these custom feeds e.g. as custom feed per user in your app, which can be built on top of base feeds
await client.feed.createConfig(options: CreateFeedOptions)
await client.feed.getConfig(configId: string)
await client.feed.listConfigs(visibility?: "private" | "template" | "public")
await client.feed.updateConfig(options: UpdateFeedOptions)
import { getClient } from "@embed-ai/sdk"
// Create client with factory function
const client = getClient(process.env.API_KEY_EMBED, {
retry: { maxRetries: 5 }
})
FAQs
The typescript sdk package for embed AI APIs.
We found that @embed-ai/sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.