Authentication

Learn how to authenticate your requests using API keys and manage your access credentials.

API Key Authentication

Authentication Required

All StayAPI endpoints require authentication using an API key.

StayAPI uses API key authentication for all requests. You must include your API key in the x-api-key header with every API request.

How to Include Your API Key

Add the x-api-key header to every request:

x-api-key: YOUR_API_KEY_HERE

Getting Your API Key

1

Sign Up for an Account

Create a free StayAPI account to get started. No credit card required for testing.

Sign Up for Free →
2

Access Your Dashboard

Once logged in, navigate to your dashboard to view and manage your API keys.

3

Generate API Key

Generate a new API key for your application. You can create multiple keys for different environments.

API Key Security

Keep Your API Key Secure

Never expose your API key in client-side code, public repositories, or unsecured environments.

Best Practices

  • Store API keys as environment variables
  • Use different keys for development, staging, and production
  • Rotate your API keys regularly
  • Never commit API keys to version control
  • Use server-side requests only - never expose keys in client-side code

Environment Variables Example

# .env file
STAYAPI_KEY=your_api_key_here

# In your application
api_key = process.env.STAYAPI_KEY  # Node.js
api_key = os.environ['STAYAPI_KEY']  # Python
api_key = ENV['STAYAPI_KEY']  # Ruby

Rate Limits

API keys are subject to rate limits to ensure fair usage and optimal performance for all users.

Plan Requests per Hour Requests per Day
Free 100 1,000
Professional 1,000 25,000
Enterprise Custom Custom

Rate Limit Headers

Check the response headers for rate limit information: X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Reset.

Authentication Errors

401 Unauthorized

Returned when no API key is provided or the API key is invalid.

{
  "error": {
    "code": "unauthorized",
    "message": "Invalid or missing API key",
    "details": "Please provide a valid API key in the x-api-key header"
  }
}

429 Rate Limit Exceeded

Returned when you exceed your rate limit.

{
  "error": {
    "code": "rate_limit_exceeded",
    "message": "Rate limit exceeded",
    "details": "You have exceeded your hourly rate limit. Try again later."
  }
}
Request
curl -X GET "https://api.stayapi.com/v1/meta/search" \
  -H "x-api-key: sk_live_abcd1234..." \
  -H "Content-Type: application/json" \
  -G \
  -d "hotel_name=Four Seasons Resort Bali"
Response
{
  "status": "success",
  "data": {
    "hotel_name": "Four Seasons Resort Bali",
    "links": {
      "booking_com": "https://www.booking.com/hotel/id/four-seasons-resort-bali-at-jimbaran-bay.html",
      "expedia": "https://www.expedia.com/Jimbaran-Hotels-Four-Seasons-Resort-Bali.h1234567.Hotel-Information",
      "hotels_com": "https://hotels.com/ho123456/four-seasons-resort-bali-jimbaran-indonesia/",
      "agoda": "https://www.agoda.com/four-seasons-resort-bali-at-jimbaran-bay/hotel/bali-id.html"
    },
    "platform_count": 4,
    "official_website_detected": true
  }
}