External API Documentation

This API allows you to programmatically manage trades and tables.

Configuration

  1. Add EXTERNAL_API_KEY to your .env file:
    EXTERNAL_API_KEY=your-secure-secret-key-here
    

Authentication

Auth Header: x-api-key: <your-secure-secret-key-here> (Required for all endpoints)


Tables

Create Table

URL: /api/external/tables Method: POST

Payload

FieldTypeRequiredDescription
userIdstringYesThe ID of the user owning the table.
namestringYesName of the table.

Example Request (cURL)

curl -X POST https://journals.trading/api/external/tables \
  -H "Content-Type: application/json" \
  -H "x-api-key: your-key" \
  -d '{
    "userId": "user_123",
    "name": "Bot Trades 2023"
  }'

Get User Tables

URL: /api/external/tables Method: GET

Query Parameters

ParameterRequiredDescription
userIdYesThe ID of the user to fetch tables for.

Example Request (cURL)

curl "https://journals.trading/api/external/tables?userId=user_123" \
  -H "x-api-key: your-key"

Update Table

URL: /api/external/tables Method: PATCH

Payload

FieldTypeRequiredDescription
idnumberYesThe ID of the table to update.
userIdstringYesThe ID of the user (for ownership verification).
namestringYesNew name for the table.

Example Request (cURL)

curl -X PATCH https://journals.trading/api/external/tables \
  -H "Content-Type: application/json" \
  -H "x-api-key: your-key" \
  -d '{
    "id": 10,
    "userId": "user_123",
    "name": "Renamed Table"
  }'

Delete Table

URL: /api/external/tables Method: DELETE

Payload

FieldTypeRequiredDescription
idnumberYesThe ID of the table to delete.
userIdstringYesThe ID of the user (for ownership verification).

Example Request (cURL)

curl -X DELETE https://journals.trading/api/external/tables \
  -H "Content-Type: application/json" \
  -H "x-api-key: your-key" \
  -d '{
    "id": 10,
    "userId": "user_123"
  }'

Trades

Create Trade

URL: /api/external/trades Method: POST

Payload

FieldTypeRequiredDescription
userIdstringYesThe ID of the user the trade belongs to.
assetstringYesName of the asset (e.g., "BTC", "AAPL").
entryPricenumberYesEntry price.
exitPricenumberYesExit price.
longOrShort"long" | "short"NoDefault is "long".
entryDatestring (ISO)NoDate of entry.
exitDatestring (ISO)NoDate of exit.
resultCommentstringNoComment or notes.
tableIdnumberNoID of an existing table to link this trade to.

Note: If tableId is provided, the system verifies it exists for that user before creating the trade.

Example Request (cURL)

curl -X POST https://journals.trading/api/external/trades \
  -H "Content-Type: application/json" \
  -H "x-api-key: your-key" \
  -d '{
    "userId": "user_123",
    "asset": "ETH",
    "longOrShort": "long",
    "entryPrice": 2000,
    "exitPrice": 2100,
    "tableId": 10
  }'

Update Trade

URL: /api/external/trades Method: PATCH

Payload

FieldTypeRequiredDescription
idnumberYesThe ID of the trade to update.
userIdstringYesThe ID of the user (for ownership verification).
assetstringNoName of the asset.
entryPricenumberNoEntry price.
exitPricenumberNoExit price.
longOrShort"long" | "short"NoDirection.
entryDatestring (ISO)NoDate of entry.
exitDatestring (ISO)NoDate of exit.
resultCommentstringNoComment or notes.

Delete Trade

URL: /api/external/trades Method: DELETE

Payload

FieldTypeRequiredDescription
idnumberYesThe ID of the trade to delete.
userIdstringYesThe ID of the user (for ownership verification).

Example Request (cURL)

curl -X DELETE https://journals.trading/api/external/trades \
  -H "Content-Type: application/json" \
  -H "x-api-key: your-key" \
  -d '{
    "id": 123,
    "userId": "user_123"
  }'

Get Trades

URL: /api/external/trades Method: GET

Query Parameters

ParameterRequiredDescription
userIdYesThe ID of the user to fetch trades for.
tableIdNoIf provided, fetches trades only for this specific table.
limitNoMax number of trades to return (default: 50).

Example Request (cURL)

curl "https://journals.trading/api/external/trades?userId=user_123&limit=10" \
  -H "x-api-key: your-key"