Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
A Python SDK for the Imgur API.
The package is supposed to be in strict accordance with the Imgur's documentation, i.e. description for any endpoint implemented in the SDK can also be found there.
The package does not have any third-party dependencies; it requires only Python 3.7+.
Using pip:
$ pip install pyimgurapi
client_id
and client_secret
.https://api.imgur.com/oauth2/authorize?client_id=<your_client_id>&response_type=token
(replace <your_client_id>
with the actual ID)refresh_token
value from the URL field.from pyimgurapi import ImgurAPI
api = ImgurAPI(
refresh_token="<refresh_token>",
client_id="<client_id>",
client_secret="<client_secret>",
)
api.auth()
Getting info about an image:
from pyimgurapi import ImgurAPI
api = ImgurAPI(
refresh_token="<refresh_token>",
client_id="<client_id>",
client_secret="<client_secret>",
)
api.auth()
meme_image = api.image.get_image("6yHmlwT")
Then you can access attributes of the response using a dot-notation:
print(meme_image.data.link)
or using a subscript-notation:
print(meme_image["data"]["link"])
Uploading a new image:
from pyimgurapi import ImgurAPI
api = ImgurAPI(
refresh_token="<refresh_token>",
client_id="<client_id>",
client_secret="<client_secret>",
)
api.auth()
filename = "cat1.jpg"
with open(filename, 'rb') as f:
new_image = api.image.upload(
f,
filename,
title="New image", # optional
description="Absolutely new image" # optional
)
Then you can access attributes of the new image as well:
print(new_image.data.link)
See the contributing guidelines.
FAQs
A Python SDK for the Imgur API.
We found that pyimgurapi demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.