Back to Documentation

Authentication

Learn how to authenticate your requests to the XpatAI API.

Overview

XpatAI uses API keys to authenticate requests. You can view and manage your API keys in your dashboard. Your API keys carry many privileges, so be sure to keep them secure.

Never share your API keys in publicly accessible areas such as GitHub, client-side code, or blog posts.

Authentication Methods

Bearer Authentication

The recommended way to authenticate requests is using Bearer authentication with your API key.

Authorization: Bearer YOUR_API_KEY

Replace YOUR_API_KEY with your actual API key

Query Parameter

Alternatively, you can authenticate by including your API key as a query parameter.

https://api.xpatai.xyz/v1/endpoint?api_key=YOUR_API_KEY

Note: Query parameter authentication is less secure and should only be used for testing.

Code Examples

JavaScript/Node.js

const response = await fetch('https://api.xpatai.xyz/v1/countries', { headers: { 'Authorization': 'Bearer YOUR_API_KEY' } });

Python

import requests response = requests.get( 'https://api.xpatai.xyz/v1/countries', headers={'Authorization': 'Bearer YOUR_API_KEY'} )

cURL

curl -X GET 'https://api.xpatai.xyz/v1/countries' \ -H 'Authorization: Bearer YOUR_API_KEY'

Getting API Keys

To get your API key, you need to:

  1. Sign up for an XpatAI account
  2. Navigate to the API section in your dashboard
  3. Generate a new API key
  4. Copy and securely store your API key