Skip to main content
POST
/
api
/
v1
/
trading
/
orders
/
sync-all
Sync All Orders
curl --request POST \
  --url https://api.example.com/api/v1/trading/orders/sync-all
{
  "synced": 123,
  "total": 123,
  "errors": [
    {}
  ]
}

Usage

result = client.sync_all_orders()

Response

synced
integer
Number of orders successfully synced.
total
integer
Total number of pending orders found.
errors
array
List of any errors encountered during sync.

Example

from polyhush import PolyhushClient

client = PolyhushClient(api_key="your-api-key")

result = client.sync_all_orders()

print(f"Synced: {result['synced']}/{result['total']} orders")

if result.get('errors'):
    print(f"\n⚠️ Sync errors:")
    for error in result['errors']:
        print(f"  - {error}")

Response

{
  "synced": 8,
  "total": 8,
  "errors": []
}

When to Use

Use sync_all_orders() when:
  • Reconnecting after a network outage
  • Starting a trading session to ensure state is current
  • Debugging position/balance discrepancies
  • After system maintenance or restarts
This is a good method to call when initializing your trading bot to ensure you have accurate order state before making trading decisions.
# Bot startup routine
def initialize_bot():
    client = PolyhushClient(api_key=os.environ["POLYHUSH_API_KEY"])
    
    # Sync all orders to ensure accurate state
    sync_result = client.sync_all_orders()
    print(f"Synced {sync_result['synced']} orders")
    
    # Now safe to make trading decisions
    balance = client.get_balance()
    positions = client.get_positions()
    
    return client, balance, positions