Skip to main content

General

Introduction

This documentation describes the routes and functionalities of the API. The API allows for file and directory management, dynamic module (cog) loading, and data manipulation in a JSON database. The API is divided into two main sections: one that requires an API Key and another that does not. Routes requiring an API Key are protected and limited to a maximum number of requests per minute.

The base domain of the API is https://api.adeptusstudio.com.

Part 1: Routes That Do Not Require an API Key

Get Directory Exploration

GET /explorer

Description: Retrieves the list of files and directories in a specific path.

Example URL:

https://api.adeptusstudio.com/explorer?path=/Launcher/

Query Parameters:

  • path (optional): The path of the directory to explore.

Response:

FieldTypeDescription
filesArrayList of files and directories
pathStringExplored path

Example Response:

{
"files": [
{
"name": "example.txt",
"type": "file",
"size": 1024,
"date": "2023-08-06T12:34:56.789Z"
},
{
"name": "folder",
"type": "directory"
}
],
"path": "/Launcher/"
}

Get File Content

GET /explorer/file

Description: Retrieves the content of a specific file.

Example URL:

https://api.adeptusstudio.com/explorer/file?path=/Launcher/db.json

Query Parameters:

  • path: The path of the file to retrieve.

Response:

  • 200 OK with the file content.
  • 400 Bad Request if the path is not a file.
  • 404 Not Found if the file does not exist.
  • 500 Internal Server Error in case of a server error.

Serve Dashboard

GET /dashboard

Description: Serves the dashboard.html file.

Example URL:

https://api.adeptusstudio.com/dashboard

Response:

  • 200 OK with the HTML file content.
  • 500 Internal Server Error in case of an error serving the file.

Part 2: Routes That Require an API Key

Verify API Key

Middleware: verifyApiKey

Description: Verifies if the request contains a valid API Key in the headers or body of the request.

Header:

  • x-api-key: The API Key to verify.

Get List of Cogs

GET /cogs

Description: Retrieves the list of available cogs.

Example URL:

https://api.adeptusstudio.com/cogs

Header:

  • x-api-key: The API Key to verify.

Response:

FieldTypeDescription
cogsArrayList of cog names

Example Response:

{
"cogs": ["team", "launcher", "reviews", "projects", "partners"]
}

Create New Cog

POST /create-cog

Description: Creates a new cog with the provided name and code.

Example URL:

https://api.adeptusstudio.com/create-cog

Header:

  • x-api-key: The API Key to verify.
  • Content-Type: application/json

Request Body:

{
"cogName": "newCog",
"cogCode": "console.log('New cog');"
}

Response:

  • 201 Created with a success message.
  • 400 Bad Request if cogName or cogCode is missing.
  • 500 Internal Server Error in case of an error creating the cog.

Example Response:

{
"success": true,
"message": "Cog 'newCog' created and loaded."
}

Delete File or Folder

DELETE /explorer/delete

Description: Deletes a specified file or folder.

Example URL:

https://api.adeptusstudio.com/explorer/delete?path=/Launcher/file.txt

Header:

  • x-api-key: The API Key to verify.

Query Parameters:

  • path: The path of the file or folder to delete.

Response:

  • 200 OK with a success message.
  • 400 Bad Request if the path parameter is missing.
  • 500 Internal Server Error in case of an error deleting the item.

Example Response:

{
"success": true,
"message": "Item '/Launcher/file.txt' deleted successfully."
}

User Management Routes

Get All Users

GET / (router path)

Description: Retrieves the list of all team members.

Example URL:

https://api.adeptusstudio.com/team

Header:

  • x-api-key: The API Key to verify.

Response:

FieldTypeDescription
usersArrayList of users

Example Response:

{
"users": [
{
"id": "98765",
"name": "Ana Martínez",
"age": "29",
"email": "[email protected]",
"bio": "Tech and photography enthusiast. Always seeking new adventures.",
"position": "Developer",
"has_mic": false,
"image": "https://cdn.modrinth.com/data/hTexWmdS/b5882166fc6114adf784ebc51e728af63494e233.png",
"country": "Spain",
"media": {
"twitter": "@AnaMartinezDev",
"twitch": "@AnaMartinez",
"youtube": "@AnaMartinezVlogs",
"github": "@AnaMartinez",
"paypal": "@AnaMartinezPay",
"mc-name": "AnaM29"
}
}
]
}

You can also get it using the explorer by going to: Click Here

Add New User

POST / (router path)

Description: Adds a new user to the team.

Example URL:

https://api.adeptusstudio.com/team

Header:

  • x-api-key: The API Key to verify.
  • Content-Type: application/json

Request Body:

FieldTypeDescription
idStringUser ID
nameStringUser name
ageNumberUser age
emailStringUser email
bioStringBiography
positionStringPosition
has_micBooleanHas microphone
imageStringImage URL
countryStringCountry
mediaObjectMedia

Example Request Body:

{
"id": "12313",
"name": "Juan Perez",
"age": "25",
"email": "[email protected]",
"bio": "Backend Developer",
"position": "Backend Developer",
"has_mic": true,
"image": "https://cdn.modrinth.com/data/hTexWmdS/b5882166fc6114adf784ebc51e728af63494e233.png",
"country": "Spain",
"media": {
"twitter": "@juanperez",
"twitch": "@juanperez",
"youtube": "@juanperez",
"github": "@juanperez",
"paypal": "@juanperez",
"mc-name": "JuanP"
}
}

