Skip to main content
curl -X GET "https://api.strike.markets/test-auth" \
  -H "X-API-Key: stk_your_api_key_here"
{
  "authenticated": true,
  "wallet_address": "0x742d35cc6c6c7532b1140da4c8a2f6c8ecfc9b46",
  "api_key_present": true,
  "api_key_type": "personal",
  "timestamp": "2024-01-15T16:30:00Z"
}
curl -X GET "https://api.strike.markets/test-auth" \
  -H "X-API-Key: stk_your_api_key_here"
{
  "authenticated": true,
  "wallet_address": "0x742d35cc6c6c7532b1140da4c8a2f6c8ecfc9b46",
  "api_key_present": true,
  "api_key_type": "personal",
  "timestamp": "2024-01-15T16:30:00Z"
}

Overview

Test authentication and API key validity. Useful for verifying your API key setup and debugging authentication issues.

Authentication

Include your API key in the X-API-Key header:
X-API-Key: stk_your_api_key_here
For service keys, also include the wallet address:
X-API-Key: your_service_key
X-Wallet-Address: 0x742d35cc6c6c7532b1140da4c8a2f6c8ecfc9b46

Response Fields

authenticated
boolean
Indicates if authentication was successful
wallet_address
string
The wallet address associated with the authenticated API key
api_key_present
boolean
Confirms an API key was provided in the request
api_key_type
string
Type of API key used: “personal” or “service”
timestamp
string
ISO 8601 timestamp of the authentication test

Use Cases

Initial Integration Testing

Verify your API key integration is working correctly:
async function testAuth(apiKey) {
  try {
    const response = await fetch('https://api.strike.markets/test-auth', {
      headers: { 'X-API-Key': apiKey }
    });
    
    if (response.ok) {
      const data = await response.json();
      console.log('✓ Authentication working');
      console.log(`Wallet: ${data.wallet_address}`);
      console.log(`Key type: ${data.api_key_type}`);
    } else {
      console.error('✗ Authentication failed');
    }
  } catch (error) {
    console.error('✗ Authentication error:', error);
  }
}

API Key Validation

Check if an API key is valid before making trading operations:
async function validateApiKey(apiKey) {
  const response = await fetch('https://api.strike.markets/test-auth', {
    headers: { 'X-API-Key': apiKey }
  });
  return response.status === 200;
}

// Use before trading
if (await validateApiKey(process.env.STRIKE_API_KEY)) {
  // Proceed with trading operations
  console.log('API key is valid, proceeding with trades...');
} else {
  console.error('Invalid API key - cannot trade');
}

Service Key Testing

Test service key authentication with wallet address:
import requests

def test_service_auth(service_key, wallet_address):
    headers = {
        'X-API-Key': service_key,
        'X-Wallet-Address': wallet_address
    }
    
    response = requests.get(
        'https://api.strike.markets/test-auth',
        headers=headers
    )
    
    if response.status_code == 200:
        data = response.json()
        print(f"✓ Service key authentication successful")
        print(f"Wallet: {data['wallet_address']}")
        print(f"Key type: {data['api_key_type']}")
        return True
    else:
        print(f"✗ Authentication failed: {response.json()}")
        return False

Debugging Auth Issues

Use this endpoint to debug common authentication problems:
  • Missing X-API-Key header
  • Invalid API key format
  • Revoked API keys
  • Service key missing wallet address

Error Responses

401 Unauthorized
object
Missing API key
{
  "detail": "No API key provided"
}
401 Unauthorized
object
Invalid API key format
{
  "detail": "Invalid API key format"
}
401 Unauthorized
object
Invalid or revoked API key
{
  "detail": "Invalid API key"
}
401 Unauthorized
object
Service key missing wallet address
{
  "detail": "Service key requires wallet address"
}

Implementation Notes

  • API keys are validated against the database
  • Personal keys are verified by hash lookup
  • Service keys require additional wallet address validation
  • Rate limited to 60 requests per minute per IP
  • Does not create or modify any account data
  • Useful for health checks and monitoring

Security Considerations

Never share or log API keys in production. This endpoint should only be used for testing and debugging during development.

Best Practices

  • Store API keys in environment variables
  • Use this endpoint to validate keys after rotation
  • Implement proper error handling for authentication failures
  • Monitor for unusual authentication patterns