Instantiate a new instance of Asset class with the specified asset id.
Optionaloptions: AssetOptionalInterfaceReturns a new Asset object with the asset id.
This method creates a new Asset controller instance that can be used to interact with an existing asset. It does not create a new asset in the database.
// Import the pre-initialized factory from your app's initialization file
import { Asset } from "utils/topiaInit.ts";
// Create an Asset instance with credentials
const assetInstance = await Asset.create(assetId, {
credentials: {
interactiveNonce,
interactivePublicKey,
assetId,
urlSlug,
visitorId
}
});
// Use the instance to interact with the asset
await assetInstance.fetchAssetById();
Standardized error handler for all SDK operations.
Standardized error object with properties: data, message, method, params, sdkMethod, stack, status, success, url
This method processes errors from API calls and formats them consistently across the SDK. It extracts relevant error information including:
All errors thrown by SDK methods flow through this handler to ensure consistent error format.
Returns the configured Axios instance for making API calls to Topia's Public API.
The configured Axios client instance with authentication headers.
Upload a new Asset to the Topia platform and return a new instance of Asset class.
Returns a new Asset object with the asset details.
This method both creates a new asset in the database and returns an Asset controller instance. A valid API key with appropriate permissions is required.
// Import the pre-initialized factory from your app's initialization file
import { Asset } from "utils/topiaInit.ts";
// Prepare the asset payload
const assetPayload = {
assetName: "My Decorative Asset",
bottomLayerURL: "https://example.com/bottom-layer.png",
creatorTags: { "decorations": true },
tagJson: "[{"label":"decorations","value":"decorations"}]",
isPublic: true,
topLayerURL: "https://example.com/top-layer.png"
};
// Upload the asset using your API key
const asset = await Asset.upload(assetPayload, apiKey);
// Access the new asset's properties
console.log(asset.id);
Factory for creating Asset instances. Use this factory to create or upload assets in the Topia platform.
Remarks
This factory should be instantiated once per application and reused across your codebase.
Keywords
asset, factory, create, upload, instantiate, topia
Example