Getting URL of a Video (wix http request)

Hi,

I am trying to create a wix-http-request to expose data that I have in a collection for a mobile application (React Native). I managed to get the data following the documentation. However, I cannot get the URL from which a video is uploaded. The link that I get from request is

"video": "wix:video://v1/fed0c6_343e54dcec4b40d7a6af5c2c55c39460/02%20Program%20-%20Poses%20-%20Wild%20Thing.mp4#posterUri=fed0c6_343e54dcec4b40d7a6af5c2c55c39460f000.jpg&posterWidth=1920&posterHeight=1080"

According to the documentation, I can get the location from

wix:video://v1/<video_uri>/<filename>#posterUri=<poster_uri>&posterWidth=<width>&posterHeight=<height>

I know that for images, I can use https://static.wixstatic.com/media/, and then add the image uri

What should I add for videos? If I try https://static.wixstatic.com/media/<video_uri> it does not work

Any idea on how to retrieve the full URL?

hello my friend. I have solved this. i have written a wix function to expose your api, and convert the images, and hide hidden plus organize it and one special function to sort a specific database by decending numbers. like scores would be>. this is for my website. so you have to fill in the names of your databases, the name of your wix site(url) and the name of the databse you wanna sort by numbers, or delete that function :). hopem it helps. : CODE: import { ok, badRequest } from ‘wix-http-functions’;
import wixData from ‘wix-data’;

// Function to convert the Wix image URL to an external accessible URL
function convertWixImageUrl(wixImageUrl) {
if (wixImageUrl.startsWith(‘wix:image://v1/’)) {
let convertedUrl = wixImageUrl.replace(‘wix:image://v1/’, ‘https://static.wixstatic.com/media/’);
const match = convertedUrl.match(//([^/]+)$/);
if (match && match[1]) {
convertedUrl = convertedUrl.replace(match[0], ‘’);
}
return convertedUrl;
} else {
return wixImageUrl;
}
}

// Function to prepend base URL to links that start with “/”
function prependBaseUrlIfNeeded(value) {
if (typeof value === ‘string’ && value.startsWith(‘/’)) {
return “https://replaceWithYourWebSitel.com” + value;
}
return value;
}

// Function to recursively convert Wix image URLs in an object
function convertWixImageUrlsInObject(obj) {
for (let prop in obj) {
if (typeof obj[prop] === ‘string’) {
obj[prop] = convertWixImageUrl(obj[prop]);
obj[prop] = prependBaseUrlIfNeeded(obj[prop]);

  // Check if the property starts with "link-"
  if (prop.startsWith('link-')) {
    // Split the property by hyphen and remove hyphens from the second part
    const parts = prop.split('-');
    parts.splice(1, 1); // Remove the hyphenated part
    obj[parts.join('')] = obj[prop]; // Create the new property without hyphens
    delete obj[prop]; // Delete the old property
  }
} else if (typeof obj[prop] === 'object') {
  convertWixImageUrlsInObject(obj[prop]);
}

}
}

// Making a common open API for your data collections in Wix Code
let whiteList = [‘databseName1’, ‘databaseName2’, ‘databasNameect’];

export function get_api(request) {
const response = {
headers: {
‘Content-Type’: ‘application/json’
}
};

let datacollection = request.path[0];

if (whiteList.includes(datacollection)) {
return wixData.query(datacollection)
.limit(1000)
.ascending(‘title’)
.find()
.then((apiResults) => {
if (apiResults.totalCount > 0) {

// Sort data by “title1” field’s number value for “replacewithScoreDatabase” collection
if (datacollection === ‘VPinOwners’) {
apiResults.items.sort((a, b) => {
const title1A = parseFloat(a.title1);
const title1B = parseFloat(b.title1);
return title1B - title1A; // Sort in descending order
});
}

      // Convert Wix image URLs and prepend base URL to links starting with "/"
      apiResults.items.forEach((item) => {
        convertWixImageUrlsInObject(item);
      });

      response.body = {
        items: apiResults.items
      };
      return ok(response);
    }

    response.body = {
      items: "No items found in the collection."
    };
    return ok(response);
  });

}

response.body = {
error: “Data Collection is not allowed to be used through this API.”
};
return badRequest(response);
}