Step 6: Make Your First API Call

With your API key integrated, you are ready to make your first request to the Videnly API.

This initial call will help you verify that your integration is working correctly and allow you to start generating videos.

Important Requirements Before Your First Call

  1. Project ID: Ensure you have the ID of the project you created. This ID is essential to specify which project configuration to use for generating videos.
  2. Credits: Confirm that your account has sufficient credits, as each video generation request will consume credits based on your plan.
  3. Optional Parameters: You can pass additional parameters to customize the video generation request, such as overwriteProjectSettings and overwriteCustomPrompt.

How to Make Your First API Call

Prepare Your Environment

You can use tools like Postman, cURL, or any programming language that supports HTTP requests.

Construct Your API Request

Make a POST request to the Videnly API endpoint, ensuring your API key is included in the Authorization header.

Example of a Simple API Call

Here’s an example of making your first API call to add a video generation request to the queue:

Example using cURL

curl -X POST https://api.videnly.com/v1/videos/queue/add \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"projectId": "YOUR_PROJECT_ID",
"overwriteProjectSettings": false,
"overwriteCustomPrompt": null
}'
  • Replace YOUR_API_KEY with the actual API key from the Developers page.
  • Replace YOUR_PROJECT_ID with the ID of the project you created.

Understanding the Request Body

  • projectId: The unique ID of the project you created earlier. This is required for specifying which project settings to use for video generation.
  • overwriteProjectSettings (optional): A flag that can be set to true or false to determine if custom project settings should override the saved ones.
  • overwriteCustomPrompt (optional | required if overwriteProjectSettings: true): If provided, this custom prompt will be used instead of the default project prompt.

Code Examples in Various Languages

Use the examples below to see how you can make an API call using different programming languages:

Understanding the Response

A successful API call will return a JSON response with details about the queued video generation request. Here is an example of what the response might look like:

{
   "status": "success",
   "message": "Video generation request added to queue successfully",
   "newQueueItem": {
      "queueId": "xxxxxxxxxxxxxxxxxxxxxxxx",
      "projectId": "YOUR_PROJECT_ID",
      "status": "pending",
      "generationProgress": 0,
      "renderProgress": 0,
      "videoUrl": null,
      "createdAt": "2024-11-07T14:23:45.213Z"
   }
}
  • status: Indicates if the request was successful.
  • newQueueItem: Contains details about the queued item, including queueId, status, and createdAt.

Verify Your API Call

  1. Check the Response: If your request is successful, you should see a response similar to the example above, confirming your video generation request has been added to the queue.
  2. Handle Errors: If the request fails, check the response for error messages. Common issues might include an invalid API key, missing projectId, or insufficient credits.

Tips for Your First API Call

  • Ensure You Have Credits: Each video generation request consumes credits. Confirm your account has enough credits.
  • Include the Project ID: Always specify the projectId to ensure the correct settings are applied to the video generation request.
  • Use Optional Parameters as Needed: Use overwriteProjectSettings and overwriteCustomPrompt to customize your requests.
  • Use Testing Tools: Tools like Postman or cURL can help you debug and confirm your API call works before integrating it.

Next Steps: Monitor the Queue

Now that you’ve made your first API call, you can start monitoring your queued requests by using the Queue Progress endpoint to check the status of your video generation requests.

Need Help?
If you encounter any issues or need further guidance, please visit our Support Center.