To retrieve a project, you’ll use the projects.get() method of the BlendDuck client.
Copy
import BlendDuck from "@blendduck/node-sdk";// Initialize the BlendDuck clientconst client = new BlendDuck({ apiKey: process.env.BLENDDUCK_API_KEY});async function retrieveProject(projectId: string) { // Retrieve the project const project = await client.projects.get(projectId); console.log(`Retrieved project: ${project.title}`); console.log(`Number of clips: ${project.clips.length}`); // You can now work with the project object // For example, you can access its properties: console.log(`Project aspect ratio: ${project.ratio}`); console.log(`Project theme: `, project.theme);}// UsageretrieveProject("your-project-id-here");
To retrieve projects, you’ll use the projects.list() method
Copy
import BlendDuck from "@blendduck/node-sdk";// Initialize the BlendDuck clientconst client = new BlendDuck({ apiKey: process.env.BLENDDUCK_API_KEY});async function retrieveProjects() { const { projects } = await client.projects.list(); // equals // const { projects } = await client.projects.list({ page: 0, limit: 20 });}// UsageretrieveProjects();
If the project cannot be found or there’s an issue with the API request, the method will throw an error. It’s good practice to wrap the call in a try-catch block to handle any potential errors gracefully.