FOREX.com Positions API

Open position management

OpenAPI Specification

forex-com-positions-api-openapi.yml Raw ↑
openapi: 3.0.3
info:
  title: FOREX.com REST Account Positions API
  description: The FOREX.com REST API, hosted at ciapi.cityindex.com/TradingAPI, enables algorithmic traders to authenticate sessions, retrieve real-time and historical price data, execute buy/sell orders across 80+ forex and CFD markets, and manage account balances, positions, and order history programmatically. Authentication uses a session-based header credential obtained from the /session endpoint. A separate FIX API is available for institutional clients.
  version: 1.0.0
  contact:
    name: FOREX.com API Support
    url: https://www.forex.com/en/help-and-support/
    email: support.en@forex.com
  termsOfService: https://www.forex.com/en-us/help-and-support/pricing-and-fees/
  x-api-id: forex-com-trading-api
  x-logo:
    url: https://www.forex.com/favicon.ico
servers:
- url: https://ciapi.cityindex.com/TradingAPI
  description: FOREX.com REST API Base URL
security:
- SessionAuth: []
  UserNameAuth: []
tags:
- name: Positions
  description: Open position management
paths:
  /order/openpositions:
    get:
      operationId: listOpenPositions
      summary: List open trading positions
      description: Retrieve a list of all open trading positions for the specified trading account. Returns position details including unrealised P&L, direction, quantity, and current pricing.
      tags:
      - Positions
      parameters:
      - name: TradingAccountId
        in: query
        required: true
        description: Trading account ID to retrieve positions for
        schema:
          type: integer
        example: 12345678
      responses:
        '200':
          description: Open positions retrieved
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OpenPositionsResponse'
components:
  schemas:
    OpenPositionsResponse:
      type: object
      properties:
        OpenPositions:
          type: array
          items:
            $ref: '#/components/schemas/OpenPosition'
    OpenPosition:
      type: object
      properties:
        OrderId:
          type: integer
          description: Order ID
        MarketId:
          type: integer
          description: Market ID
        MarketName:
          type: string
          description: Market name (e.g. EUR/USD)
        Direction:
          type: string
          enum:
          - buy
          - sell
          description: Position direction
        Quantity:
          type: number
          format: double
          description: Position size
        Price:
          type: number
          format: double
          description: Entry price
        UnrealisedPnl:
          type: number
          format: double
          description: Unrealised profit and loss
        Bid:
          type: number
          format: double
          description: Current bid price
        Offer:
          type: number
          format: double
          description: Current offer (ask) price
        TradingAccountId:
          type: integer
        Currency:
          type: string
  securitySchemes:
    SessionAuth:
      type: apiKey
      in: header
      name: Session
      description: Session ID obtained from POST /session
    UserNameAuth:
      type: apiKey
      in: header
      name: UserName
      description: FOREX.com account username
externalDocs:
  description: FOREX.com API Trading Documentation
  url: https://www.forex.com/en/trading-tools/api-trading/