Getting Started with REST API: Authentication and Your First Request

K

Katy Spark

Sep 09, 2025

4 min read 1,754 views

Getting started with the PulseMarkets API is straightforward. In this tutorial, we'll walk through authentication, making your first request, and handling responses. By the end, you'll be fetching real-time forex quotes programmatically.

Prerequisites

Before we begin, you'll need:

  • A PulseMarkets account (free tier is fine for this tutorial)
  • An API key from your dashboard
  • Basic programming knowledge in Python, JavaScript, or cURL

Step 1: Get Your API Key

Log into your PulseMarkets dashboard and navigate to the API Keys section. Create a new key with a descriptive name like "Development" or "Tutorial". You'll receive:

  • API Key: A public identifier starting with fx_
  • API Secret: A private key for additional security (optional for read-only requests)

Important: Never share your API secret or commit it to public repositories.

Step 2: Understanding Authentication

The PulseMarkets API uses header-based authentication. Include your API key in every request:

X-API-Key: fx_your_api_key_here

All requests must be made over HTTPS. HTTP requests will be rejected.

Step 3: Your First Request

Let's fetch a quote for EUR/USD. Here are examples in different languages:

cURL

curl -X GET "https://api.pulse-markets.com/api/quote/EURUSD" \
  -H "X-API-Key: fx_your_api_key_here"

Python

import requests

API_KEY = "fx_your_api_key_here"
BASE_URL = "https://api.pulse-markets.com"

headers = {
    "X-API-Key": API_KEY
}

response = requests.get(
    f"{BASE_URL}/api/quote/EURUSD",
    headers=headers
)

if response.status_code == 200:
    data = response.json()
    print(f"EUR/USD Price: {data['data']['price']}")
    print(f"Bid: {data['data']['bid']}")
    print(f"Ask: {data['data']['ask']}")
else:
    print(f"Error: {response.status_code}")
    print(response.json())

JavaScript (Node.js)

const axios = require('axios');

const API_KEY = 'fx_your_api_key_here';
const BASE_URL = 'https://api.pulse-markets.com';

async function getQuote(symbol) {
    try {
        const response = await axios.get(
            `${BASE_URL}/api/quote/${symbol}`,
            {
                headers: {
                    'X-API-Key': API_KEY
                }
            }
        );

        const { price, bid, ask, timestamp } = response.data.data;
        console.log(`${symbol}: ${price} (Bid: ${bid}, Ask: ${ask})`);
        console.log(`Timestamp: ${new Date(timestamp).toISOString()}`);

        return response.data;
    } catch (error) {
        console.error('Error:', error.response?.data || error.message);
    }
}

getQuote('EURUSD');

Step 4: Understanding the Response

A successful response looks like this:

{
    "success": true,
    "data": {
        "symbol": "EURUSD",
        "price": 1.08542,
        "bid": 1.08540,
        "ask": 1.08544,
        "high": 1.08721,
        "low": 1.08325,
        "timestamp": "2026-01-15T14:30:00.000Z"
    },
    "meta": {
        "plan": "Free",
        "usage": {
            "minuteLimit": 10,
            "minuteUsed": 1,
            "dailyLimit": 100,
            "dailyUsed": 15
        }
    }
}

Step 5: Fetching Multiple Quotes

To get quotes for multiple pairs in one request:

# Python example
symbols = ["EURUSD", "GBPUSD", "USDJPY", "XAUUSD"]

response = requests.get(
    f"{BASE_URL}/api/quotes",
    headers=headers,
    params={"symbols": ",".join(symbols)}
)

for quote in response.json()['data']:
    print(f"{quote['symbol']}: {quote['bid']}")

Step 6: Fetching Historical Data

Get candlestick data for technical analysis:

# Get last 100 hourly candles for EUR/USD
response = requests.get(
    f"{BASE_URL}/api/candles/EURUSD",
    headers=headers,
    params={
        "timeframe": "H1",
        "limit": 100
    }
)

candles = response.json()['data']['candles']
for candle in candles[-5:]:  # Print last 5
    print(f"{candle['timestamp']}: O:{candle['open']} H:{candle['high']} L:{candle['low']} C:{candle['close']}")

Step 7: Error Handling

Always implement proper error handling:

def safe_api_call(endpoint, params=None):
    try:
        response = requests.get(
            f"{BASE_URL}{endpoint}",
            headers=headers,
            params=params,
            timeout=10
        )
        response.raise_for_status()
        return response.json()

    except requests.exceptions.Timeout:
        print("Request timed out - try again")
        return None

    except requests.exceptions.HTTPError as e:
        error_data = response.json()
        if response.status_code == 429:
            print(f"Rate limited - wait {error_data['error']['retry_after']} seconds")
        elif response.status_code == 401:
            print("Invalid API key")
        else:
            print(f"API error: {error_data['error']['message']}")
        return None

    except requests.exceptions.RequestException as e:
        print(f"Request failed: {e}")
        return None

Rate Limits

Be mindful of rate limits based on your plan:

PlanRequests/MinuteRequests/Day
Free10100
Individual6010,000
Business300100,000

Rate limit info is included in response headers:

  • X-RateLimit-Limit: Your limit per minute
  • X-RateLimit-Remaining: Requests remaining
  • X-Daily-Remaining: Daily requests remaining

Next Steps

Now that you can make basic API requests, consider:

  • Upgrading to WebSocket for real-time streaming data
  • Building a price alert system
  • Creating a portfolio tracker
  • Implementing automated trading signals

Check out our other tutorials for more advanced implementations. Happy coding!

Tags: REST API authentication API tutorial python javascript
Share:
K

Katy Spark

Content Writer at PulseMarkets

Expert in forex trading, market analysis, and financial API integration. Helping traders and developers make better decisions with data.

Ready to Get Started?

Access professional-grade market data with our powerful API

Start Free Trial