A simple Python API wrapper for Cloudflare Stream's API.

Overview

python-cloudflare-stream

A basic Python API wrapper for working with Cloudflare Stream.

Arbington.com started off using Cloudflare Stream. We used their API very heavily and pulled out our code into a simple client for others to use. It's not perfect, nor is it close to being complete. But it's a good start for anyone who wishes to contribute!

Installation

pip install python-cloudflare-stream

Setup

You will need a Cloudflare account with Stream minutes added. We recommend starting small with a $5 subscription just to get your feet wet.

Once you have your Cloudflare Stream subscription you'll need:

  • Your Account ID, which you can find in your Cloudflare Dashboard.
  • Your email address you used for Cloudflare
  • Your API key
  • Then run:
from python_cloudflare_stream.client import StreamClient

keys = StreamClient.create_signing_keys()
print(keys)

That will give the PEM key you will need and the "signing token". Save these as they are only displayed once.

Understanding Cloudflare Stream

Stream is a bit different from other platforms. It's very basic, fast, reliable and moderately priced.

Everytime you upload a video, the video receives a "UID". You'll want to store this UID as it's the only way to refer to a video through their API.

Here is some example code to get you started:

from python_cloudflare_stream.client import StreamClient

keys = StreamClient.create_signing_keys('your-cloudflare-account-id', '[email protected]', 'your-api-key')  # Gives you your PEM and signing_token (called an "id") if you don't have that already. These are only displayed once per API call and aren't shown when listing your keys

# Store these somewhere safe.
signing_token = keys['result']['id']
pem = keys['result']['pem']

# Init the client
client = StreamClient(
    auth_email='[email protected]',
    auth_api_key='qwertyqwertyqwertyqwertyqwertyqwerty',
    account_id='asdf1asdf2asdf3asdf4asdf5',
    pem='LS0TEASRASDASDa-VERY-long-string-here=',
    signing_token='qwertyqwertyqwertyqwertyqwerty',
)

# Sample download URL
download_url = 'https://yourwebsite.com/video.mp4'
# Tell Cloudflare to download the sample download URL from above
video_uid, all_data_dict = client.pull_from_url(download_url, 'Test video', require_signed_url=True, watermark_uid=None)

# Get details about a specific video from its video_uid
data = client.get_video(video_uid)

# Get the total minutes in your account, and the total remaining minutes
client.get_total_storage_minutes()
client.get_remaining_cloudflare_minutes()

# Create a download URL from Cloudflare. Wait until its ready, or return a URL that can be used sometime in the future.
download_url = client.get_download_url(video_uid, wait_until_ready=True)

# Delete a video
deleted = client.delete_video(video_uid)

# List up to 1000 videos at once
videos = client.get_all_videos()

Contributing

Happy to accept contributions of any size!

You might also like...
A simple Python wrapper for the Amazon.com Product Advertising API β›Ί

Amazon Simple Product API A simple Python wrapper for the Amazon.com Product Advertising API. Features An object oriented interface to Amazon products

A simple API wrapper for Discord written in Python.

AIOCord This project is work in progress not for production use A simple asynchronous API wrapper around Discord API written in Python. Inspiration Th

Simple VK API wrapper for Python

VK Admier: documentation VK Admier is simple VK API wrapper for community bot development. Authorization You should create bot object from Client clas

Python API wrapper around Trello's API

A wrapper around the Trello API written in Python. Each Trello object is represented by a corresponding Python object. The attributes of these objects

Async ready API wrapper for Revolt API written in Python.

Mutiny Async ready API wrapper for Revolt API written in Python. Installation Python 3.9 or higher is required To install the library, you can just ru

A Python API wrapper for the Twitter API!

PyTweet PyTweet is an api wrapper made for twitter using twitter's api version 2! Installation Windows py3 -m pip install PyTweet Linux python -m pip

Python API wrapper library for Convex Value API

convex-value-python Python API wrapper library for Convex Value API. Further Links: Convex Value homepage @ConvexValue on Twitter JB on Twitter Authen

This an API wrapper library for the OpenSea API written in Python 3.

OpenSea NFT API Python 3 wrapper This an API wrapper library for the OpenSea API written in Python 3. The library provides a simplified interface to f

YARSAW is an Async Python API Wrapper for the Random Stuff API.

