Skip to main content
Version: v2

Migration from API v1

Upgrade from Nexchange API v1 to the improved v2 interface with cleaner field names, better structure, and enhanced developer experience while maintaining full backward compatibility.

Why Upgrade to API v2?โ€‹

Key Improvements in v2โ€‹

  • ๐ŸŽฏ Intuitive Field Names: side instead of order_type, deposit_amount instead of amount_quote
  • ๐Ÿ“Š Flat Structure: No nested objects, all fields at the top level
  • ๐Ÿ”ค String Values: "BUY" instead of numeric codes like 0
  • ๐Ÿงน Cleaner Responses: Removed deprecated and unnecessary fields
  • ๐Ÿ“ Better Documentation: More descriptive field names and clearer concepts
  • ๐Ÿ”— Consistent Endpoints: Simplified URL structure and standardized naming
  • ๐Ÿ” API Key Required: All endpoints now require API key authentication for security

Base URL Changesโ€‹

v1 Base URL:

https://api.n.exchange/en/api/v1/

v2 Base URL:

https://api.n.exchange/en/api/v2/

Field Mapping Referenceโ€‹

Ordersโ€‹

v1 Fieldv2 FieldChange TypeDescription
order_typesideRenamedNow uses "BUY" or "SELL" strings
amount_basewithdraw_amountRenamedMore descriptive naming
amount_quotedeposit_amountRenamedMore descriptive naming
pair.basewithdraw_currencyFlattenedCurrency code only (string)
pair.quotedeposit_currencyFlattenedCurrency code only (string)
status_name[0][1]statusSimplifiedFlat string status
payment_windowpayment_window_minutesRenamedClearer units
payment_deadlinefixed_rate_deadlineRenamedMore descriptive
transactions[].tx_iddeposit_transaction, withdraw_transactionSplitSeparate fields by type

Pairsโ€‹

v1 Fieldv2 FieldChange TypeDescription
basetoRenamedCurrency you receive
quotefromRenamedCurrency you send
fee_ask, fee_bidremovedDeprecatedSimplified response
test_moderemovedDeprecatedNo longer needed
orderbook_enabledremovedDeprecatedNo longer needed
reverse_orderbook_enabledremovedDeprecatedNo longer needed

Ratesโ€‹

v1 Fieldv2 FieldChange TypeDescription
max_receive_amountmax_withdraw_amountRenamedMore descriptive
min_receive_amountmin_withdraw_amountRenamedMore descriptive
allowed_historic_price_varianceremovedDeprecatedNo longer needed
allowed_historic_price_ageremovedDeprecatedNo longer needed
max_amountremovedDeprecatedReplaced by specific limits
min_amountremovedDeprecatedReplaced by specific limits

Pre-screeningโ€‹

v1 Fieldv2 FieldChange TypeDescription
amount_quotedeposit_amountRenamedMore descriptive
amount_basewithdraw_amountRenamedMore descriptive
detailstatus, messageSplitStructured response

Endpoint Changesโ€‹

Currency Endpointsโ€‹

v1 Endpointv2 EndpointChanges
GET /currency/GET /currency/โœ… Same endpoint
GET /currency/{code}/GET /currency/{code}/โœ… Same endpoint
-GET /network/๐Ÿ†• New: List networks
-GET /network/{name}/๐Ÿ†• New: Get network details

Trading Pair Endpointsโ€‹

v1 Endpointv2 EndpointChanges
GET /pair/GET /pair/โœ… Same endpoint, simplified response
GET /pair/{name}/GET /pair/{name}/โœ… Same endpoint, simplified response

Rate Endpointsโ€‹

v1 Endpointv2 EndpointChanges
GET /info/bulk/GET /rate/๐Ÿ”„ Renamed: Cleaner endpoint name

Order Endpointsโ€‹

v1 Endpointv2 EndpointChanges
GET /orders/GET /orders/โœ… Same endpoint, simplified response
POST /orders/POST /orders/โœ… Same endpoint, simplified request/response
GET /orders/{unique_reference}/GET /orders/{unique_reference}/โœ… Same endpoint, simplified response
PATCH /orders/{unique_reference}/PATCH /orders/{unique_reference}/โœ… Same endpoint, simplified request

Risk Management Endpointsโ€‹

v1 Endpointv2 EndpointChanges
POST /pre_screening/POST /pre_screening/โœ… Same endpoint, structured response

Migration Examplesโ€‹

1. Get Trading Pairsโ€‹

v1 Endpoint:

curl -X GET "https://api.n.exchange/en/api/v1/pair/" \
-H "Accept: application/json" \
-H "Authorization: ApiKey api_key"

v1 Response:

[
{
"name": "BTCUSDC",
"base": "BTC",
"quote": "USDC",
"fee_ask": "0.005",
"fee_bid": "0.005",
"disabled": false,
"test_mode": false,
"orderbook_enabled": true,
"reverse_orderbook_enabled": false
}
]

v2 Endpoint:

curl -X GET "https://api.n.exchange/en/api/v2/pair/" \
-H "Accept: application/json" \
-H "Authorization: ApiKey api_key"

v2 Response:

[
{
"name": "BTCUSDC",
"to": "BTC",
"from": "USDC",
"disabled": false
}
]

2. Get Ratesโ€‹

v1 Endpoint:

curl -X GET "https://api.n.exchange/en/api/v1/info/bulk/" \
-H "Accept: application/json" \
-H "Authorization: ApiKey api_key"

v1 Response:

[
{
"pair": "BTCUSDC",
"rate": "45000.00",
"max_receive_amount": "10.00000000",
"min_receive_amount": "0.00100000",
"allowed_historic_price_variance": "0.05",
"allowed_historic_price_age": "300",
"max_amount": "500000.00",
"min_amount": "50.00"
}
]

