Getting started overview
Integrating with the Duply API involves a sequence of steps designed to get developers operational with AI-powered image generation and manipulation features. This guide focuses on the foundational requirements: account creation, API key retrieval, and executing a preliminary API call. Duply provides a REST API for programmatic access, supporting various programming languages through code examples, although official SDKs are not listed. The API facilitates operations such as AI product photography and automated background removal.
Before making your first API call, you will need to register for a Duply account. This provides access to the Duply dashboard, where API keys are generated and managed. These keys authenticate your requests, ensuring secure access to Duply's services.
A typical integration workflow includes:
- Registering for a Duply account.
- Navigating to the dashboard to generate and copy API credentials.
- Constructing an API request, often using cURL for initial testing or an HTTP client library in a preferred programming language.
- Executing the request and processing the API response.
The following table provides a quick reference for the initial setup steps:
| Step | Action | Location / Tool |
|---|---|---|
| 1. Sign Up | Create a new Duply account. | Duply homepage |
| 2. Get API Key | Locate and copy your unique API key. | Duply dashboard > API Settings |
| 3. Prepare Request | Formulate an API request, typically a POST request to an image generation or background removal endpoint. | Text editor, IDE, or terminal |
| 4. Execute Call | Send the API request. | cURL, Postman, or programming language HTTP client |
| 5. Verify Response | Check the API's response for success or error messages. | Terminal output, application logs |
Create an account and get keys
To begin using Duply's API, the first step is to establish an account. Duply offers a free tier that includes 50 API credits per month, enabling initial development and testing without immediate financial commitment. Registration is typically straightforward, requiring basic information to set up your profile.
- Navigate to the Duply homepage: Open your web browser and go to www.duply.co.
- Sign up: Look for a 'Sign Up' or 'Get Started' button, usually located in the top right corner. Follow the prompts to create your account. This typically involves providing an email address and setting a password.
- Access the dashboard: After successful registration and potential email verification, log into your new Duply account. You will be redirected to your personal dashboard.
- Locate API settings: Within the dashboard, find a section labeled 'API Settings', 'Developers', or similar. The exact nomenclature may vary, but it's where your API keys are managed. Refer to the Duply API reference for specific navigation instructions if needed.
- Generate or retrieve API key: Your dashboard should display an existing API key, or provide an option to generate a new one. API keys are long, alphanumeric strings that act as unique identifiers and authenticators for your application. Treat your API key as sensitive information, similar to a password. It should not be hardcoded directly into client-side code or exposed publicly. Best practices for API key management include using environment variables or secure configuration files, as outlined by general API key security guidelines from Google Cloud.
- Copy your API key: Copy the generated API key to your clipboard. You will need this key to authenticate all your API requests to Duply.
Your first request
Once you have your API key, you can make your first authenticated request to the Duply API. This example will demonstrate how to perform a basic image generation or background removal request using cURL, a command-line tool for making HTTP requests. Duply's API is a RESTful service, meaning it uses standard HTTP methods (POST, GET, etc.) and typically communicates using JSON payloads.
For this example, let's assume we want to use the background removal feature. You will need an image URL to send to the API. Replace YOUR_API_KEY with the key you obtained from your Duply dashboard and YOUR_IMAGE_URL with the URL of the image you wish to process.
Example: Background Removal Request (cURL)
curl -X POST \
'https://api.duply.co/v1/remove-background' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-d '{
"image_url": "YOUR_IMAGE_URL",
"output_format": "png"
}'
Explanation of the cURL command:
-X POST: Specifies that this is an HTTP POST request.'https://api.duply.co/v1/remove-background': This is the API endpoint for background removal. Note that the specific endpoint might vary; always consult the Duply API reference documentation for the most current and accurate endpoints.-H 'Content-Type: application/json': Sets theContent-Typeheader, indicating that the request body is in JSON format.-H 'Authorization: Bearer YOUR_API_KEY': This is the authentication header. Duply uses a Bearer token scheme, where your API key is prefixed withBearer.-d '{ ... }': Specifies the request body, which is a JSON object containing the parameters for the background removal operation. In this case,image_urlis the URL of the input image, andoutput_formatspecifies the desired format for the processed image.
Upon successful execution, the API will return a JSON response containing a URL to the processed image or the image data directly, depending on the endpoint and parameters. An example successful response might look like this:
{
"status": "success",
"data": {
"processed_image_url": "https://cdn.duply.co/processed/image-id-123.png"
}
}
If there's an issue, the API will return an error response, typically with an HTTP status code indicating the problem (e.g., 400 for bad request, 401 for unauthorized) and a JSON body detailing the error.
Common next steps
After successfully making your first API call, you can explore more advanced features and integrate Duply into your applications. Here are some common next steps:
- Explore other API endpoints: Review the Duply API reference for other functionalities like AI product photography, image generation, or advanced editing options. Each endpoint will have specific parameters and expected responses.
- Integrate with a programming language: Instead of cURL, use an HTTP client library in your preferred programming language (e.g., Axios for Node.js, Requests for Python, Guzzle for PHP). This allows for more robust error handling, data manipulation, and integration into your application logic. Duply provides code examples for Node.js, Python, PHP, Ruby, and Go.
- Implement webhooks: For long-running processes or asynchronous operations, Duply might offer webhooks. Webhooks allow Duply to notify your application when a task is complete, rather than requiring your application to poll the API repeatedly. This is a common pattern for event-driven architectures, as described in Twilio's webhook guide.
- Manage API credits and usage: Monitor your API credit usage through the Duply dashboard. Understand the pricing structure and consider upgrading your plan if your usage exceeds the free tier or current subscription limits.
- Error handling and logging: Implement comprehensive error handling in your application to gracefully manage API failures, rate limits, or invalid responses. Log API requests and responses for debugging and auditing purposes.
- Optimize image storage: Decide how to store the processed images returned by Duply. This might involve integrating with cloud storage solutions like AWS S3 or Google Cloud Storage, or serving them directly from your application.
Troubleshooting the first call
Encountering issues during your first API call is common. Here's a troubleshooting guide for frequent problems:
- HTTP Status Code 401 Unauthorized:
- Issue: Your API key is incorrect, missing, or improperly formatted.
- Solution: Double-check that you've included the
Authorization: Bearer YOUR_API_KEYheader with the exact key copied from your Duply dashboard. Ensure there are no extra spaces or characters.
- HTTP Status Code 400 Bad Request:
- Issue: The request body is malformed, or required parameters are missing or invalid.
- Solution: Verify that your JSON payload is syntactically correct (e.g., all quotes are closed, commas are in place). Check the Duply API reference for the specific endpoint you're calling to ensure all mandatory parameters (e.g.,
image_urlfor background removal) are present and their values are in the correct format.
- HTTP Status Code 403 Forbidden:
- Issue: Your account might lack the necessary permissions for the requested operation, or your API credits have been exhausted.
- Solution: Check your Duply dashboard to confirm your account status and available API credits. If you're on a free tier, you might have hit your monthly limit.
- HTTP Status Code 404 Not Found:
- Issue: The API endpoint URL is incorrect.
- Solution: Compare the endpoint URL in your request with the one listed in the Duply API reference. Ensure there are no typos.
- Network Connection Issues:
- Issue: Your machine cannot reach the Duply API servers.
- Solution: Verify your internet connection. If you are behind a corporate firewall or proxy, ensure it is configured to allow outbound connections to
api.duply.co.
- CORS Errors (when calling from a browser):
- Issue: If you're attempting to call the Duply API directly from client-side browser JavaScript, you might encounter Cross-Origin Resource Sharing (CORS) errors.
- Solution: Most APIs are designed to be called from a server-side application to protect your API key. Avoid directly calling the Duply API from a browser. Instead, route your requests through a backend server that can securely store and use your API key.
- Image Processing Errors:
- Issue: The API returns an error related to the input image itself (e.g., invalid image format, inaccessible URL).
- Solution: Ensure
YOUR_IMAGE_URLis publicly accessible and points to a valid image file (JPEG, PNG, etc.). Test the image URL directly in a browser to confirm it loads correctly.