Skip to main content

Uploading an image

If you wish to upload an image to the Upload API, you can do so by sending a POST request to the https://api.fivemanage.com/api/v2/image 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 Upload 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 with Axios

const axios = require('axios');
const fs = require('fs');

const apiKey = 'YOUR_API_TOKEN';
const url = 'https://api.fivemanage.com/api/v2/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
{
  "data": {
	// use this ID when you want to delete or get a file later
    "id": "7F9pGhN8qwErT1vx5aZk",
	// url might be r2.fivemanage.com as well
    "url": "https://i.fmfile.com/6E9pGhN8qwErT1vx5aZk/7F9pGhN8qwErT1vx5aZk.webp"
  },
  "status": "ok"
}

Deleting an image

When we want to delete an image, we can do so by sending a DELETE request to the https://fmapi.net/api/image/:id 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: 'https://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 is no way to upload files from Lua yet, but we are adding support for base64 uploads.
There are a few ways to upload an image to the Image API. The easiest way is to use Screenshot Basic.

Screenshot Basic

Using headers
exports['screenshot-basic']:requestScreenshotUpload('https://api.fivemanage.com/api/v2/image',
'file',
{
    headers = {
        Authorization = "YOUR_API_TOKEN"
    }
},
function(data)
    local resp = json.decode(data)
    if resp then
		-- the url is in resp.data.url	
        print(resp.data.url)
    end
end)
Using query parameters
exports['screenshot-basic']:requestScreenshotUpload('https://api.fivemanage.com/api/v2/image?apiKey=YOUR_API_TOKEN', 'file', function(data)
    local resp = json.decode(data)
    if resp then
        print(resp.data.url)
    end
end)