v2 Endpoint:

curl -X GET "https://api.n.exchange/en/api/v2/rate/" \
-H "Accept: application/json" \
-H "Authorization: ApiKey api_key"

v2 Response:

[
{
"pair": "BTCUSDC",
"from": "USDC",
"to": "BTC",
"withdrawal_fee": "0.00050000",
"rate": "45000.00",
"rate_id": "abc123-000000",
"max_withdraw_amount": "10.00000000",
"min_withdraw_amount": "0.00100000",
"max_deposit_amount": "500000.00",
"min_deposit_amount": "50.00",
"expiration_time_unix": "1697365800"
}
]

3. Create Orderโ€‹

v1 Endpoint:

curl -X POST "https://api.n.exchange/en/api/v1/orders/" \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey api_key" \
-d '{
"amount_base": "0.01000000",
"pair_name": "BTCUSDC",
"withdraw_address": "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa"
}'

v1 Request:

{
"amount_base": "0.01000000",
"pair_name": "BTCUSDC",
"withdraw_address": "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa"
}

v2 Endpoint:

curl -X POST "https://api.n.exchange/en/api/v2/orders/" \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey api_key" \
-d '{
"side": "SELL",
"withdraw_amount": "0.01000000",
"deposit_currency": "USDC",
"withdraw_currency": "BTC",
"withdraw_address": "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa"
}'

v2 Request:

{
"side": "SELL",
"withdraw_amount": "0.01000000",
"deposit_currency": "USDC",
"withdraw_currency": "BTC",
"withdraw_address": "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa"
}

4. Pre-screening Requestโ€‹

v1 Request:

{
"ip": "192.168.1.1",
"pair": "BTCUSDC",
"amount_quote": "50000.0"
}

v1 Response:

{
"detail": "Pre-screening passed."
}

v2 Request:

{
"ip": "192.168.1.1",
"pair": "BTCUSDC",
"deposit_amount": "50000.0"
}

v2 Response:

{
"status": "success",
"message": "Pre-screening passed."
}

Step-by-Step Migrationโ€‹

Step 1: Update Base URLsโ€‹

Update all your API calls to use the v2 base URL:

// Before (v1)
const BASE_URL = 'https://api.n.exchange/en/api/v1/';

// After (v2)
const BASE_URL = 'https://api.n.exchange/en/api/v2/';

Step 2: Update Endpoint URLsโ€‹

Replace changed endpoint names:

// Before (v1)
const ratesUrl = `${BASE_URL}info/bulk/`;

// After (v2)
const ratesUrl = `${BASE_URL}rate/`;

Step 3: Add Authorization headerโ€‹

"Authorization: ApiKey api_key"

Step 4: Update Field Namesโ€‹

Replace old field names with new ones:

// Before (v1)
const orderData = {
amount_base: "0.01",
pair_name: "BTCUSDC",
order_type: 0 // numeric code
};

// After (v2)
const orderData = {
withdraw_amount: "0.01",
deposit_currency: "USDC",
withdraw_currency: "BTC",
side: "SELL" // string value
};

Step 5: Handle Response Changesโ€‹

Update response parsing logic:

// Before (v1) - nested pair structure
const baseCurrency = response.pair.base;
const quoteCurrency = response.pair.quote;
const status = response.status_name[0][1];

// After (v2) - flat structure
const withdrawCurrency = response.withdraw_currency;
const depositCurrency = response.deposit_currency;
const status = response.status;

Step 6: Remove Deprecated Fieldsโ€‹

Remove handling of deprecated fields:

// Remove these from v1 response parsing:
// - fee_ask, fee_bid
// - test_mode, orderbook_enabled
// - allowed_historic_price_variance
// - allowed_historic_price_age
// - max_amount, min_amount (use specific limits instead)

Migration Checklistโ€‹

  • Update base URLs from /v1/ to /v2/
  • Replace amount_base with withdraw_amount
  • Replace amount_quote with deposit_amount
  • Replace nested pair.base with flat withdraw_currency
  • Replace nested pair.quote with flat deposit_currency
  • Replace order_type numeric values with side strings
  • Update status parsing from status_name[0][1] to status
  • Replace /info/bulk/ with /rate/ endpoint
  • Update transaction handling from nested arrays to flat fields
  • Remove handling of deprecated fields
  • Update pre-screening response parsing to use status and message
  • Test all endpoints with new field names
  • Update error handling for new response format

Backward Compatibilityโ€‹

Don't worry about breaking changes:

  • v1 endpoints remain fully functional - No rush to migrate
  • Same business logic - v2 inherits all v1 functionality
  • Gradual migration - Migrate endpoints one by one
  • Side-by-side operation - Run both versions simultaneously during transition

New Features in v2โ€‹

Enhanced Filteringโ€‹

  • Rate filtering: fiat_only and crypto_only query parameters
  • Pair pagination: Better pagination support for large lists

Network Informationโ€‹

  • Network endpoints: New /network/ endpoints for blockchain network details
  • Enhanced currency info: Better token and network information

Improved Error Handlingโ€‹

  • Structured errors: Consistent error response format across all endpoints
  • Detailed validation: Field-specific error messages

Need Help?โ€‹

  • ๐Ÿ“š v2 API Reference - Complete v2 documentation
  • ๐Ÿ’ฌ Support - Contact our team for migration assistance

Ready to start? Try our Quick Start Guide guide! ๐Ÿš€

Next Stepsโ€‹


Questions about migration? Contact our support team for assistance with upgrading your integration.