Skip to main content

Shadertoy API for Python

Python Versions license

shadertoy-api is a library for easily accessing the Shadertoy API.
For more info about the Shadertoy API, refer to shadertoy.com/howto
Note: only shaders listed as Public+API are available through the Shadertoy API.
Also, I (the author of this library) don't have any connections with the shadertoy development team, in case you are wondering.

Using the Shadertoy API

To start using the Shadertoy API you first need to create an instance of the App class provided by shadertoy-api

>>> import shadertoy
>>> app = shadertoy.App(api_key)

To get an API key for your application you must have an account on shadertoy (go to shadertoy.com/signin).
Once logged in, you can create an API key at shadertoy.com/myapps

The App class provides access to all documented features of the Shadertoy API as of the time this was written.

Search the Shadertoy database

query(keywords=[], sort_by=None, filter=None, start_index=0, num_shaders="all")

Queries the shadertoy database for shaders matching the given filter and returns a list with the given number of their IDs, starting at the given index and sorted by the given classifier.

Classifiers: "name", "love", "popular", "newest", "hot"
Filters: "vr", "soundoutput", "soundinput", "webcam", "multipass", "musicstream"

A list of all classifiers and filters is provided by shadertoy-api

>>> shadertoy.classifiers
('name', 'love', 'popular', 'newest', 'hot')
>>> shadertoy.filters
('vr', 'soundoutput', 'soundinput', 'webcam', 'multipass', 'musicstream')

Example

>>> app.query(keywords=["fluid", "simulation"], sort_by="newest", num_shaders=10)
['DsSSzm', 'fdcyzr', 'NldXWf', 'ftySzR', 'NtKGRc', '7tKGzK', '7tyGW1', 'slKGRw', '7ttGR4', 'sdd3zj']

Get shader data (name, creator, description, likes, views, code, input media...)

get_shader(shader_id)

Returns a dictionary containing data about the shader with the given ID.

Example

>>> shader = app.get_shader("WdVXWy")
>>> shader["info"]["name"]
'molten bismuth'

Get all available shader IDs

get_all_shaders()

Returns a list of the IDs of all available shaders.

Example

>>> all_shaders = app.get_all_shaders()
>>> len(all_shaders)
25859

Non-API features

shadertoy-api also provides some non-API utilities through the App class including downloading shadertoy media files and shader icons, getting URLs for embedding shaders in webapps, and possibly more in the future!

Download Shadertoy media files

download_media_file(path)

Downloads a shadertoy media file from the given path (relative to shadertoy.com) and returns it as a file-like io.BytesIO object.

Example

>>> Image_input0 = shader["renderpass"][0]["inputs"][0]
>>> media = app.download_media_file(Image_input0["src"])
>>> type(media)
<class '_io.BytesIO'>

If you have pillow installed, try this as well:

>>> from PIL import Image
>>> img = Image.open(media)
>>> img.show()

Download shader icons

download_shader_icon(shader_id)

Downloads the icon for the shader with the given id and returns it as a file-like io.BytesIO object (note that shader icons are in JPEG format).

Example

>>> icon = app.download_shader_icon("WdVXWy")
>>> type(icon)
<class '_io.BytesIO'>

With pillow installed, try this:

>>> from PIL import Image
>>> img = Image.open(icon)
>>> img.show()

Get embeddable shader URLs

get_embeddable_url(shader_id, enable_gui=True, start_time=10, paused=True, muted=False)

Returns an embeddable URL for the shader with the given id, and configures it with the given initial settings.

Example

>>> embeddable_url = app.get_embeddable_url("WdVXWy")
>>> embeddable_url
'https://www.shadertoy.com/embed/WdVXWy?gui=true&t=10&paused=true&muted=false'

Metadata

Release files for shadertoy-api 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for shadertoy-api 1.0.2
File Size Uploaded
shadertoy-api-1.0.2.tar.gz 4.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for shadertoy-api 1.0.2
File Interpreter ABI Platform
shadertoy_api-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 9.2 kB

Release files / shadertoy-api-1.0.2.tar.gz

Download URL shadertoy-api-1.0.2.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
97c2f6aa202dfb367a9f2d36d3e1b96b4daae9f7927326e7e1c10395fcd2622a
BLAKE2b-256 checksum
How to use checksums
915bb832c687d68ec3acb30b868ca453a7ad9f86b7032d7c00087dddf3080f9a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.8.2 requests/2.25.1 setuptools/50.3.2 requests-toolbelt/0.10.1 tqdm/4.64.1 CPython/3.5.3

Release files / shadertoy_api-1.0.2-py3-none-any.whl

Download URL shadertoy_api-1.0.2-py3-none-any.whl
Size 4.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f2323024dff4be394bdc3af39dc6137360e11c17d963c3f2e2851df972b21377
BLAKE2b-256 checksum
How to use checksums
aa4bb6fcea662bf37f7df7f80b919fdcf3cad8637c63cd7c35821a39e4d55e61
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.8.2 requests/2.25.1 setuptools/50.3.2 requests-toolbelt/0.10.1 tqdm/4.64.1 CPython/3.5.3

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page