Loading the guide…
Loading the guide…
This guide will help you get started with the FlareKit API. We'll cover the basics of authentication, making your first API request, and some common use cases.
Before you begin, make sure you have:
All API requests require authentication using a Bearer token. Include the token in your requests using the Authorization header:
Authorization: Bearer YOUR_API_KEY
Let's try a simple example using cURL:
# List files
curl -X GET \
https://flarekit.mockkey.com/api/v1/files \
-H 'Authorization: Bearer YOUR_API_KEY'
Or using JavaScript with fetch:
const response = await fetch('https://flarekit.mockkey.com/api/v1/files', {
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
}
});
const data = await response.json();
console.log(data);
const formData = new FormData();
formData.append('file', fileInput.files[0]);
formData.append('parentId', null);
formData.append('hash', 'xxxxxx-xxxxx-xxxxx-xxxx');
const uploadResponse = await fetch('https://flarekit.mockkey.com/api/v1/file/upload', {
method: 'PUT',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
},
body: formData
});
const { url } = await uploadResponse.json();
console.log('File uploaded:', url);
const response = await fetch('https://flarekit.mockkey.com/api/v1/files?page=1&limit=10', {
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
}
});
const data = await response.json();
console.log('Files:', data.items);
// List trash items
const trashResponse = await fetch('https://flarekit.mockkey.com/api/v1/files/trash', {
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
}
});
const trashData = await trashResponse.json();
console.log('Trash items:', trashData.items);
// Restore a file from trash
const restoreResponse = await fetch(`https://flarekit.mockkey.com/api/v1/files/trash/restore/${fileId}`, {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
}
});
const restoredFile = await restoreResponse.json();
console.log('Restored file:', restoredFile);
// Permanently delete a file from trash
const deleteResponse = await fetch(`https://flarekit.mockkey.com/api/v1/files/trash/${fileId}`, {
method: 'DELETE',
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
}
});
const deleteResult = await deleteResponse.json();
console.log('Delete result:', deleteResult);
All FlareKit API endpoints return errors in a consistent JSON format. A typical error response looks like this:
{
"error": "Unauthorized"
}
Some endpoints may include additional details:
{
"error": "Validation failed",
"details": {
"field": "name",
"message": "Name is required"
}
}
error field is always a string describing the error.details field (if present) provides more information about the error.Example: Unauthorized
HTTP/1.1 401 Unauthorized
{
"error": "Unauthorized"
}
Example: Not Found
HTTP/1.1 404 Not Found
{
"error": "File not found"
}