Python SDK

Getting started


To use the FX SDK for Python, you must have

Including the SDK in your project

If you use the standard way to manage your project's dependencies using a requirements.txt file and virtual environments, then add "fx-python-sdk" to your project's dependencies and install it.

$ your-virtualenv/bin/python install -r ./requirements.txt

An alternative is to download and install the the FX SDK for Python manually.

The latest version can always be found at

You can the unpack it and install it via python install.

$ wget
$ tar xvfz fx-python-sdk-latest.tar.gz
$ (cd fx-python-sdk-{version} && python2.7 install)

Using the SDK

Creating Service Clients

import impossible_fx

# FX_API_KEY and FX_API_SECRET should come from a configuration source like
# environment variables.

svc = impossible_fx.ProjectService(region="us-west-2", auth=(FX_API_KEY,   FX_API_SECRET))

The project service client always requires you to connect to a particular region where your project data is hosted and always need authentication. For a list of supported regions, see list of regions.

If you have dynamic movies in your account that you either created using the online editor or programmatically using the project service API, then you can render the movies. Rendering movies does not require authentication. Specifying a region is optional for the render service.

from impossible_fx import RenderService

render = RenderService()
# or:
render = RenderService(region="ap-southeast-2")

Exception Handling

FXError is the most common exception that you'll experience when using the SDK for Python. This exception represents an error response from an Impossible FX service. For some cases, a subclass of FXError will be thrown to allow developers fine grained control over handling error cases through try-except blocks.


Project and Asset Management Examples

Creating a project

svc = impossible_fx.ProjectService(region="eu-west-1", auth=(..., ...))
project = svc.create_project("PythonTest")

Uploading Assets

svc = impossible_fx.ProjectService(region="eu-west-1", auth=(..., ...))
project = svc.create_project("PythonTest")
with open("/tmp/mymovie.mp4") as f:
    project.upload_asset("movie.mp4", f)

Rendering Examples

Create a personalized Render URL

svc = impossible_fx.RenderService()
render_url = svc.get_render_url(
    movie_name="mymovie", params=dict(
        param1="Hello there!",
print render_url.url

Render a movie and upload it to S3

render_result = svc.render_to_s3(
        mytext="Hello there!",),
print render_result

Working with templates

Creating a simple movie template

from impossible_fx import ProjectService, SDL

svc = impossible_fx.ProjectService(region="eu-west-1", auth=(...))
project = svc.get_project("...")

video_params = SDL.VideoParams(width=640, height=360)
stream_params = SDL.StreamParams(vparams=video_params)
red = SDL.Color(red=255, alpha=255)
background = SDL.ImageProvider(type=SDL.ImageProvider.emptyimage, color=red)
background_track = SDL.VisualTrack(content=background)
green = SDL.Color(green=255, alpha=255)

text = SDL.ImageProvider(type=SDL.ImageProvider.textsimple, fontsize=50, color=green, text=SDL.StringVariable(, key="textblock1"))
foreground_track = SDL.VisualTrack(content=text)
scenes = SDL.Scene(numframes=100, tracks=[background_track, foreground_track])
movie = SDL.Movie(params=stream_params, scenes=[scenes])
print project.create_movie("mymovie", movie)

API documentation

Open generated Class and Method Reference.

Terms of Use | © 2017, Impossible Software, or its affiliates. All rights reserved.