constaxios=require('axios');constfs=require('fs');constFormData=require('form-data');// Load the image fileconstfilePath='/path/to/your/video.mp4'; // 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/videos', 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/video.mp4'# 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/videos', 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/videos', 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/videos', 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);});