Prom.ua api: Step-by-Step Guide to Connect with Odoo ERP

Prom.ua api: Step-by-Step Guide to Connect with Odoo ERP - prom.ua api

The prom.ua api lets you pull product catalogs, inventory levels, and order data directly into Odoo ERP, enabling real‑time sync across sales channels.

Key Takeaways

  • Authentication uses a simple token header; no OAuth flow.
  • Map Prom.ua fields to Odoo models: products → product.template, orders → sale.order.
  • Schedule the import script with Odoo’s built‑in cron to keep data fresh.
  • Common mistakes include ignoring pagination and mismatching currency formats.
photo-1774901128275-dcba96786383?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=M3wxMTA3NDE5fDB8MXxzZWFyY2h8Nnx8cHJvbS51YSUyMGFwaXxlbnwwfDB8fHwxNzk1MjA4MDAzfDA&ixlib=rb-4.1 Prom.ua api: Step-by-Step Guide to Connect with Odoo ERP

What Is the prom.ua api and Why Use It With Odoo?

Prom.ua provides a public RESTful API that returns JSON for product searches, category listings, and order details. Businesses that already run Odoo for accounting, inventory, and CRM can extend its capabilities by pulling this marketplace data instead of manually uploading CSV files.

How Do I Get an API Token from Prom.ua?

1. Register a developer account on the Prom.ua portal.

  1. Navigate to the API section and generate a token.
  2. Copy the token; it will be used in the HTTP Authorization header as Bearer YOUR_TOKEN.

Keep the token secret – treat it like a password. If the token is compromised, revoke it from the dashboard and generate a new one.

Setting Up Odoo to Call the prom.ua api

Odoo’s ir.http service can make external requests. Create a custom module (e.g., prom_ua_sync) and add a Python file that defines a helper function:

import requests

def fetch_prom_data(endpoint, params=None):
 url = f"https://api.prom.ua/v1/{endpoint}"
 headers = {"Authorization": f"Bearer {YOUR_TOKEN}"}
 response = requests.get(url, headers=headers, params=params)
 response.raise_for_status()
 return response.json()

Replace YOUR_TOKEN with the token you saved in Odoo’s configuration parameters.

Mapping Prom.ua Fields to Odoo Models

Prom.ua returns fields like id, title, price, stock_quantity, and category_path. Odoo’s product model expects default_code, name, list_price, qty_available, and a many‑to‑one link to product.category. Create a mapping dictionary inside your module:

FIELD_MAP = {
 "id": "default_code",
 "title": "name",
 "price": "list_price",
 "stock_quantity": "qty_available",
 "category_path": "categ_id",
}

When importing, iterate over the JSON objects, translate keys using FIELD_MAP, and write or update records with Odoo’s ORM methods.

Handling Pagination and Rate Limits

Prom.ua caps each request to 100 items. The response includes a next_page URL when more records exist. Loop until next_page is null:

def fetch_all_products():
 all_items = []
 endpoint = "products"
 params = {"limit": 100, "offset": 0}
 while True:
 data = fetch_prom_data(endpoint, params)
 all_items.extend(data["items"])
 if not data.get("next_page"):
 break
 params["offset"] += 100
 return all_items

Respect the API’s 60‑request‑per‑minute limit; add a short time.sleep(1) between calls if you approach the threshold.

Importing Products Into Odoo

Once you have a flat list of product dicts, run a batch upsert:

def sync_products():
 products = fetch_all_products()
 Product = env["product.template"]
 for p in products:
 vals = {
 FIELD_MAP["id"]: p["id"],
 FIELD_MAP["title"]: p["title"],
 FIELD_MAP["price"]: float(p["price"]),
 FIELD_MAP["stock_quantity"]: int(p["stock_quantity"]),
 }
 existing = Product.search([("default_code", "=", p["id")]])
 if existing:
 existing.write(vals)
 else:
 Product.create(vals)

Run sync_products from an Odoo scheduled action (cron) every few hours to keep inventory accurate.

Syncing Orders From Prom.ua to Odoo

Order data follows a similar pattern but requires creating a sale.order record and linking sale.order.line items. Important fields include order_id, buyer_name, total_amount, and an array of items each with product_id and quantity. Map these to Odoo’s order model, then confirm the order to trigger downstream accounting entries.

Common Pitfalls and How to Avoid Them

  • Ignoring currency conversion. Prom.ua prices are in the seller’s local currency. Store the currency code in a custom field and convert using Odoo’s res.currency rates before setting list_price.
  • Skipping pagination. Fetching only the first page leaves out most products. Always loop until next_page is empty.
  • Mismatched category hierarchy. Prom.ua returns a full path string (e.g., “Electronics > Phones”). Split the path, create missing Odoo categories, and assign the deepest level.
  • Overwriting manual edits. If you edit a product directly in Odoo, the sync script may overwrite those changes. Use a flag like is_prom_synced to decide whether to update.

Testing the Integration Before Going Live

Set up a separate Odoo database for testing. Run the import script with a limited limit=10 parameter to verify field mapping and category creation. Check that order totals match the JSON payload. Once you’re satisfied, switch the cron to the production database.

What to Do Next

