The simple way of using Imgur.

Overview

PyImgur

The simple way of using Imgur.

You can upload images, download images, read comments, update your albums, message people and more. In fact, you can do almost everything via PyImgur that you can via the webend.

Installation

The recommended way to install is via pip

$ pip install pyimgur

Getting Started

Before we can start using PyImgur, we need to register our application with Imgur. This way, Imgur can see what each application is doing on their site. Go to https://api.imgur.com/oauth2/addclient to register your client. Note that you can't use an application registration for the old v2 version of the Imgur API, which was depreciated December 2012.

When we registered our application we got a client_id and a client_secret. The client_secret is used for authenticating as a user, if we just need access to public or anonymous resources, then we can leave it out. For our first example we're going to get some information about an image already uploaded to image:

import pyimgur
CLIENT_ID = "Your_applications_client_id"
im = pyimgur.Imgur(CLIENT_ID)
image = im.get_image('S1jmapR')
print(image.title) # Cat Ying & Yang
print(image.link) # http://imgur.com/S1jmapR.jpg

The Imgur object keeps the authentication information, changes authentication and is the common way to get objects from Imgur.

Uploading an Image

Let's use another example to show how to upload an image:

import pyimgur

CLIENT_ID = "Your_applications_client_id"
PATH = "A Filepath to an image on your computer"

im = pyimgur.Imgur(CLIENT_ID)
uploaded_image = im.upload_image(PATH, title="Uploaded with PyImgur")
print(uploaded_image.title)
print(uploaded_image.link)
print(uploaded_image.size)
print(uploaded_image.type)

Some methods here one or more arguments with the default value None. For methods modifying existing objects, this mean to keep the already existing value. For methods not modifying existing objects, this mean to use the Imgur default.

Lazy objects

