---
title: "Ayrshare’s YouTube API to Upload Videos"
description: "Want to upload and share a video to YouTube via an API? Ayrshare's YouTube API integration allows you to upload and post a video a thumbnail."
canonical: https://www.ayrshare.com/blog/ayrshare-api-posting-videos-to-youtube/
lastModified: 2026-07-01
pageType: blog
---

# Ayrshare’s YouTube API to Upload Videos

Author: Ayrshare Team  
Published: 2021-02-24

> Want to upload and share a video to YouTube via an API? Ayrshare's YouTube API integration allows you to upload and post a video a thumbnail.

We’re pleased to announce [Aryshare](https://www.ayrshare.com)‘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](https://docs.ayrshare.com/rest-api/overview) or [Dashboard](https://app.ayrshare.com). And we’ve made it is simple as can be. Check out our [YouTube API docs](https://docs.ayrshare.com/rest-api/endpoints/post#youtube) 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](https://docs.ayrshare.com/rest-api/endpoints/post).

```javascript
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:

```javascript
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:

[▶ Watch: Ayrshare’s YouTube API to Upload Videos](https://www.youtube.com/watch?v=UkisNgVxubg)

## And That Isn’t All: YouTube Analytics

Don’t forget about [YouTube analytics](https://docs.ayrshare.com/rest-api/endpoints/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](mailto:contact@ayrshare.com).