Yet Another Random Stuff API Wrapper - YARSAW YARSAW is an Async Python API Wrapper for the Random Stuff API. This module makes it simpler for you to

Comments
  • Error 10009 when trying to get signing token.

    Error 10009 when trying to get signing token.

    Firstly, this is a great project and has saved me lots of time and effort. However, since last night, I have been getting errors, most commonly Error 10009 "Forbidden" when trying to create the signing token.

    The JSON reply is as follows: {'result': None, 'success': False, 'errors': [{'code': 10009, 'message': 'Forbidden'}], 'messages': None}

    I know this is more CloudFlare related than an issue with this project, but I was wondering if you had come across this issue before?

    Thanks.

    opened by LoneWalkerWolf 0
  • Hi! Scoped Token instead of API Key?

    Hi! Scoped Token instead of API Key?

    Hi, thanks for the hard work, this module has saved me quite a bit of dev time.

    Is it possible to used a Cloudflare Scoped Token, rather than the full-blown API key?

    opened by mevans-pai 0
Owner
Arbington
Learn anything from anyone at any time.
Arbington
DDoS Script (DDoS Panel) with Multiple Bypass ( Cloudflare UAM,CAPTCHA,BFM,NOSEC / DDoS Guard / Google Shield / V Shield / Amazon / etc.. )

KARMA DDoS DDoS Script (DDoS Panel) with Multiple Bypass ( Cloudflare UAM,CAPTCHA,BFM,NOSEC / DDoS Guard / Google Shield / V Shield / Amazon / etc.. )

Hyuk 256 Jan 2, 2023
πŸš€ An asynchronous python API wrapper meant to replace discord.py - Snappy discord api wrapper written with aiohttp & websockets

Pincer An asynchronous python API wrapper meant to replace discord.py ❗ The package is currently within the planning phase ?? Links |Join the discord

Pincer 125 Dec 26, 2022
Anime Streams Scrapper for Telegram Publicly Available for everyone to use

AniRocks Project Structure: ╭─ bot β”œβ”€β”€β”€β”€ plugins: directory stored all the plugins β”œβ”€β”€β”€β”€ utils: a directory of Utilities to help bot Client to create

ポキ 11 Oct 28, 2022
Automatically gets clips from twitch streams and uploads them to a YouTube channel.

Twitch Stream Highlights to YT Automatic Uploader (AutoBot Clipper) This script can be used to automatically extract highlights (or clips) from a twit

Teja Swaroop 57 Dec 12, 2022
Aws-lambda-requests-wrapper - Request/Response wrapper for AWS Lambda with API Gateway

AWS Lambda Requests Wrapper Request/Response wrapper for AWS Lambda with API Gat

null 1 May 20, 2022
PRAW, an acronym for "Python Reddit API Wrapper", is a python package that allows for simple access to Reddit's API.

PRAW: The Python Reddit API Wrapper PRAW, an acronym for "Python Reddit API Wrapper", is a Python package that allows for simple access to Reddit's AP

Python Reddit API Wrapper Development 3k Dec 29, 2022
PRAW, an acronym for "Python Reddit API Wrapper", is a python package that allows for simple access to Reddit's API.

PRAW: The Python Reddit API Wrapper PRAW, an acronym for "Python Reddit API Wrapper", is a Python package that allows for simple access to Reddit's AP

Python Reddit API Wrapper Development 3k Dec 29, 2022
Discord-Wrapper - Discord Websocket Wrapper in python

This does not currently work and is in development Discord Websocket Wrapper in

null 3 Oct 25, 2022
A simple API wrapper for the Tenor API

Gifpy A simple API wrapper for the Tenor API Installation Python 3.9 or higher is recommended python3 -m pip install gifpy Clone repository: $ git cl

Juan Ignacio Battiston 4 Dec 22, 2021
A wrapper for slurm especially on Taiwania2 (HPC CLI)A wrapper for slurm especially on Taiwania2 (HPC CLI)

TWCC-slurm-wrapper A wrapper for slurm especially on Taiwania2 (HPC CLI). For Taiwania2 (HPC CLI) usage, please refer to here. (δΈ­ζ–‡) How to Install? gi

Chi-Liang, Liu 5 Oct 7, 2022