Response:

  • 201 Created with the new user details.
  • 500 Internal Server Error in case of an error saving the new user.

Update User

PUT /:id (router path)

Description: Updates the data of a specific user.

Example URL:

https://api.adeptusstudio.com/team/USER_ID_ON_DISCORD

Header:

  • x-api-key: The API Key to verify.
  • Content-Type: application/json

Route Parameters:

  • id: User ID to update.

Request Body: Fields to update.

Example Request Body:

{
"bio": "New biography",
"media": {
"twitter": "@newTwitter"
}
}

Response:

  • 200 OK with the updated user details.
  • 404 Not Found if the user does not exist.
  • 500 Internal Server Error in case of an error updating the user.

Delete User

DELETE /:id (router path)

Description: Deletes a specific user.

Example URL:

https://api.adeptusstudio.com/team/USER_ID_ON_DISCORD

**Header:

**

  • x-api-key: The API Key to verify.

Route Parameters:

  • id: User ID to delete.

Response:

  • 200 OK with a success message.
  • 404 Not Found if the user does not exist.
  • 500 Internal Server Error in case of an error deleting the user.

JavaScript Fetch Examples

Get List of Files

async function loadFileList(path) {
try {
const response = await fetch(`https://api.adeptusstudio.com/explorer?path=${path}`, {
headers: { 'x-api-key': apiKey }
});
const data = await response.json();
displayFileList(data);
} catch (error) {
console.error('Error:', error);
}
}

Delete File

function deleteFile(path) {
if (confirm('Are you sure you want to delete this file?')) {
fetch(`https://api.adeptusstudio.com/explorer/delete?path=${path}`, {
method: 'DELETE',
headers: { 'x-api-key': apiKey }
})
.then(response => response.json())
.then(data => {
console.log(data.message);
})
.catch(error => console.error('Error:', error));
}
}

Create New Cog

function createNewCog(cogName, cogCode) {
if (!cogName || !cogCode) {
alert('Please enter both the name and the cog code');
return;
}

fetch('https://api.adeptusstudio.com/create-cog', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': apiKey
},
body: JSON.stringify({ cogName, cogCode })
})
.then(response => response.json())
.then(data => {
console.log(data.message);
})
.catch(error => console.error('Error:', error));
}

Get File Content

async function loadFileContent(path) {
try {
const response = await fetch(`https://api.adeptusstudio.com/explorer/file?path=${path}`, {
headers: { 'x-api-key': apiKey }
});
const content = await response.text();
displayFileContent(path.split('/').pop(), content);
} catch (error) {
console.error('Error:', error);
}
}

Get List of Cogs

async function loadCogs() {
try {
const response = await fetch('https://api.adeptusstudio.com/cogs', {
headers: { 'x-api-key': apiKey }
});
const cogs = await response.json();
const cogNav = document.getElementById('cogNav');
cogNav.innerHTML = ''; // Clear existing content
cogs.cogs.forEach(cog => {
// Logic to add cogs to the navigation
});
} catch (error) {
console.error('Error:', error);
}
}

Perform Actions with Cogs

async function performCogAction(action, cog, parameter, data) {
try {
let response;
const url = `https://api.adeptusstudio.com/${cog}${parameter ? `/${parameter}` : ''}`;
const options = {
headers: { 'x-api-key': apiKey }
};

switch (action) {
case 'get':
response = await fetch(url, options);
break;
case 'getOne':
response = await fetch(url, options);
break;
case 'post':
response = await fetch(url, {
...options,
method: 'POST',
headers: { ...options.headers, 'Content-Type': 'application/json' },
body: JSON.stringify(data)
});
break;
case 'delete':
response = await fetch(url, {
...options,
method: 'DELETE'
});
break;
}
const result = await response.json();
console.log(result);
} catch (error) {
console.error('Error:', error);
}
}

Add Item

function addItem(item) {
fetch(`https://api.adeptusstudio.com/${currentCog}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': apiKey
},
body: JSON.stringify(item)
})
.then(response => response.json())
.then(data => {
console.log(data.message);
})
.catch(error => console.error('Error:', error));
}

Load Team Items

function loadTeamItems() {
fetch(`https://api.adeptusstudio.com/${currentCog}`, {
headers: { 'x-api-key': apiKey }
})
.then(response => response.json())
.then(data => {
displayItems(data);
})
.catch(error => console.error('Error:', error));
}

Update Item

function updateItem(id, updatedItem) {
fetch(`https://api.adeptusstudio.com/${currentCog}/${id}`, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
'x-api-key': apiKey
},
body: JSON.stringify(updatedItem)
})
.then(response => response.json())
.then(data => {
console.log(data.message);
})
.catch(error => console.error('Error:', error));
}

Delete Item

function deleteItem(id) {
fetch(`https://api.adeptusstudio.com/${currentCog}/${id}`, {
method: 'DELETE',
headers: { 'x-api-key': apiKey }
})
.then(response => response.json())
.then(data => {
console.log(data.message);
})
.catch(error => console.error('Error:', error));
}