Track conversion is the simplest API available on Orchdio. To convert a track, you make a post request to the convert endpoint, with the url you're trying to convert as the value.
Some platforms (like Deezer web app) allow you copy short URL when sharing. We try to handle this on our end but for better user experience in your app, it is recommended you detect shortlink URLs and extract the real link.
There are various url preview libraries depending on the language or framework you are building with. You can use if you are using JavaScript and we have written for those using Rust.
An example on how to do this is show below, in JavaScript.
// check if the "link" being converted is a shorturl. Then preview
// and log the real link if its a short link.
// It is assumed that your function is an async function
// rest of your code here
let isShortLink = ["deezer.page.link", "link.tospotify.com"].some((shortLink) => link.includes(shortLink));
if (isShortLink) {
const preview = await getLinkPreview(url, {
resolveDNSHost: async (url) => {
const { hostname } = new URL(url);
dns.lookup(hostname, (err, address) => {
if (err) {
console.log(err);
} else {
return address;
}
})
},
followRedirects: "follow"
});
const { url } = preview
console.log("Real link to be converted is: %s", url)
}
When converting to a track, you must specify the target_platform in the request body. You can pass all in order to return results from all platforms you've specified credentials for.