LeaderOS API
  • 👋Getting Started
    • Introduction
    • Authentication
  • 🔐Auth
    • Login
    • Register
    • Sessions
  • 🧑‍🦱Users
    • Profiles
    • Roles
    • Tickets
    • Orders
  • 🛍️Store
    • Listing
    • Products
    • Categories
    • Buy
    • Donations
  • 🍏Bazaar
    • Player Storages
    • Servers
  • 🚨Support
    • Tickets
    • Messages
    • Categories
    • Quick Answers
  • 🪙Credits
    • Show Credits
    • Add Credits
    • Remove Credits
    • Send Credits
    • Set Credits
  • 👍Vote
    • Vote Links
  • 🎮Discord
    • Users
    • Settings
    • Roles
Powered by GitBook
On this page
  1. Getting Started

Authentication

LeaderOS uses a HTTP header to authenticate requests with an API key. The header is called X-Api-Key and the value is the API key.

The API key can be found in the LeaderOS settings.

Examples

GET Request

curl https://yourwebsite.com/api/store/products
   -H "X-Api-Key: YOUR_API_KEY"

POST Request

curl https://yourwebsite.com/api/store/products
   -H "X-Api-Key: YOUR_API_KEY"
   -H "Content-Type: multipart/form-data"
   -X POST
   -d "username=test&password=test"

GET Request

// GET
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://yourwebsite.com/api/store/products");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$headers = [
    'X-Api-Key: YOUR_API_KEY'
];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$output = curl_exec ($ch);
curl_close ($ch);

POST Request

// POST
curl_setopt($ch, CURLOPT_URL, "https://yourwebsite.com/api/auth/login");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, [
    'username' => 'test',
    'password' => 'test'
]);

$headers = [
    'X-Api-Key: YOUR_API_KEY'
];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$output = curl_exec ($ch);
curl_close ($ch);

GET Request

const instance = axios.create({
  baseURL: 'https://yourwebsite.com',
  headers: {
    'X-API-KEY': 'YOUR_API_KEY',
  },
});

// GET
instance.get('/api/store/products');

POST Request

const instance = axios.create({
  baseURL: 'https://yourwebsite.com',
  headers: {
    'X-API-KEY': 'YOUR_API_KEY',
  },
});

// POST
instance.post('/api/auth/login', {
  username: 'test',
  password: 'test'
}, {
  headers: {
    'Content-Type': 'multipart/form-data',
  }
});
PreviousIntroductionNextAuth

Last updated 5 months ago

👋