Programmable Media

Python quick start

Last updated: Oct-31-2023

This quick start is intended to let you quickly try using several common Cloudinary features. It doesn't necessarily employ coding best practices and the code you create here isn't intended for production.

You can perform this quick start in a code sandbox or in a clean project in the dev environment of your choice.

You can also view the completed code of this quick start in a GitHub repo and code explorer.

Tip
If you aren't familiar with Cloudinary, you may want to first take a look at the Developer get started guide for a high-level overview of integrating Cloudinary into your code, and an introduction to the main concepts.

You may also find our Glossary helpful to understand Cloudinary-specific terminology.

Prerequisites

To perform this quick start, you'll need:

1. Set up and configure the SDK

In a terminal in your Python3 environment, run the following code:

In your project, create a file called .env containing your API environment variable from your product environment credentials:

.env

Important
  • When writing your own applications, follow your organization's policy on storing secrets and don't expose your API secret.
  • Don't store your .env under version control for maximum security.

In your project, create a new file called my_file.py. Copy and paste the following into this file:

my_file.py

2. Upload an image

Copy and paste this into my_file.py:

my_file.py (continued)

3. Get and use details of the image

Copy and paste this into my_file.py:

my_file.py (continued)

4. Transform the image

Copy and paste this into my_file.py:

my_file.py (continued)

5. Run your code

Copy and paste this into my_file.py:

my_file.py (continued)

In the terminal, run the following command:

The following original image is uploaded to Cloudinary, tagged appropriately and accessible via the URL shown below.

The transformed version of the image is accessible via the URL shown below.

Original image Original image
http://res.cloudinary.com/&ltcloud-name&gt/image/
upload/v1/quickstart_butterfly
Transformed image Transformed image
http://res.cloudinary.com/&ltcloud-name&gt
/image/upload/e_sepia
r_max/v1/quickstart_butterfly

View the completed code

See the code above in action using this code playground.

Note
If you want to see the output:
  • Click Remix to Edit.
  • Copy your API Environment variable value (i.e., only the portion after the equal sign, cloudinary://<api_key:api_secret@cloud_name).
  • Paste it into the Glitch .env file as the Variable Value for CLOUDINARY_URL.
  • Click Logs at the bottom of the screen.

This code is also available in GitHub

Next steps

  • Learn more about the Python SDK by visiting the other pages in this SDK guide.
  • Get comprehensive details about Cloudinary features and capabilities:

✔️ Feedback sent!

Rate this page: