Authentication
All API requests must be authenticated using OAuth 2.0 with the password flow. You'll need to obtain an access token before making requests to protected endpoints.
POST/api/v1/login/
Login with username and password to get an access token
Name | Type | Required | Description |
---|---|---|---|
username | string | ✅ | Your AXRO account username |
password | string | ✅ | Your AXRO account password |
Example Request
- cURL
- JavaScript
- PHP
- Python
- Go
- C#
curl -X POST https://api.axro.com/api/v1/login/ \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'username=your_username&password=your_password'
// Using Fetch API
fetch('https://api.axro.com/api/v1/login/', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: 'username=your_username&password=your_password'
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
// Using cURL
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.axro.com/api/v1/login/');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'username=your_username&password=your_password');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$error = curl_error($ch);
curl_close($ch);
if ($error) {
echo "Error: " . $error;
} else {
$data = json_decode($response, true);
print_r($data);
}
# Using requests library (recommended)
import requests
url = 'https://api.axro.com/api/v1/login/'
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
data = 'username=your_username&password=your_password'
response = requests.post(url, headers=headers, data=data)
print(response.status_code)
print(response.json())
package main
import (
"fmt"
"io/ioutil"
"net/http"
"strings"
)
func main() {
url := "https://api.axro.com/api/v1/login/"
payload := strings.NewReader("username=your_username&password=your_password")
req, err := http.NewRequest("POST", url, payload)
if err != nil {
fmt.Println("Error creating request:", err)
return
}
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error sending request:", err)
return
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println("Error reading response:", err)
return
}
fmt.Println("Response Status:", resp.Status)
fmt.Println("Response Body:", string(body))
}
// Using HttpClient (modern approach)
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
// Create HttpClient instance
using (HttpClient client = new HttpClient())
{
// Set content type header
client.DefaultRequestHeaders.Add("Content-Type", "application/x-www-form-urlencoded");
// Create form content
var formContent = new StringContent(
"username=your_username&password=your_password",
Encoding.UTF8,
"application/x-www-form-urlencoded");
// Make the POST request
HttpResponseMessage response = await client.PostAsync(
"https://api.axro.com/api/v1/login/",
formContent);
// Read the response
string responseBody = await response.Content.ReadAsStringAsync();
// Check if request was successful
if (response.IsSuccessStatusCode)
{
Console.WriteLine("Response: " + responseBody);
}
else
{
Console.WriteLine("Error: " + response.StatusCode);
Console.WriteLine("Response: " + responseBody);
}
}
}
}
Example Response
{
"token_type": "Bearer",
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}