To reduce the load on Imgur, PyImgur only requests the data it needs. This means each object has the attribute _has_fetched which if True` has fetched all the data it can, if False it can fetch more information.

Whenever we request an attribute that hasn't been loaded the newest information will be requested from Imgur and all the object attributes will be updated to the newest values. We can also use the method refresh() to force a call to Imgur, that will update the object with the latest values:

import pyimgur
CLIENT_ID = "Your_applications_client_id"
im = pyimgur.Imgur(CLIENT_ID)
gallery_image = im.get_gallery_image('JiAaT')
author = gallery_image.author
print(author._has_fetched) # False ie. it's a lazily loaded object
print(author.reputation)
print(author._has_fetched) # True ie. all values have now been retrieved.

Introspection

Remember that as usual you can use the dir, vars and help builtin functions to introspect objects to learn more about them and how they work.

Mashape API

Imgur supports commercial use via Mashape, which uses a different endpoint and some additional authentication. You can enable this easily by providing your Mashape key on initialization of the Imgur object:

import pyimgur
CLIENT_ID = "Your_applications_client_id"
MASHAPE_KEY = "Your_mashape_api_key"
im = pyimgur.Imgur(CLIENT_ID, mashape_key=MASHAPE_KEY)

More information on Mashape's API and Pricing can be found on the Mashape website.

Support

If you find an bug, have any questions about how to use PyImgur or have suggestions for improvements then feel free to file an issue on the Github project page.

Documentation

PyImgur's full documentation is located on ReadTheDocs.

License

All of the code contained here is licensed by the GNU GPLv3.

Owner
Andreas Damgaard Pedersen
Andreas Damgaard Pedersen
Represents a Lavalink client used to manage nodes and connections.

lavaplayer Represents a Lavalink client used to manage nodes and connections. setup pip install lavaplayer setup lavalink you need to java 11* LTS or

HazemMeqdad 37 Nov 21, 2022
Discord Account Generator that will create Account with hCaptcha bypass. Using socks4 proxies

Account-Generator [!] This was made for education. Please use socks4 proxies for nice experiences. [!] Please install these modules - "pip3 install ht

RyanzSantos 10 Feb 23, 2022
A simple fun discord bot using discord.py that can post memes

A simple fun discord bot using discord.py * * Commands $commands - to see all commands $meme - for a random meme from the internet $cry - to make the

Dice Flip 2 Dec 20, 2021
TFT Bot that automatically surrenders and allows finishing TFT Passes easily.

Image Based TFT Bot TFT Bot that automatically surrenders and allows finishing TFT Passes easily. Please read full file! You can check new releases he

1 Feb 06, 2022
LHXP・Official "LH - Cyber Security" Discord Leveling-Bot

LHXP・Official "LH - Cyber Security" Discord Leveling-Bot Based on nsde/NOVΛLIX Feature Overview /clear @user Requires admin permission Purges all XP

Felix・onlix 2 Mar 09, 2022
ESOLinuxAddonManager - Very simple addon manager for Elder Scrolls Online running on Linux.

ESOLinuxAddonManager Very simple addon manager for Elder Scrolls Online running on Linux. Well, more a downloader for now. Currently it's quite ugly b

Akseli 25 Aug 28, 2022
A Wrapper for ScarletAPI

ScarletAPI A Wrapper for ScarletAPI still a work in progress Docs these are the

Amashi 0 Mar 24, 2022
OpenQuake's Engine for Seismic Hazard and Risk Analysis

OpenQuake Engine The OpenQuake Engine is an open source application that allows users to compute seismic hazard and seismic risk of earthquakes on a g

Global Earthquake Model 281 Dec 21, 2022
Man-Userbot adalah userbot Telegram modular yang berjalan di Python3 dengan database sqlalchemy

Man-Userbot Telegram Man-Userbot adalah userbot Telegram modular yang berjalan di Python3 dengan database sqlalchemy. Berbasis Paperplane dan ProjectB

DzLyz 1 Feb 12, 2022
buys ethereum based on graphics card moving average price on ebay

ebay_trades buys ethereum based on graphics card moving average price on ebay Built as a meme, this application will scrape the first 3 pages of ebay

ConnorCreate 41 Jan 05, 2023
It's a simple python script to take backup of directories (compressing) then the same to move your mentioned S3 bucket with the help of AWS IAM User.

Directory Backup Moved to S3 (Pyscript) Description Here it's a python script that needs to use this script simply create a directory backup and moved

Yousaf K Hamza 3 Mar 04, 2022
Housing Price Prediction Using Machine Learning.

HOUSING PRICE PREDICTION USING MACHINE LEARNING DESCRIPTION Housing Price Prediction Using Machine Learning is to predict the data of housings. Here I

Shreya Shree Padhi 1 Aug 03, 2022
Process your transactions from etherscan (and other forks) into excel file for easier manipulation.

DEGEN TRACKER Read first This is my first Python open source project and it is very likely full of bad practices and security issues. You should not u

1 Oct 13, 2022
Simple-nft-tutorial - A simple tutorial on making nft/memecoins on algorand

nft/memecoin Tutorial on Algorand Let's make a simple NFT/memecoin on the Algora

2 Feb 05, 2022
Telegram forwarder

Telegram Forwarder Quick Start This application using docker, docker-compose to run. So I suppose that you can install these two things. Prepare essen

10 Dec 20, 2022
Python script to download WAX transactions

WAXtax Python script to download WAX transactions WAXtax uses the CoinGecko API and the WAX Blockchain History API to download csvs for each account y

SixPM Software 11 Oct 09, 2022
A Discord bot that enables using breakout rooms on a server

Discord Breakout Room Bot This bot enables you to use breakout rooms on your Discord server! Note This bot was thrown together within a few hours, so

Till Müller 2 Nov 23, 2021
Ap lokit lokit

🎵 FANDA PROJECT 🎵 HAI AKU FANDA! Requirements 📝 FFmpeg NodeJS nodesource.com Python 3.8 or higher PyTgCalls MongoDB Get STRING_SESSION from below:

Fatur 2 Nov 18, 2021
Huan Xu 1.6k Jan 04, 2023
Host your Python Discord Bot 24/7 for free. POC

🐉 Pandore 🐉 The easiest and fastest way to host your Python3 Discord Bot 24/7 for free! 📚 Documentation 📚 If you encounter any problem while using

Billy 73 Jan 02, 2023