Quick Start Guide

Get started with the Windy Network API in minutes. This guide will help you make your first API calls for real-time market data.

Get Your API Key

  1. Sign up at windy.network
  2. Navigate to Dashboard > API Keys
  3. Click Create API Key and copy your key

Keep your API key secure and never expose it in client-side code.

Installation

JavaScript/TypeScript SDK (Recommended)

npm install @windy-network/client-js

Direct API Access

You can also call the REST API directly using curl, fetch, or any HTTP client.

Your First API Call

Using the SDK

import { WindyClient } from '@windy-network/client-js';

// Create a client with your API key
const client = WindyClient('your-api-key');

// Get cryptocurrency rate
const btc = await client.crypto.getRate('BTC', 'USD');
console.log(`Bitcoin: $${btc.rate}`);

// Get stock quote
const apple = await client.stocks.getQuote('AAPL');
console.log(`Apple: $${apple.price}`);

// Get forex rate
const eurUsd = await client.forex.getRate('EUR', 'USD');
console.log(`EUR/USD: ${eurUsd.rate}`);

Using cURL

# Get Bitcoin rate
curl -H "X-API-Key: your-api-key" \
  https://api.windy.network/v1/crypto/rate/BTC-USD

# Get stock quote
curl -H "X-API-Key: your-api-key" \
  https://api.windy.network/v1/stock/quote/AAPL

# Get forex rate
curl -H "X-API-Key: your-api-key" \
  https://api.windy.network/v1/forex/rate/EUR-USD

Using Python

import requests

headers = {"X-API-Key": "your-api-key"}
base_url = "https://api.windy.network"

# Get Bitcoin rate
response = requests.get(f"{base_url}/v1/crypto/rate/BTC-USD", headers=headers)
data = response.json()
print(f"Bitcoin: ${data['rate']}")

Real-time Streaming

Subscribe to live price updates using WebSocket, SSE, or long-polling.

WebSocket (SDK)

const ws = client.streaming.websocket();

ws.on('connect', () => console.log('Connected'));
ws.on('error', (err) => console.error(err));

await ws.connect();

// Subscribe to BTC/USD rate updates
ws.subscribe('crypto:rate:BTC:USD', (message) => {
  console.log('BTC:', message.data.rate);
});

WebSocket (Native)

const ws = new WebSocket('wss://ws.windy.network/v1/crypto/stream/ws');

ws.onopen = () => {
  // Authenticate
  ws.send(JSON.stringify({
    type: 'auth',
    apiKey: 'your-api-key'
  }));

  // Subscribe to channel
  ws.send(JSON.stringify({
    type: 'subscribe',
    channel: 'crypto:rate:BTC:USD'
  }));
};

ws.onmessage = (event) => {
  const data = JSON.parse(event.data);
  console.log('Rate update:', data);
};

Server-Sent Events (SSE)

const eventSource = new EventSource(
  'https://api.windy.network/v1/crypto/stream/sse?channel=crypto:rate:BTC:USD',
  { headers: { 'X-API-Key': 'your-api-key' } }
);

eventSource.onmessage = (event) => {
  const data = JSON.parse(event.data);
  console.log('Rate update:', data);
};

Available Markets

| Market | Description | Example Endpoints | |--------|-------------|-------------------| | Crypto | Cryptocurrency rates, tickers, OHLC | /v1/crypto/rate/{symbol} | | Stocks | Stock quotes and market data | /v1/stock/quote/{symbol} | | Forex | Foreign exchange rates | /v1/forex/rate/{pair} | | Options | Options chains and Greeks | /v1/options/chain/{symbol} | | Calendar | Market hours and holidays | /v1/calendar/status |

Error Handling

SDK Error Handling

import {
  ApiError,
  AuthenticationError,
  RateLimitError
} from '@windy-network/client-js';

try {
  const rate = await client.crypto.getRate('BTC', 'USD');
} catch (error) {
  if (error instanceof AuthenticationError) {
    console.error('Invalid API key');
  } else if (error instanceof RateLimitError) {
    console.error(`Rate limited. Retry after ${error.retryAfter}s`);
  } else if (error instanceof ApiError) {
    console.error(`API error: ${error.message}`);
  }
}

HTTP Error Codes

| Code | Description | |------|-------------| | 401 | Invalid or missing API key | | 403 | Insufficient permissions for this resource | | 429 | Rate limit exceeded | | 404 | Resource not found | | 500 | Internal server error |

Rate Limits

| Plan | Requests/min | WebSocket Connections | |------|-------------|----------------------| | Free | 60 | 1 | | Pro | 600 | 5 | | Enterprise | Unlimited | Unlimited |

Rate limit headers are included in every response:

  • X-RateLimit-Limit: Maximum requests per window
  • X-RateLimit-Remaining: Requests remaining
  • X-RateLimit-Reset: Unix timestamp when the limit resets

Next Steps

Need Help?