To best utilize the Import API, we recommend some best practices while implementing the Import API.
Effective use of Import Containers
Organize Import Containers
- When importing full data sets, creating a new dedicated Import Container for the task can help in distinguishing imports performed on different occasions.
- When performing routine data imports, reusing a dedicated Import Container may be better.
- When importing data from multiple sources, using an Import Container for each source can help in organizing and monitoring progress.
Use Case | Possible Import Container organization |
---|---|
Import Product and Category | Create separate containers for Product and Category |
Import Price changes daily at 5 PM | Create a reusable container. If there are more than 200 000 imports per day, this may be broken down by some other business logic or temporary container for excess counts. |
Import Product changes from multiple sources | Create one container per source for Product imports. |
Optimize performance
Day | Import Operation total count | Import Containers (Import Operation count) |
---|---|---|
Day 1 | 100 000 | container-a (100 000) |
Day 2 | 500 000 | container-a (100 000), container-b (200 000), container-c (200 000) |
Day 3 | 400 000 | container-a (0), container-b (200 000), container-c (200 000) |
Day 4 | 200 000 | container-a (200 000), container-b (0), container-c (0) |
On Day 3, container-a will be empty as all the Import Operations have reached 48 hours. container-a is now ready to be reused. Similarly container-b and container-c can be reused from Day 4.
Limits
Clean up data from Import Containers and remove unused Import Containers
Send Import Requests to Import Containers
Choose the right Product import endpoint
The Import API has multiple endpoints for importing Product data. The following table summarizes what can be imported by each endpoint.
Endpoint | What can be imported |
---|---|
ProductDraft | Product data including Product Variants and Prices. |
Product | Product data without Product Variants and Prices. |
ProductVariant | Product Variant data without Prices. |
ProductVariantPatch | Product Variant Attribute data. |
EmbeddedPrice | Price data for a specific Product Variant. |
The following information explains common use cases for each endpoint.
ProductDraft
Common use cases:
- when you want to update a Product with 10+ new Product Variants, each with 20+ Embedded Prices.
- when you want to update a large number of Product Variants with new Attribute values and Prices.
Product
ProductVariant
ProductVariantPatch
EmbeddedPrice
Manage published state of Products
publish
which accepts a boolean value. The result of using this field varies based on whether you are importing data to create or update Products.When importing data to create a Product
true
, the Product is created and published immediately to the current projection. If false
, the Product is created but not published.When importing data to update an existing Product
The result of updating existing Products depends on if you are including changes in your import request, and if the Product currently has staged changes.
Value of publish | Does the import request have changes? | Does the Product have staged changes before importing? | Result |
---|---|---|---|
true | No | Yes | The staged changes are applied to the current projection and the Product is published. |
true | No | No | If the Product is currently unpublished, it is published to the current projection. |
true | Yes | N/A | The changes are applied to both the current and staged projection.
|
false | No | N/A | The Product is unpublished. |
false | Yes | N/A | The changes are applied to the staged projection, the Product is unpublished, and hasStagedChanges becomes true . |
Monitor import progress
- Import Summary can be used to get an aggregated progress summary, which gives you the information if you have any errors,
unresolved
orcompleted
states. - Query Import Operations can be used with filters like states to query specific situations. For example, query to fetch all the errors to fix those, or to fetch the unresolved to resolve those.
- You can use debug mode to fetch the unresolved references if there is something in the
unresolved
states. This way, you know which references to resolve.
Subscribe to Import API Events BETA
Utilize 48 hours lifetime of Import Operations
For example, one of your teams is responsible for Product import but the business validation usually delays the Product import for 1-2 days, and another team that imports Prices is very fast in importing the data, the Import API keeps the Price data for up of 48 hours and waits for the Product to be imported.
Import large data sets
-
You can import as much data you need using the Import API, keeping in mind the best practices for rate limits and payload size per request. For more information on optimization, see optimize performance.
-
Check the API limits to ensure that your import requests do not exceed the resource limitations of your Project.
Rate limits
Currently, there are no rate limits. However, to ensure the best performance, we recommend that you send 300 API calls per second, per Project, to the Import API.
-
To ensure the best performance, send 300 API calls per second per Project to the Import API.
For example, if you send 300 Import Category requests per second, and each CategoryImportRequest contains 20 CategoryImport items, this means that 360 000 Categories can be sent to the Import API every minute.
Handle retries
rejected
status. In other cases, the Import API will handle the retry internally without you needing to do anything.What not to do
- Do not send duplicate import requests concurrently. Since the Import API imports data asynchronously, the order is not guaranteed. It may also lead to a concurrent modification error.
- In case of errors, do not query Import Operations or the Import Summary endpoint frequently without fixing the problems as it may slow down the import process. For assistance in debugging issues or errors, query the Import Operation and consult the
errors
field.
Avoid concurrency errors
product
field in the ProductVariantPatch minimizes concurrency errors during the import process.product
field on one ProductVariantPatch, you have to set it for every ProductVariantPatch in the same ProductVariantPatchRequest.
Otherwise, the API returns an InvalidField error.