Ayrshare’s YouTube API to Upload Videos
We’re pleased to announce Aryshare‘s Social Media API now support uploading and posting videos to a YouTube channel.
The YouTube API upload video integration allows you or your users to easily upload and share a video, and even set a thumbnail, playlist, visibility to share a private, public or unlisted video, and the video description.
The video can be directly uploaded to YouTube either with our API or Dashboard. And we’ve made it is simple as can be. Check out our YouTube API docs for more information and examples.
YouTube API Example
Upload a Video and Post
A JavaScript (Node.js) example is shown below. Also, check out other language examples.
const fetch = require("node-fetch");
const API_KEY = "API_KEY";
fetch("https://app.ayrshare.com/api/post", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${API_KEY}`
},
body: JSON.stringify({
title: "YouTube Post Title",
post: "YouTube Description",
platforms: ["youtube"],
mediaUrls: ["https://videourl"],
youTubeVisibility: "private"
}),
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
In this example, we have specified the YouTube video file as a URL, video title, video description (post field), and the visibility to share as private video. This JSON is posted to the API endpoint https://app.ayrshare.com/api/post.
In the JSON response, you’ll get the status (success or error) and the YouTube uploaded video URL.
Delete a YouTube Video
If you don’t want the video any more, simply delete it via the API:
const fetch = require("node-fetch");
const API_KEY = "API_KEY";
const id = "Post ID";
fetch("https://app.ayrshare.com/api/delete", {
method: "DELETE",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${API_KEY}`
},
body: JSON.stringify({ id }),
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
Watch Uploading a Video to YouTube with the API
Here is a short video on how to link your YouTube account and post via the API:
And That Isn’t All: YouTube Analytics
Don’t forget about YouTube analytics so you can see how many views and likes your video got. A great insight for your users so they understand the video engagement.
Let us know what you think or if you have questions.