QuickStart
In this tutorial, you'll learn how to leverage Bagel's APIs to efficiently manage your assets, enabling streamlined data access and manipulation capabilities.
Prerequisites
To ensure that all the code in this tutorial runs properly, install the following:
Axios :
npm install axios
Node-Fetch:
npm install node-fetch
Form data:
npm install form-data
uuid:
npm install uuid
Buffer:
npm install buffer
bagelML:
npm install bagelML
Client
The Client
class is the main interface to the Bagel API. It requires a Settings
object to configure connectivity:
Step 1: Creating an Asset
Before we can begin managing our asset, we need to create a new asset within Bagel. This can be achieved using the POST /api/v1/asset
endpoint:
Step 2: Upload File to Asset
Once you have created an asset, you may need to upload a file to it. This is useful for associating data files with the asset for further processing. You can achieve this using the POST /api/v1/asset/{asset_id}/upload
endpoint.
In this snippet:
assetId: The ID of the asset to which the file will be uploaded.
filePath: The path to the file you want to upload.
apiKey: Your API key for authentication.
Step 3: Managing the Asset
Bagel's APIs provide functionality for managing assets, including retrieving asset information, updating asset properties, and deleting assets when they are no longer needed.
Retrieving Asset Information
To retrieve information about an asset, we can use the GET /api/v1/asset/{asset_id}/info
endpoint. This method retrieves details for a specific Asset using the generated "Asset ID". An API key is used to ensure security.
Step 4: Update Asset
You may need to update the properties of an existing asset to reflect changes in its status or metadata. This can be done using the PUT /api/v1/asset/{asset_id}
endpoint.
Step 5: Delete Asset
If an asset is no longer needed, you can delete it using the DELETE /api/v1/asset/{asset_id}
endpoint. This method ensures that the asset is removed from the marketplace and is no longer accessible.
By following these steps, you can effectively manage your assets using Bagel's API, enabling you to create, upload, retrieve, update, and delete assets with ease.
Need extra help or just want to connect with other developers? Join our community on Discord for additional support 👾
Last updated