You can access the API using one of the following methods:
Include the Authorization header with your API key.
Include the apiKey as a query parameter in the URL.
Supported Request Formats
The API supports the following request formats:
form-data
json
x-www-form-urlencoded
Each request must include the appropriate header to be accepted.
Form Data Requests
Body
The request body should be a form-data object containing a file named file or data.
Response
The response JSON body takes the following shape:
{"id":3,"uuid":"f1ce38a5-4e05-456e-9e86-33c2f269fcdf","filename":"f1ce38a5-4e05-456e-9e86-33c2f269fcdf.jpg","original_filename":"xjss8mp8il3b1.jpg","mime_type":"image/jpeg","size":180585,// in bytes"hash":"63b89ee6f0b2e368d9823c5c0fc42b4ad080b42548c8d692516ea6a942ab612f","url":"https://fivermerr/files/images/f1ce38a5-4e05-456e-9e86-33c2f269fcdf.jpg","created_at":"2024-07-04T00:53:53.569154676+05:30","updated_at":"2024-07-04T00:53:53.569154745+05:30"}
Example with Node.js (with Axios)
constaxios=require('axios');constfs=require('fs');constFormData=require('form-data');// Load the image fileconstfilePath='/path/to/your/image.png'; // Replace with your file pathconstfile=fs.createReadStream(filePath);// Create a form data objectconstform=newFormData();form.append('file', file);// Make the POST requestaxios.post('https://api.fivemerr.com/v1/media/images', form, { headers: {...form.getHeaders(),'Authorization':'YOUR_API_KEY'// Replace with your API key }}).then(response => {console.log(response.data.url);}).catch(error => {console.error(error);});
Example with Python
import requests# Load the image filefile_path ='/mnt/data/image.png'# Replace with your file pathfiles ={'file':open(file_path, 'rb')}# Set the headersheaders ={'Authorization':'YOUR_API_KEY',# Replace with your API key'Content-Type':'multipart/form-data'}# Make the POST requestresponse = requests.post('https://api.fivemerr.com/v1/media/images', files=files, headers=headers)# Print the responseprint(response.json())
JSON Requests
Body
The request body should be a JSON string containing a key named file or data. Data should be encoded as base64 in the following format.
data:[<mediatype>][;base64],<data>
Example with Node.js (with Axios)
constaxios=require('axios');let data =JSON.stringify({"file":"data:image/png;base64,iVBORw0KGgoAAA=="});let config = { method:'post', maxBodyLength:Infinity, url:'https://api.fivemerr.com/v1/media/images', headers: { 'Content-Type':'application/json','Authorization':'β’β’β’β’β’β’' }, data : data};axios.request(config).then((response) => {console.log(JSON.stringify(response.data));}).catch((error) => {console.log(error);});
x-www-form-urlencoded Requests
Body
The request body should be x-www-form-urlencoded containing a key named file or data. Data should be encoded as base64 in the following format.
data:[<mediatype>][;base64],<data>
Example with Node.js (with Axios)
constaxios=require('axios');constqs=require('qs');let data =qs.stringify({'file':'data:image/png;base64,iVBORw0kJggg=='});let config = { method:'post', maxBodyLength:Infinity, url:'https://api.fivemerr.com/v1/media/images', headers: { 'Content-Type':'application/x-www-form-urlencoded','Authorization':'β’β’β’β’β’β’' }, data : data};axios.request(config).then((response) => {console.log(JSON.stringify(response.data));}).catch((error) => {console.log(error);});