en:api_direct
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| en:api_direct [2026/02/18 14:05] – [Prerequisites] toomas | en:api_direct [2026/03/09 15:24] (current) – toomas | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Directo API Documentation ====== | + | {{page>et:api_direct}} |
| - | + | ||
| - | Welcome to the Directo API - a comprehensive RESTful API for accessing and managing your ERP data including items, orders, customers, invoices, stock levels, and more. | + | |
| - | + | ||
| - | ===== 🚀 Getting Started ===== | + | |
| - | + | ||
| - | ==== Prerequisites ==== | + | |
| - | + | ||
| - | * Active Directo ERP account | + | |
| - | * API key (obtain from your Directo administrator) | + | |
| - | * Basic understanding of REST APIs and HTTP methods | + | |
| - | * API Resources and Endpint can be found in Postman collection. Response field list managed in Directo ERP. Postman collection can be downloaded here: {{: | + | |
| - | ==== Quick Start Guide ==== | + | |
| - | + | ||
| - | - **Configure Authentication**: | + | |
| - | - **Set Variables**: | + | |
| - | - **Choose Format**: Set the Accept header to application/ | + | |
| - | - **Make Your First Request**: Try the "All items" request to retrieve your item catalog | + | |
| - | + | ||
| - | ==== Base URL & Versioning ==== | + | |
| - | + | ||
| - | **Base URL Structure: | + | |
| - | <code> | + | |
| - | {{baseUrl}}/ | + | |
| - | </ | + | |
| - | + | ||
| - | **Current Configuration: | + | |
| - | + | ||
| - | * **baseUrl**: | + | |
| - | * **version**: | + | |
| - | + | ||
| - | **Example Full URL:** | + | |
| - | < | + | |
| - | [https:// | + | |
| - | </ | + | |
| - | + | ||
| - | The API uses versioning to ensure backward compatibility. Always specify the version number in your requests. | + | |
| - | + | ||
| - | ===== 🔐 Authentication ===== | + | |
| - | + | ||
| - | The Directo API uses API Key authentication for secure access. | + | |
| - | + | ||
| - | ==== How to Authenticate ==== | + | |
| - | Include your API key in the request header: | + | |
| - | < | + | |
| - | X-Directo-Key: | + | |
| - | </ | + | |
| - | + | ||
| - | ==== Getting Your API Key ==== | + | |
| - | Contact your Directo system administrator to obtain an API key. Each key is associated with specific permissions and access levels. | + | |
| - | + | ||
| - | ==== Security Best Practices ==== | + | |
| - | + | ||
| - | * Never expose your API key in client-side code or public repositories | + | |
| - | * Store API keys securely using environment variables | + | |
| - | * Rotate keys periodically | + | |
| - | * Use different keys for development and production environments | + | |
| - | + | ||
| - | ===== 📋 Response Formats (JSON vs XML) ===== | + | |
| - | + | ||
| - | The API supports both JSON and XML response formats. Control the format using the Accept header. | + | |
| - | + | ||
| - | ==== JSON Format (Recommended) ==== | + | |
| - | < | + | |
| - | Accept: application/ | + | |
| - | </ | + | |
| - | + | ||
| - | **Example Request: | + | |
| - | <code bash> | + | |
| - | curl -X GET " | + | |
| - | + | ||
| - | -H " | + | |
| - | + | ||
| - | -H " | + | |
| - | </ | + | |
| - | + | ||
| - | ==== XML Format ==== | + | |
| - | < | + | |
| - | Accept: application/ | + | |
| - | </ | + | |
| - | + | ||
| - | **Example Request: | + | |
| - | <code bash> | + | |
| - | curl -X GET " | + | |
| - | + | ||
| - | -H " | + | |
| - | + | ||
| - | -H " | + | |
| - | </ | + | |
| - | + | ||
| - | ===== 🔍 Advanced Filtering (Key Feature) ===== | + | |
| - | + | ||
| - | ==== 🎯 ERP-Style Filtering - The Power of Directo API ==== | + | |
| - | + | ||
| - | ⭐ **CRITICAL FEATURE:** The Directo API supports the exact same powerful filtering capabilities as the Directo ERP system itself. | + | |
| - | + | ||
| - | This is one of the most powerful features of the Directo API. Filters can be applied like default filters inside the ERP system. All fields can be used for filters except calculated fields. | + | |
| - | + | ||
| - | ==== What This Means for Developers ==== | + | |
| - | + | ||
| - | * **Seamless Integration: | + | |
| - | * **No Learning Curve:** If you know how to filter in the ERP, you already know how to filter via the API | + | |
| - | * **Maximum Flexibility: | + | |
| - | * **Powerful Queries:** Combine multiple filters to create complex queries without custom endpoints | + | |
| - | + | ||
| - | ==== Understanding Filterable vs Calculated Fields ==== | + | |
| - | + | ||
| - | **✅ Filterable Fields (Stored in Database)** | + | |
| - | These are fields that are stored directly in the database and can be used for filtering: | + | |
| - | + | ||
| - | * **Item Fields:** code, name, class, status, country, unit, price, cost, supplier_code, | + | |
| - | * **Order/ | + | |
| - | * **Customer Fields:** code, name, country, city, address, phone, email, vat_number, payment_terms, | + | |
| - | * **Stock Fields:** item_code, warehouse, quantity, reserved_quantity, | + | |
| - | * **Line Item Fields:** row_item, row_quantity, | + | |
| - | * **Custom Data Fields:** Any custom fields you've defined in your ERP system (found in datafields array) | + | |
| - | + | ||
| - | **❌ Calculated Fields (Cannot Be Filtered)** | + | |
| - | These are fields computed on-the-fly and cannot be used for filtering: | + | |
| - | + | ||
| - | * **Computed Totals:** Fields like total_with_vat, | + | |
| - | * **Derived Values:** available_stock (when calculated as quantity - reserved), profit_margin (calculated from price and cost) | + | |
| - | * **Aggregations: | + | |
| - | * **Formatted Values:** Display-only fields like formatted_date, | + | |
| - | * **Virtual Fields:** Fields that exist only in the API response but not in the database | + | |
| - | + | ||
| - | ==== How to Identify Calculated Fields ==== | + | |
| - | + | ||
| - | * **Check the ERP Interface: | + | |
| - | * **Test the Filter:** Try filtering by the field via API - if it returns no results or an error, it's calculated | + | |
| - | * **Look for Patterns:** Fields with names like total_*, calculated_*, | + | |
| - | * **Consult Documentation: | + | |
| - | + | ||
| - | ==== Practical Examples: Filterable vs Calculated ==== | + | |
| - | + | ||
| - | **Example 1: Item Stock** | + | |
| - | < | + | |
| - | ✅ WORKS: GET / | + | |
| - | (quantity is stored in database) | + | |
| - | ❌ DOESN' | + | |
| - | (if available_stock = quantity - reserved, it's calculated) | + | |
| - | </ | + | |
| - | + | ||
| - | **Example 2: Order Totals** | + | |
| - | < | + | |
| - | ✅ WORKS: GET / | + | |
| - | (row_price is stored per line item) | + | |
| - | ❌ MIGHT NOT WORK: GET / | + | |
| - | (if order_total is sum of all line items, it's calculated) | + | |
| - | ✅ ALTERNATIVE: | + | |
| - | (then calculate totals in your application) | + | |
| - | </ | + | |
| - | + | ||
| - | **Example 3: Customer Data** | + | |
| - | < | + | |
| - | ✅ WORKS: GET / | + | |
| - | (both are stored fields) | + | |
| - | ❌ DOESN' | + | |
| - | (if full_address is concatenation of address+city+country) | + | |
| - | ✅ ALTERNATIVE: | + | |
| - | (filter by individual stored fields) | + | |
| - | </ | + | |
| - | + | ||
| - | ==== Basic Filtering ==== | + | |
| - | Filter by exact match using any stored field name: | + | |
| - | < | + | |
| - | GET {{baseUrl}}/ | + | |
| - | GET {{baseUrl}}/ | + | |
| - | GET {{baseUrl}}/ | + | |
| - | GET {{baseUrl}}/ | + | |
| - | GET {{baseUrl}}/ | + | |
| - | </ | + | |
| - | **Key Principle: | + | |
| - | + | ||
| - | ==== Comparison Operators ==== | + | |
| - | The API supports powerful comparison operators for advanced filtering: | + | |
| - | + | ||
| - | **Greater Than (>)** | + | |
| - | < | + | |
| - | < | + | |
| - | + | ||
| - | **Less Than (<)** | + | |
| - | < | + | |
| - | < | + | |
| - | + | ||
| - | **Not Equal (!)** | + | |
| - | < | + | |
| - | < | + | |
| - | + | ||
| - | **Greater Than or Equal (>=)** | + | |
| - | < | + | |
| - | < | + | |
| - | + | ||
| - | **Less Than or Equal (<=)** | + | |
| - | < | + | |
| - | < | + | |
| - | + | ||
| - | ==== Range Filtering ==== | + | |
| - | Combine operators to create ranges (AND logic): | + | |
| - | < | + | |
| - | GET {{baseUrl}}/ | + | |
| - | GET {{baseUrl}}/ | + | |
| - | </ | + | |
| - | + | ||
| - | ==== Multiple Values (OR Logic) ==== | + | |
| - | Use comma-separated lists to filter by multiple values: | + | |
| - | < | + | |
| - | GET {{baseUrl}}/ | + | |
| - | GET {{baseUrl}}/ | + | |
| - | GET {{baseUrl}}/ | + | |
| - | </ | + | |
| - | + | ||
| - | ==== Timestamp-Based Filtering (Synchronization) ==== | + | |
| - | Use the ts parameter to retrieve records modified after a specific timestamp (ideal for synchronization): | + | |
| - | < | + | |
| - | GET {{baseUrl}}/ | + | |
| - | GET {{baseUrl}}/ | + | |
| - | </ | + | |
| - | **Best Practice:** Store the timestamp of your last successful sync and use it in the next request to fetch only changed records. | + | |
| - | + | ||
| - | ==== Filtering by Line Item Fields ==== | + | |
| - | For resources with line items (orders, invoices), you can filter by line-level fields: | + | |
| - | < | + | |
| - | GET {{baseUrl}}/ | + | |
| - | GET {{baseUrl}}/ | + | |
| - | </ | + | |
| - | **Note:** When filtering by line item fields, the API returns the entire document (order/ | + | |
| - | + | ||
| - | ==== Filtering by Custom Data Fields ==== | + | |
| - | If you have custom fields defined in your ERP system (visible in the datafields array), you can filter by them: | + | |
| - | < | + | |
| - | GET {{baseUrl}}/ | + | |
| - | GET {{baseUrl}}/ | + | |
| - | </ | + | |
| - | **How to Find Custom Field Names:** Make a request without filters and examine the datafields array in the response. | + | |
| - | + | ||
| - | ==== Complex Filter Combinations ==== | + | |
| - | Combine multiple filters to create sophisticated queries: | + | |
| - | + | ||
| - | **Get new orders from the last week for a specific customer: | + | |
| - | < | + | |
| - | + | ||
| - | **Get items with low stock in specific warehouses, excluding closed items:** | + | |
| - | < | + | |
| - | + | ||
| - | ==== Common Filter Parameters by Resource ==== | + | |
| - | + | ||
| - | ^ Parameter ^ Description ^ Example ^ Applicable Resource ^ | + | |
| - | | ts | Timestamp for modified records (ISO 8601) | 2025-10-01T08: | + | |
| - | | date | Date filtering (supports operators) | > | + | |
| - | | number | Document number | 12345 or !001 | Orders, Invoices | | + | |
| - | | code | Item/ | + | |
| - | | name | Name search | Kalev | Items, Customers | | + | |
| - | | status | Status filter | UUS, CLOSED, NEW | Orders, Items | | + | |
| - | | country | Country code (ISO 2-letter) | EE, !EE | Items, Customers | | + | |
| - | | warehouse | Warehouse/ | + | |
| - | | quantity | Quantity filter (supports operators) | >100, <50 | Items, Stock Levels | | + | |
| - | | row_item | Item code in line items | 9810 or PROD-ABC | Orders, Invoices | | + | |
| - | | closed | Closed status | 1 (closed), 0 (open) | Customers, Orders | | + | |
| - | + | ||
| - | ==== Filter Best Practices ==== | + | |
| - | + | ||
| - | * **Start Simple:** Begin with single filters and add complexity as needed | + | |
| - | * **Use Timestamp Sync:** Always use ts parameter for incremental synchronization | + | |
| - | * **Combine Strategically: | + | |
| - | * **Test in ERP First:** If unsure whether a field is filterable, test it in the ERP interface first | + | |
| - | * **Handle Empty Results:** Empty results might mean filters are too restrictive or field is calculated | + | |
| - | * **URL Encode:** Always URL-encode filter values, especially dates and special characters | + | |
| - | + | ||
| - | ==== Troubleshooting Filters ==== | + | |
| - | **Problem: Filter returns no results** | + | |
| - | + | ||
| - | * Check: Is the field calculated? Try filtering by underlying stored fields | + | |
| - | * Check: Is the value correct? Verify exact field values in an unfiltered response | + | |
| - | * Check: Are operators correct? Use > not >= if that's what the ERP uses | + | |
| - | + | ||
| - | **Problem: Filter seems to be ignored** | + | |
| - | + | ||
| - | * Check: Is the field name spelled correctly? Field names are case-sensitive | + | |
| - | * Check: Is the value URL-encoded? | + | |
| - | * Check: Does the field exist in this resource? Not all fields are available in all resources | + | |
| - | + | ||
| - | **Problem: Unexpected results** | + | |
| - | + | ||
| - | * Check: Are you using OR logic (comma) when you meant AND (multiple parameters)? | + | |
| - | * Check: For line item filters, remember the entire document is returned if any line matches | + | |
| - | + | ||
| - | + | ||
| - | =====📦 API Resources & Endpoints ===== | + | |
| - | API Resources and Endpint can be found in Postman collection. | + | |
| - | Response field list managed in Directo ERP. | + | |
| - | + | ||
| - | < | + | |
| - | GET {{baseUrl}}/ | + | |
| - | GET {{baseUrl}}/ | + | |
| - | GET {{baseUrl}}/ | + | |
| - | GET {{baseUrl}}/ | + | |
| - | GET {{baseUrl}}/ | + | |
| - | GET {{baseUrl}}/ | + | |
| - | GET {{baseUrl}}/ | + | |
| - | GET {{baseUrl}}/ | + | |
| - | GET {{baseUrl}}/ | + | |
| - | GET {{baseUrl}}/ | + | |
| - | GET {{baseUrl}}/ | + | |
| - | GET {{baseUrl}}/ | + | |
| - | GET {{baseUrl}}/ | + | |
| - | GET {{baseUrl}}/ | + | |
| - | GET {{baseUrl}}/ | + | |
| - | GET {{baseUrl}}/ | + | |
| - | GET {{baseUrl}}/ | + | |
| - | GET {{baseUrl}}/ | + | |
| - | GET {{baseUrl}}/ | + | |
| - | GET {{baseUrl}}/ | + | |
| - | GET {{baseUrl}}/ | + | |
| - | GET {{baseUrl}}/ | + | |
| - | GET {{baseUrl}}/ | + | |
| - | GET {{baseUrl}}/ | + | |
| - | GET {{baseUrl}}/ | + | |
| - | GET {{baseUrl}}/ | + | |
| - | GET {{baseUrl}}/ | + | |
| - | + | ||
| - | + | ||
| - | </ | + | |
| - | + | ||
| - | Postman collection can be downloaded here: {{:et:toomas20260218-140231.json|Directo API postman collection}} | + | |
| - | + | ||
| - | + | ||
| - | ===== 📊 Response Structure ===== | + | |
| - | + | ||
| - | ==== Success Response (HTTP 200) ==== | + | |
| - | + | ||
| - | **JSON Format:** | + | |
| - | <code json> | + | |
| - | [ | + | |
| - | { | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | { | + | |
| - | " | + | |
| - | " | + | |
| - | }, | + | |
| - | { | + | |
| - | " | + | |
| - | " | + | |
| - | }, | + | |
| - | { | + | |
| - | " | + | |
| - | " | + | |
| - | }, | + | |
| - | { | + | |
| - | " | + | |
| - | " | + | |
| - | } | + | |
| - | ] | + | |
| - | }, | + | |
| - | { | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | } | + | |
| - | ] | + | |
| - | </ | + | |
| - | + | ||
| - | **XML Format:** | + | |
| - | <code xml> | + | |
| - | < | + | |
| - | <item code=" | + | |
| - | < | + | |
| - | <data code=" | + | |
| - | <data code=" | + | |
| - | <data code=" | + | |
| - | <data code=" | + | |
| - | </ | + | |
| - | </ | + | |
| - | <item code=" | + | |
| - | < | + | |
| - | </ | + | |
| - | </ | + | |
| - | </ | + | |
| - | + | ||
| - | ==== Response Characteristics ==== | + | |
| - | + | ||
| - | * **Array Format:** All endpoints return arrays of objects, even for single results | + | |
| - | * **Consistent Structure: | + | |
| - | * **Custom Fields:** Custom data fields appear in the datafields array | + | |
| - | * **Null Values:** Missing or null values may be omitted from responses | + | |
| - | * **Date Format:** All dates use ISO 8601 format (e.g., 2025-11-20T07: | + | |
| - | * **Numeric Values:** Numbers are returned as numbers in JSON, as strings in XML | + | |
| - | + | ||
| - | ===== ⚠️ Error Handling ===== | + | |
| - | + | ||
| - | ==== HTTP Status Codes ==== | + | |
| - | + | ||
| - | ^ Status Code ^ Meaning ^ Description ^ | + | |
| - | | 200 | OK | Request successful | | + | |
| - | | 400 | Bad Request | Invalid parameters or malformed request | | + | |
| - | | 400 | API not enababled | Resource not enabled for this API key | | + | |
| - | | 401 | Unauthorized | Missing or invalid API key | | + | |
| - | | 403 | Forbidden | API key lacks required permissions | | + | |
| - | | 404 | Not Found | Resource or endpoint not found | | + | |
| - | | 429 | Too Many Requests | Rate limit exceeded | | + | |
| - | | 500 | Internal Server Error | Server-side error | | + | |
| - | | 503 | Service Unavailable | API temporarily unavailable | | + | |
| - | + | ||
| - | ==== Error Response Format ==== | + | |
| - | <code json> | + | |
| - | { | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | } | + | |
| - | } | + | |
| - | </ | + | |
| - | + | ||
| - | ==== Common Error Scenarios ==== | + | |
| - | + | ||
| - | **401 Unauthorized: | + | |
| - | + | ||
| - | * Missing X-Directo-Key header | + | |
| - | * Invalid or expired API key | + | |
| - | * **Solution: | + | |
| - | + | ||
| - | **403 Forbidden: | + | |
| - | + | ||
| - | * API key lacks permissions for the requested resource | + | |
| - | * **Solution: | + | |
| - | + | ||
| - | **400 Bad Request: | + | |
| - | + | ||
| - | * Invalid filter syntax | + | |
| - | * Malformed date format (use ISO 8601: 2025-11-20T07: | + | |
| - | * Filtering by calculated field | + | |
| - | * **Solution: | + | |
| - | + | ||
| - | **404 Not Found:** | + | |
| - | + | ||
| - | * Incorrect endpoint URL | + | |
| - | * Invalid API version | + | |
| - | * **Solution: | + | |
| - | + | ||
| - | **429 Too Many Requests: | + | |
| - | + | ||
| - | * Rate limit exceeded | + | |
| - | * **Solution: | + | |
| - | + | ||
| - | **500 Internal Server Error:** | + | |
| - | + | ||
| - | * Server-side processing error | + | |
| - | * **Solution: | + | |
| - | + | ||
| - | ===== 🚦 Rate Limiting & Performance ===== | + | |
| - | + | ||
| - | ==== Rate Limits ==== | + | |
| - | While specific rate limits depend on your account tier, follow these guidelines: | + | |
| - | + | ||
| - | * **Recommended: | + | |
| - | * **Burst Limit:** Short bursts of higher traffic may be allowed | + | |
| - | * **Daily Limits:** May apply based on your subscription | + | |
| - | + | ||
| - | ==== Performance Best Practices ==== | + | |
| - | + | ||
| - | **1. Use Timestamp Filtering for Sync** | + | |
| - | Instead of fetching all records repeatedly, use the ts parameter: | + | |
| - | < | + | |
| - | + | ||
| - | * **Benefits: | + | |
| - | + | ||
| - | **2. Implement Pagination with Date Ranges** | + | |
| - | For large datasets, break requests into smaller chunks: | + | |
| - | < | + | |
| - | + | ||
| - | # Week 1 | + | |
| - | + | ||
| - | GET {{baseUrl}}/ | + | |
| - | + | ||
| - | # Week 2 | + | |
| - | + | ||
| - | GET {{baseUrl}}/ | + | |
| - | </ | + | |
| - | + | ||
| - | **3. Cache Static Data** | + | |
| - | Cache data that changes infrequently: | + | |
| - | + | ||
| - | * Item classes (cache for 24 hours) | + | |
| - | * Price formulas (cache for 1 hour) | + | |
| - | * Customer master data (cache for 6 hours) | + | |
| - | + | ||
| - | **4. Use Specific Filters** | + | |
| - | Apply filters to retrieve only the data you need: | + | |
| - | < | + | |
| - | + | ||
| - | # Instead of fetching all items and filtering locally | + | |
| - | + | ||
| - | GET {{baseUrl}}/ | + | |
| - | + | ||
| - | # Fetch only what you need | + | |
| - | + | ||
| - | GET {{baseUrl}}/ | + | |
| - | </ | + | |
| - | + | ||
| - | **5. Implement Exponential Backoff** | + | |
| - | For transient errors (429, 503), retry with increasing delays: | + | |
| - | + | ||
| - | * 1st retry: wait 1 second | + | |
| - | * 2nd retry: wait 2 seconds | + | |
| - | * 3rd retry: wait 4 seconds | + | |
| - | * 4th retry: wait 8 seconds | + | |
| - | + | ||
| - | **6. Batch Related Requests** | + | |
| - | Group related operations to minimize round trips: | + | |
| - | + | ||
| - | 1. Fetch orders: '' | + | |
| - | 2. For each order, fetch customer details (if needed) | + | |
| - | 3. Update local database in batch | + | |
| - | + | ||
| - | **7. Monitor API Usage** | + | |
| - | Track your API consumption: | + | |
| - | + | ||
| - | * Log request counts per endpoint | + | |
| - | * Monitor response times | + | |
| - | * Track error rates | + | |
| - | * Set up alerts for rate limit warnings | + | |
| - | + | ||
| - | ===== 🔄 Common Integration Patterns ===== | + | |
| - | + | ||
| - | ==== Pattern 1: Initial Data Sync (First-Time Setup) ==== | + | |
| - | **Objective: | + | |
| - | + | ||
| - | * **Step 1:** Fetch all items '' | + | |
| - | * **Step 2:** Fetch all customers '' | + | |
| - | * **Step 3:** Fetch all stock levels '' | + | |
| - | * **Step 4:** Fetch item classes '' | + | |
| - | * **Step 5:** Store current timestamp for future incremental syncs '' | + | |
| - | **Considerations: | + | |
| - | + | ||
| - | ==== Pattern 2: Incremental Sync (Ongoing Synchronization) ==== | + | |
| - | **Objective: | + | |
| - | + | ||
| - | * **Step 1:** Retrieve last sync timestamp from your database | + | |
| - | * **Step 2:** Fetch changed items '' | + | |
| - | * **Step 3:** Fetch changed customers '' | + | |
| - | * **Step 4:** Fetch changed stock levels '' | + | |
| - | * **Step 5:** Fetch deleted records '' | + | |
| - | * **Step 6:** Process changes (Update/ | + | |
| - | * **Step 7:** Update last sync timestamp | + | |
| - | + | ||
| - | ==== Pattern 3: Real-Time Order Monitoring ==== | + | |
| - | **Objective: | + | |
| - | + | ||
| - | * **Step 1:** Poll orders endpoint '' | + | |
| - | * **Step 2:** Process new orders (Validate, Check inventory, Update status) | + | |
| - | * **Step 3:** Update last check timestamp | + | |
| - | * **Step 4:** Wait for next interval (e.g., 5 minutes) | + | |
| - | + | ||
| - | ==== Pattern 4: Inventory Management & Availability Check ==== | + | |
| - | **Objective: | + | |
| - | + | ||
| - | * **Step 1:** Fetch current stock levels '' | + | |
| - | * **Step 2:** Fetch allocations (reserved stock) '' | + | |
| - | * **Step 3:** Calculate available quantity: '' | + | |
| - | * **Step 4:** Update your inventory system | + | |
| - | + | ||
| - | ==== Pattern 5: Customer Data Synchronization (CRM Integration) ==== | + | |
| - | **Objective: | + | |
| - | + | ||
| - | * **Step 1:** Fetch changed customers '' | + | |
| - | * **Step 2:** Sync to CRM (Create/ | + | |
| - | * **Step 3:** Fetch deleted customers '' | + | |
| - | * **Step 4:** Remove deleted customers from CRM | + | |
| - | + | ||
| - | ==== Pattern 6: Invoice Export to Accounting System ==== | + | |
| - | **Objective: | + | |
| - | + | ||
| - | * **Step 1:** Fetch new/updated invoices '' | + | |
| - | * **Step 2:** Map fields and create in accounting system | + | |
| - | * **Step 3:** Handle errors and mark as exported | + | |
| - | + | ||
| - | ==== Pattern 7: Price Synchronization to E-Commerce ==== | + | |
| - | **Objective: | + | |
| - | + | ||
| - | * **Step 1:** Fetch changed items with pricing '' | + | |
| - | * **Step 2:** Fetch price formulas '' | + | |
| - | * **Step 3:** Calculate final prices and update e-commerce platform | + | |
| - | + | ||
| - | ===== 🛠️ Troubleshooting Guide ===== | + | |
| - | + | ||
| - | ==== Issue: Empty Response / No Results ==== | + | |
| - | **Possible Causes:** Filters too restrictive, | + | |
| - | **Solutions: | + | |
| - | < | + | |
| - | + | ||
| - | # Remove filters one by one | + | |
| - | + | ||
| - | GET /items | + | |
| - | + | ||
| - | # Verify date format | + | |
| - | + | ||
| - | ✅ CORRECT: ? | + | |
| - | </ | + | |
| - | + | ||
| - | ==== Issue: Authentication Errors (401/403) ==== | + | |
| - | **Possible Causes:** Missing key, incorrect header name, expired key. | + | |
| - | **Solutions: | + | |
| - | < | + | |
| - | + | ||
| - | # Verify header name (case-sensitive) | + | |
| - | + | ||
| - | ✅ CORRECT: X-Directo-Key: | + | |
| - | </ | + | |
| - | + | ||
| - | ==== Issue: Rate Limit Errors (429) ==== | + | |
| - | **Solutions (Python): | + | |
| - | <code python> | + | |
| - | import time | + | |
| - | def make_request_with_retry(url, | + | |
| - | for attempt in range(max_retries): | + | |
| - | response = requests.get(url) | + | |
| - | if response.status_code == 200: | + | |
| - | return response | + | |
| - | elif response.status_code == 429: | + | |
| - | wait_time = 2 ** attempt | + | |
| - | time.sleep(wait_time) | + | |
| - | raise Exception(" | + | |
| - | </ | + | |
| - | + | ||
| - | ===== 📞 Support & Resources ===== | + | |
| - | + | ||
| - | **Technical Support: | + | |
| - | + | ||
| - | * Email: info@directo.ee | + | |
| - | * Contact your Directo account manager | + | |
| - | * Submit support ticket through Directo Chat | + | |
| - | + | ||
| - | ===== 📝 Changelog & Version History ===== | + | |
| - | + | ||
| - | **Version 1 (Current)** | + | |
| - | + | ||
| - | * Initial API release | + | |
| - | * Support for major resources: items, customers, orders, invoices, stock levels | + | |
| - | * JSON/XML support & ERP-style filtering | + | |
| - | + | ||
| - | ===== 🔒 Security & Compliance ===== | + | |
| - | + | ||
| - | ==== Data Security ==== | + | |
| - | + | ||
| - | * **Encryption**: | + | |
| - | * **Authentication**: | + | |
| - | * **Authorization**: | + | |
| - | * **Audit Logging**: All API requests are logged server-side | + | |
| - | + | ||
| - | ==== Compliance Considerations ==== | + | |
| - | * GDPR: Customer data includes personal information - handle according to GDPR requirements | + | |
| - | * Data Retention: Implement appropriate data retention policies | + | |
| - | * Access Control: Limit API key distribution to authorized personnel only | + | |
| - | * Monitoring: Monitor API usage for unusual patterns | + | |
| - | + | ||
| - | ==== Security Best Practices ==== | + | |
| - | * Protect API Keys: | + | |
| - | * Never commit keys to version control | + | |
| - | * Use environment variables or secure vaults | + | |
| - | * Rotate keys regularly (quarterly recommended) | + | |
| - | * Use different keys for dev/ | + | |
| - | * Implement Access Controls: | + | |
| - | * Limit API key permissions to minimum required | + | |
| - | * Use separate keys for different integrations | + | |
| - | * Revoke keys immediately when no longer needed | + | |
| - | * Monitor Usage: | + | |
| - | * Log all API requests in your application | + | |
| - | * Set up alerts for unusual activity | + | |
| - | * Review access logs regularly | + | |
| - | * Handle Data Responsibly: | + | |
| - | * Encrypt sensitive data at rest | + | |
| - | * Implement data retention policies | + | |
| - | * Comply with privacy regulations (GDPR, etc.) | + | |
| - | * Secure data transmission (HTTPS only) | + | |
| - | + | ||
| - | ===== 💡 Tips & Tricks ===== | + | |
| - | + | ||
| - | * **Tip 1:** Discover fields by making an unfiltered request: '' | + | |
| - | * **Tip 2:** Test filters in ERP interface first. | + | |
| - | * **Tip 3:** Build filter strings programmatically. | + | |
| - | + | ||
| - | **Example (Python): | + | |
| - | <code python> | + | |
| - | # Python example with comprehensive error handling | + | |
| - | import requests | + | |
| - | import time | + | |
| - | def fetch_directo_data(endpoint, | + | |
| - | url = f" | + | |
| - | headers = { | + | |
| - | " | + | |
| - | " | + | |
| - | } | + | |
| - | for attempt in range(max_retries): | + | |
| - | try: | + | |
| - | response = requests.get(url, | + | |
| - | if response.status_code == 200: | + | |
| - | return response.json() | + | |
| - | elif response.status_code == 429: | + | |
| - | # Rate limit - wait and retry | + | |
| - | wait_time = 2 ** attempt | + | |
| - | time.sleep(wait_time) | + | |
| - | elif response.status_code in [401, 403]: | + | |
| - | # Auth error - don't retry | + | |
| - | raise Exception(f" | + | |
| - | else: | + | |
| - | # Other error - log and retry | + | |
| - | print(f" | + | |
| - | time.sleep(1) | + | |
| - | except requests.exceptions.Timeout: | + | |
| - | print(f" | + | |
| - | time.sleep(2) | + | |
| - | except requests.exceptions.RequestException as e: | + | |
| - | print(f" | + | |
| - | time.sleep(2) | + | |
| - | raise Exception(f" | + | |
| - | # Usage | + | |
| - | items = fetch_directo_data(" | + | |
| - | </ | + | |
| - | + | ||
| - | **Last Updated:** 29-01-2026 | + | |
| - | **API Version:** 1 | + | |
| - | + | ||
| - | + | ||
| - | ===== 📚 Quick Reference Card ===== | + | |
| - | + | ||
| - | ==== Essential Endpoints ==== | + | |
| - | < | + | |
| - | Items: | + | |
| - | Customers: | + | |
| - | Orders: | + | |
| - | Invoices: | + | |
| - | Stock: | + | |
| - | Deletions: | + | |
| - | </ | + | |
| - | + | ||
| - | ==== Authentication ==== | + | |
| - | < | + | |
| - | X-Directo-Key: | + | |
| - | </ | + | |
| - | + | ||
| - | ==== Response Format ==== | + | |
| - | < | + | |
| - | Accept: application/ | + | |
| - | </ | + | |
| - | + | ||
| - | ==== Common Filters ==== | + | |
| - | < | + | |
| - | Exact match: | + | |
| - | Greater than: ? | + | |
| - | Less than: ? | + | |
| - | Not equal: | + | |
| - | Multiple values: | + | |
| - | Timestamp: | + | |
| - | </ | + | |
| - | + | ||
| - | ==== Filter Examples ==== | + | |
| - | < | + | |
| - | ? | + | |
| - | ? | + | |
| - | ? | + | |
| - | ? | + | |
| - | ? | + | |
| - | ? | + | |
| - | </ | + | |
| - | + | ||
| - | ==== Remember ==== | + | |
| - | + | ||
| - | * ✅ All fields can be filtered (except calculated fields) | + | |
| - | * ✅ Filters mirror ERP system behavior | + | |
| - | * ✅ Use timestamp filtering for sync | + | |
| - | * ✅ URL encode special characters | + | |
| - | * ✅ Implement rate limiting (60 req/min) | + | |
| - | * ✅ Handle errors with exponential backoff | + | |
| - | + | ||
| - | This documentation is maintained by the Directo development team. For questions or feedback, contact info@directo.ee | + | |
en/api_direct.1771416306.txt.gz · Last modified: 2026/02/18 14:05 by toomas