in this tutorial, We’ll upload an mp4 video using imgur api. we will show you how to upload videos to Imgur via API and get video links from Imgur API using Python.
The Imgur API provides a programmatic approach to upload and manage images/videos on the Imgur server. The Imgur API is a REST API service that takes HTTP queries and provides JSON replies. You can integrate the Imgur API using any programming language.
Also checkout other related tutorials,
Each request must be authorized and Client ID is required to be passed with an authorization header in the Imgur API request.
'Authorization: Client-ID imgur-app-client-id'
Imgur is an internet platform for sharing and hosting images and videos. Without hosting the photographs on your server, you can share them online using Imgur.
Hosting the image on Imgur is the ideal option to use it without hosting it on the server if your online application has the ability to upload images and you want to maximize server space. The image files can be posted to Imgur and displayed on the website using an Imgur image link.
We’ll use /upload
API that will help to upload videos.
The api:
https://api.imgur.com/3/upload Method : POST
You need to register your application and generate the client ID. All HTTP requests for uploading images to Imgur must include the client_id in the authorization header and this would also let you upload images anonymously without the image being tied to your personal Imgur account.
You need to follow the below steps to authenticate :
https://api.imgur.com/oauth2/addclient
https://imgur.com/account/settings/apps
).Source code to upload a video using API
import requests url = "https://api.imgur.com/3/upload" payload = {'album': 'album_id', 'type': 'file', 'disable_audio': '0'} files = [ ('video', open('/path/to/Video.mp4','rb')) ] headers = { 'Authorization': 'Bearer BEARERTOKENHERE' } response = requests.request("POST", url, headers=headers, data = payload, files = files) print(response.text.encode('utf8'))
The above code will uploads the video successfully. Something to note though, I have not figured out how to make the upload tied to my account, or within a specific album. It seems to be ignoring the album_id field.
You can get more details from imgur Api
This tutorial helps integrate a PHP SDK with Laravel. We'll install aws-php-sdk into laravel application and access all aws services… Read More
in this quick PHP tutorial, We'll discuss php_eol with examples. PHP_EOL is a predefined constant in PHP and represents an… Read More
This Laravel tutorial helps to understand table Relationships using Elequonte ORM. We'll explore laravel table Relationships usage and best practices… Read More
We'll explore different join methods of Laravel eloquent with examples. The join helps to fetch the data from multiple database… Read More
in this Laravel tutorial, We'll explore valet, which is a development environment for macOS minimalists. It's a lightweight Laravel development… Read More
I'll go through how to use soft delete in Laravel 10 in this post. The soft deletes are a method… Read More
View Comments
I wanted to upload a video to imgur using the api and then get the link of where that video gets uploaded. Could you please guide on how to do that?
You ll get url in api response