How to Use the API

Welcome to the CloudLions API Tutorial

In this guide, you'll learn how to upload files using our API. Follow the examples in Python, PHP, and Node.js. Make sure to replace placeholder values with your actual API key and file paths.

1. API Endpoint

The API URL you will use is:

https://api.cloudlions.cc/api.php
                

Your API key is available on your profile page within your account.

2. Python Example

Here’s a Python example for uploading a file:


import requests

# Define the API URL and your API key
api_url = "https://api.cloudlions.cc/api.php"
api_key = "YOUR_API_KEY"  # Replace with your actual API key

# Path to the file you want to upload
file_path = "path/to/your/file.ext"

# Prepare the file and data to be sent
files = {'file': open(file_path, 'rb')}
data = {'api_key': api_key}

# Make the POST request
response = requests.post(api_url, files=files, data=data)

# Print the response
print(response.json())

                

3. PHP Example

Here’s how you can upload a file using PHP:


<?php
$api_url = "https://api.cloudlions.cc/api.php";
$api_key = "YOUR_API_KEY";  // Replace with your actual API key
$file_path = "path/to/your/file.ext";  // Path to the file you want to upload

$ch = curl_init();

$data = [
    'api_key' => $api_key,
    'file' => new CURLFile($file_path)
];

curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

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

echo $response;
?>

                

4. Node.js Example

Here’s a Node.js example for uploading a file:


const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');

const apiUrl = "https://api.cloudlions.cc/api.php";
const apiKey = "YOUR_API_KEY";  // Replace with your actual API key
const filePath = "path/to/your/file.ext";  // Path to the file you want to upload

const form = new FormData();
form.append('api_key', apiKey);
form.append('file', fs.createReadStream(filePath));

axios.post(apiUrl, form, {
    headers: form.getHeaders()
})
.then(response => {
    console.log(response.data);
})
.catch(error => {
    console.error('Error uploading file:', error);
});

                

5. Handling Responses

The API returns a JSON response. Here’s what you can expect:

Successful Response:


{
    "status": 1,
    "file_code": "https://cloudlions.cc/d/somefilecode"
}

                

Error Response:


{
    "status": 4,
    "message": "Invalid API key."
}

                

If you have any questions or need help, please refer to the API documentation or contact our support team.

© CloudLions.
Choose Layouts
Vertical
Horizontal
Skin Layouts
Default
Bordered
Light & Dark
LTR & RTL
Content Width
Topbar Colors