Uploading an image
If you wish to upload an image to the Image API, you can do so by sending a POST request to the https://api.fivemanage.com/api/image (opens in a new tab) endpoint.
General
Headers
You need to send an Authorization
header with your API key.
Query parameters
You can also send your API key as a query parameter ?apiKey=
. This is useful if you are using the Image API in a browser.
Body
The body of the request should be a form-data object with a file named file
or image
.
Uploading an image
const axios = require('axios');
const fs = require('fs');
const apiKey = 'YOUR_API_TOKEN';
const url = 'https://api.fivemanage.com/api/image';
const formData = new FormData();
formData.append('file', fs.createReadStream('image.png'));
// Optional metadata field (JSON string)
formData.append("metadata", JSON.stringify({
name: 'My image',
description: 'This is my image',
}));
axios.post(url, formData, {
headers: {
Authorization: apiKey,
}
}).then(res => {
console.log(res.data.url);
}).catch(err => {
console.error(err);
});
Response
Success
{
"url": "https://r2.fivemanage.com/images/1234567890",
"id": "0987654321"
}
Deleting an image
When we want to delete an image, we can do so by sending a DELETE request to the https://api.fivemanage.com/api/image/:id (opens in a new tab) endpoint.
The :id
parameter should be the ID of the image you want to delete. You can get the ID from the response when you upload an image (see above).
import axios from "axios";
const options = {
method: 'DELETE',
url: 'http://api.fivemanage.com/api/image/delete/0987654321',
headers: {
Authorization: 'YOUR_API_TOKEN'
}
};
axios.request(options).then(function (response) {
console.log(response.data);
}).catch(function (error) {
console.error(error);
});
Games & Mods
FiveM
There are a few ways to upload an image to the Image API. The easiest way is to use Screenshot Basic (opens in a new tab).
Screenshot Basic
Using headers
exports['screenshot-basic']:requestScreenshotUpload('https://api.fivemanage.com/api/image',
'file',
{
headers = {
Authorization = "YOUR_API_TOKEN"
}
},
function(data)
local resp = json.decode(data)
if resp then
print(resp.url)
end
end)
Using query parameters
exports['screenshot-basic']:requestScreenshotUpload('https://api.fivemanage.com/api/image?apiKey=YOUR_API_TOKEN', 'file', function(data)
local resp = json.decode(data)
if resp then
print(resp.url)
end
end)