Get Started
To use cobalt-kit, you need to have access to a Cobalt instance API.
WARNING
Hosted API instances (such as api.cobalt.tools
) use bot protection and are not intended to be used in other projects without explicit permission. If you want to access the Cobalt API reliably, you should host your own instance or ask an instance owner for access.
Installation
- Run this command on a terminal.
$ npm add cobalt-kit
$ pnpm add cobalt-kit
$ yarn add cobalt-kit
$ bun add cobalt-kit
You're ready to use cobalt-kit.
Read the documentation to learn more about how to use it.
INFO
If you have any trouble understanding the documentation or find any mistake, please reach out!
Example
You can use and modify this example to help you get started.
INFO
This example will not work as the instance
and auth
provided are not valid. Please modify these properties to match your credentials. Learn more about Cobalt options.
import { Cobalt } from 'cobalt-kit';
let cobalt = new Cobalt({
instance: 'https://cobalt.example.org/',
auth: {
scheme: 'Api-Key',
token: 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'
}
});
cobalt.download('https://www.youtube.com/watch?v=VUFr92i5jkA').then(res=>{
if(res.status == 'tunnel' || res.status == 'redirect'){
console.log(res.url);
}
if(res.status == 'picker'){
for(let item of res.picker){
console.log(item.url);
}
}
if(res.status == 'error'){
console.error(res.error.code);
}
});