media

Upload and manage your images and videos. Starter, Premium or Business Plan required.

Manage your image and video gallery by uploading and retrieving images/videos. Response will be a reference URL.

post
Upload an image or video

https://app.ayrshare.com/api/upload
This endpoint allows you to upload a file or an image or video to include in your post. Returned will be the URL to the image that can be used in a post or HTML page. You can also directly include an image or video hosted at a URL with the media_urls parameter in the /post endpoint.
Request
Response
Request
Headers
Authorization
required
string
Format: Authorization: Bearer API_KEY. See Overview for more information.
Query Parameters
file
required
string
The image or video as a Base64 encoded string: Data URI - data:content/type;base64 Example encoding with Output Format Data URI: Image: https://base64.guru/converter/encode/image Video: https://base64.guru/converter/encode/video Note 1: Max size for video is 10 MB and images 5 MB. Note 2: The /post endpoint accepts larger files via an external URL with the media_urls parameter.
fileName
optional
string
The name of the file for later reference.
description
optional
string
A description for your reference.
Response
200: OK
Return the URL of the uploaded image, id of the image, and metadata provided.
{
"id": "1167335b-6c37-4fc6-ab8a-044e0005d335-jpeg",
"url": "https://images.ayrshare.com/q3Ls85VTsrbODnGIJHpy7PaHWwA3/1167335b-6c37-4fc6-ab8a-044ed885d-jpeg.jpeg",
"fileName": "fun.jpg",
"description": "good times"
}

Request Example

cURL
Node JS
Python
PHP
cURL
curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-d '{"file": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQ...", "fileName": "test.png", "description": "best image"}' \
-X POST https://app.ayrshare.com/api/upload
Node JS
const fetch = require("node-fetch");
const API_KEY = "API_KEY";
const base64 = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQ...";
fetch("https://app.ayrshare.com/api/upload", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${API_KEY}`
},
body: JSON.stringify({
file: base64,
fileName: "test.png",
description: "best image"
}),
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
Python
import requests
payload = {'file': 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQ...',
'fileName': "test.png",
'description': "best image"}
headers = {'Content-Type': 'application/json',
'Authorization': 'Bearer API_KEY'}
r = requests.post('https://app.ayrshare.com/api/upload',
json=payload,
headers=headers)
print(r.json())
PHP
<?php
require 'vendor/autoload.php'; // Composer auto-loader
$client = new GuzzleHttp\Client();
$res = $client->request(
'POST',
'https://app.ayrshare.com/api/upload',
[
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer API_KEY'
],
'file' => 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQ...',
'fileName' => "test.png",
'description' => "best image"
]
);
echo json_encode(json_decode($res->getBody()), JSON_PRETTY_PRINT);
https://app.ayrshare.com/api/media
Retrieve all the images uploaded to the image gallery.
Request
Response
Request
Headers
Authorization
required
string
Format: Authorization: Bearer [API Key] See Overview for more information.
Response
200: OK
Returns an array of images in the image gallery.
[
{
"id": "5553a26a-cffb-4a31-bd89-dee296d35648-jpeg",
"timeCreated": "2020-07-30T20:23:49.774Z",
"size": "223340",
"url": "https://images.ayrshare.com/LW8kx9Q5smXeJl5CujF7DxFAF1q1/5553a26a-cffb-4a31-bd89-dee296d35648-jpeg.jpeg",
"fileName": "test1.jpeg",
"description": "Test1"
},
{
"id": "93383cc7-7a15-4d16-a5fa-fdda1f9bebe2-jpeg",
"timeCreated": "2020-07-30T20:24:57.421Z",
"size": "223340",
"url": "https://images.ayrshare.com/LW8kx9Q5smXeJl5CujF7DxFAF1q1/93383cc7-7a15-4d16-a5fa-fdda1f9bebe2-jpeg.jpeg",
"fileName": "test2.jpeg",
"description": "Test2"
}
]

Request Header

cURL
Node JS
Python
PHP
C#
cURL
curl \
-H "Authorization: Bearer [API Key]" \
-X GET https://app.ayrshare.com/api/media
Node JS
const fetch = require("node-fetch");
const API_KEY = "Your API Key";
fetch("https://app.ayrshare.com/api/media", {
method: "GET",
headers: {
"Authorization": `Bearer ${API_KEY}`
}
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
Python
import requests
headers = {'Authorization': 'Bearer [API_KEY]'}
r = requests.get('https://app.ayrshare.com/api/media', headers=headers)
print(r.json())
PHP
<?php
require 'vendor/autoload.php'; // Composer auto-loader
$client = new GuzzleHttp\Client();
$res = $client->request(
'GET',
'https://app.ayrshare.com/api/media',
[
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer API_KEY'
]
]
);
echo json_encode(json_decode($res->getBody()), JSON_PRETTY_PRINT);
C#
using System;
using System.Net;
using System.IO;
namespace MediaGETRequest_charp
{
class Media
{
static void Main(string[] args)
{
string API_KEY = "API_KEY";
string url = "https://app.ayrshare.com/api/media";
var httpWebRequest = WebRequest.CreateHttp(url);
httpWebRequest.ContentType = "application/json";
httpWebRequest.Headers.Add("Authorization", "Bearer " + API_KEY);
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
var response = streamReader.ReadToEnd();
Console.WriteLine(response);
}
}
}
}