1. Generate your prom.ua token and store it in Odoo’s configuration.

  1. Install the custom prom_ua_sync module and run a test import.
  2. Schedule the cron and monitor logs for any API errors.

For deeper security considerations, read the AI Meeting Assistant privacy guide on handling tokens safely.

photo-1572202485378-d934798763cc?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=M3wxMTA3NDE5fDB8MXxzZWFyY2h8OHx8QVBJJTIwcGFnaW5hdGlvbiUyMGV4YW1wbGUlMjBjb2RlfGVufDB8MHx8fDE3OTUyMDgwMDZ8MA&ixlib=rb-4.1 Prom.ua api: Step-by-Step Guide to Connect with Odoo ERP

Choosing the Right Sync Strategy for Your Catalog Size

The method you choose to move data between Prom.ua and Odoo depends heavily on your catalog volume. For small shops with fewer than 500 SKUs, a simple full refresh on a nightly cron job is often sufficient. It is easy to debug and requires minimal code. However, this approach becomes inefficient as you scale. If you have thousands of products, a full refresh wastes API calls and can trigger rate limits without completing the job.

For larger inventories, implement delta-based synchronization. Prom.ua provides timestamps for product updates. You should query only those items modified since the last successful sync. In Odoo, store a `prom_last_sync` timestamp field on your product template. During each run, pass this value to the Prom.ua API filter. This reduces data transfer and keeps the integration responsive.

Note that delta syncs require careful handling of deleted items. The API might not explicitly tell you a product was removed. You must cross-reference your local Odoo list against the active Prom.ua list to identify orphans and mark them as archived.

Handling Price and Stock Fluctuations

Prices and stock levels change more frequently than product descriptions. Do not bundle these high-frequency updates with your product master data sync. Create a separate, lighter-weight job for price and stock synchronization. This job should run every 15 to 30 minutes. It only updates the `list_price` and `website_sale_stock` fields in Odoo. Keeping these tasks separate prevents a single slow product description update from delaying critical stock corrections that affect customer availability.

Managing Authentication and Token Security in Odoo

Security is a common oversight in custom integrations. Never hard-code your Prom.ua API token in your Python code or store it in plain text within the Odoo database. Use Odoo’s `ir.config_parameter` to store sensitive credentials. This module encrypts the value and allows you to retrieve it securely at runtime.

When you create your integration module, define a function that fetches the token from this parameter. This ensures that if you change your API key, you only need to update one place in Odoo settings, not redeploy code.

# Example: Securely retrieving the API token
from odoo import models

class PromIntegration(models.AbstractModel):
_name = ‘abstract.prom.integration’

def _get_prom_token(self):
return self.env[‘ir.config_parameter’].sudo().get_param(‘prom.api_token’)

Restrict access to the configuration page. Only users with the ‘Technical’ or ‘Admin’ group should be able to view or edit the API token. If you use Odoo.sh or a cloud hosting provider, ensure your server logs do not accidentally print the token during debugging.

A single exposed token in a log file can allow unauthorized access to your shop data. Rotate your tokens periodically, even if you have not changed the integration logic. This is a standard practice to mitigate the risk of leaked credentials.

Debugging Failed API Calls and Error Logs

When an integration fails, you need to know exactly why. Do not rely on generic error messages like “Request Failed.” Log the specific HTTP status code returned by Prom.ua. If you receive a 400 error, it usually means your payload format is incorrect. If you get a 401, your token is invalid or expired.

A 429 means you have hit the rate limit. Capture these codes in your Odoo logger. Use the `self.env.cr` to log detailed information, including the request URL and a sanitized version of the payload (never log the full token).

Create a custom view in Odoo that displays recent sync errors. This gives your support team visibility into issues without checking server logs. Include fields for the timestamp, error type, and the specific product ID or order number that failed.

This allows you to retry only the failed records instead of running the entire sync again. For example, if one product image fails to upload, you should not re-import 500 other products. Isolate the failure, fix the specific issue (such as a broken image URL), and retry just that item.

Setting Up Automated Alerts

Proactive monitoring saves hours of troubleshooting. Configure Odoo to send an email alert if a sync job fails three times in a row. You can use the `mail.thread` model to post a message on a dedicated “Integration Health” record. When the error count exceeds your threshold, trigger a notification to your IT team.

This ensures that minor issues, like a temporary network glitch, are caught before they result in significant data drift between your e-commerce platform and your ERP. Do not wait for a customer to report a missing order; find the problem before it affects revenue.

Related articles

You can find more guides on this topic and related ones at novabiztech.com.

Frequently Asked Questions

Do I need a paid Prom.ua account to use the API?

No. The public API is available to any registered developer, though rate limits apply.

Can I sync inventory in both directions?

The basic integration described here pulls data from Prom.ua into Odoo. Bidirectional sync requires additional endpoints for updating stock on Prom.ua, which are not covered by the public API.

What if the API schema changes?

Prom.ua publishes versioned Swagger documentation. When a new version is released, update your endpoint URLs and adjust field mappings accordingly.

Further reading

Arslan is a digital marketing writer and tech blogger who covers marketing strategy, business tools, and startup culture at NovaBizTech. He writes practical guides for beginners who want real advice without the fluff.