Documentation
Everything you need to know about using our products
API Endpoint as Import Source
Import products directly from external REST APIs
The API Endpoint feature allows you to import product data directly from external REST APIs without downloading files. Perfect for integrating with WMS, ERP systems, suppliers, marketplaces, and any REST API with product data.
Overview
Key Features
How to Use
Step 1: Select Source
- Go to New Import
- In "Select Source" section, click the "API Endpoint" tile
- API configuration form will open
Step 2: Configure API Request
Basic Parameters
HTTP Method:
- GET - Retrieve data (default)
- POST - Send data with request body
- PUT - Update data
- PATCH - Partial update
API Endpoint URL:
https://api.example.com/products
Authentication
None
No authentication required. Used for public APIs.
Basic Auth
Username and password authentication.
Authorization: Basic base64(username:password)
Bearer Token
Token-based authentication (JWT, OAuth).
Authorization: Bearer your_api_token_here
API Key
API key in custom header.
X-API-Key: your_api_key_here
Custom Headers (Optional)
Format: JSON
{
"Content-Type": "application/json",
"Accept": "application/json",
"X-Custom-Header": "custom-value"
}
Request Body (for POST/PUT/PATCH)
Format: JSON
{
"limit": 100,
"page": 1,
"category": "electronics"
}
Step 3: Fetch Data
- Click "Fetch & Continue" button
- Plugin sends request to API
- Response is saved as file
- Data preview opens automatically
- Proceed to field mapping
Usage Examples
Example 1: Simple GET Request (No Auth)
Configuration:
- Method: GET
- URL:
https://api.example.com/products - Auth: None
Expected API Response:
[
{
"sku": "PROD-001",
"name": "Product 1",
"price": 29.99,
"stock": 100
},
{
"sku": "PROD-002",
"name": "Product 2",
"price": 39.99,
"stock": 50
}
]
Example 2: GET with Bearer Token
Configuration:
- Method: GET
- URL:
https://api.supplier.com/v1/products - Auth: Bearer Token
- Token:
eyJhbGciOiJIUzI1NiIs...
Custom Headers:
{
"Accept": "application/json"
}
Example 3: POST Request with Parameters
Configuration:
- Method: POST
- URL:
https://api.warehouse.com/export - Auth: API Key
- API Key:
sk_live_abc123xyz789
Request Body:
{
"format": "json",
"filters": {
"category": "electronics",
"in_stock": true
},
"limit": 500
}
Custom Headers:
{
"Content-Type": "application/json",
"Accept": "application/json"
}
Example 4: Basic Auth with XML Response
Configuration:
- Method: GET
- URL:
https://erp.company.com/api/products.xml - Auth: Basic Auth
- Username: api_user
- Password: ••••••••
Expected API Response:
<?xml version="1.0" encoding="UTF-8"?>
<products>
<product>
<sku>PROD-001</sku>
<name>Product 1</name>
<price>29.99</price>
</product>
</products>
API Requirements
Response Format
API must return data in one of the following formats:
JSON (recommended)
[
{"sku": "001", "name": "Product 1", "price": 29.99},
{"sku": "002", "name": "Product 2", "price": 39.99}
]
JSON with nesting
{
"data": {
"products": [
{"sku": "001", "name": "Product 1"}
]
}
}
XML
<products>
<product>
<sku>001</sku>
<name>Product 1</name>
</product>
</products>
CSV
SKU,Name,Price
001,Product 1,29.99
002,Product 2,39.99
HTTP Status Codes
| Status Code | Meaning |
|---|---|
| 200-299 | Successful response |
| 400-499 | Client error (invalid parameters) |
| 500-599 | Server error |
Recommended Headers
Content-Type: application/json
Content-Length: 12345
Technical Details
Backend Endpoint
URL: POST /wp-json/pifwc/v1/fetch-api
Parameters:
{
"url": "https://api.example.com/products",
"method": "GET",
"auth_type": "bearer",
"auth_key": "your_token",
"headers": "{\"Accept\":\"application/json\"}",
"body": "{\"limit\":100}"
}
Response:
{
"status": "success",
"data": {
"file_id": "abc123-xyz789",
"original_name": "api_response_1704801234.json",
"format": "json",
"message": "API data fetched successfully."
},
"errors": []
}
Processing Flow
- 1. URL Validation - Check URL correctness
- 2. Parse Headers - Decode JSON headers
- 3. Add Authentication - Form Authorization header
- 4. HTTP Request - wp_remote_request() with 60s timeout
- 5. Status Check - Validate HTTP status code (200-299)
- 6. Format Detection - By Content-Type or content
- 7. Save File - FileStorage::store_api_response()
- 8. Return file_id - For further processing
Auto-detect Format
By Content-Type header:
application/json→ JSONapplication/xmlortext/xml→ XMLtext/csv→ CSV
By content (if Content-Type not defined):
- Starts with { or [ → JSON
- Starts with < → XML
- Default → JSON
Security
- ✓ SSL verification enabled (sslverify: true)
- ✓ Timeout 60 seconds (protection from hanging)
- ✓ File size check (max 100MB)
- ✓ URL validation (only http/https)
- ✓ Sanitization of all parameters
- ✓ WordPress nonce verification
- ✓ Capability check (manage_woocommerce)
Troubleshooting
Error: "API URL is required"
Cause: API URL not specified
Solution: Fill in the "API Endpoint URL" field
Error: "Invalid API URL provided"
Cause: URL does not pass validation
Solution:
- Check URL format: https://api.example.com/products
- URL must start with http:// or https://
- Do not use spaces or special characters
Error: "API returned error status code: 401"
Cause: Invalid authentication
Solution:
- Verify authentication type
- Check token/key/password correctness
- Ensure token has not expired
Error: "API returned error status code: 404"
Cause: Invalid endpoint URL
Solution:
- Check URL correctness
- Ensure endpoint exists
- Review API documentation
Error: "API returned empty response"
Cause: API returned no data
Solution:
- Check request parameters
- Verify API has available data
- Review filters in Request Body
Error: "API request failed: SSL certificate problem"
Cause: SSL certificate issue
Solution:
- Ensure API uses valid SSL certificate
- Check that certificate has not expired
- For testing, temporarily disable SSL verification (not recommended for production)
Error: "Failed to connect to API"
Cause: Network error or timeout
Solution:
- Check API availability (ping, curl)
- Ensure WordPress server can connect to external APIs
- Check firewall settings
- Increase timeout (default 60 sec)
Best Practices
-
1.
Use pagination
If API returns large amounts of data, use pagination to avoid timeouts:
{ "page": 1, "limit": 100 } -
2.
Cache tokens
Do not request new token for each import. Save token and reuse it.
-
3.
Handle rate limits
Many APIs have request limits. Check API documentation.
-
4.
Use filters
Request only necessary data:
{ "filters": { "updated_since": "2026-01-01", "category": "electronics" } } -
5.
Test with small datasets
First request small amount of data to verify configuration:
{ "limit": 10 } -
6.
Log errors
When errors occur, save: request URL, parameters, API response, request time.
-
7.
Use HTTPS
Always use HTTPS for secure data transmission, especially with authentication.
Integration with Popular APIs
WooCommerce REST API
- Method: GET
- URL:
https://yourstore.com/wp-json/wc/v3/products - Auth: Basic Auth
- Username: consumer_key
- Password: consumer_secret
Shopify API
- Method: GET
- URL:
https://yourstore.myshopify.com/admin/api/2024-01/products.json - Auth: API Key
Headers:
{
"X-Shopify-Access-Token": "your_token"
}
Amazon MWS/SP-API
- Method: POST
- URL:
https://sellingpartnerapi-eu.amazon.com/... - Auth: Bearer Token
- Token: AWS Signature v4 token
eBay API
- Method: GET
- URL:
https://api.ebay.com/sell/inventory/v1/inventory_item - Auth: Bearer Token
- Token: OAuth 2.0 token
Ready to import from APIs?
Start importing products directly from your external systems!