BW

BYTEWYRM

Simple online data for small Python projects

Send game data online with simple Python.

Your tutor gives you a ByteWyrm key. You use it to save and read small pieces of game data such as scores, lap times, progress values and flags.

$ python -m pip install bytewyrm

You do not need to set up a database or web server to use ByteWyrm as a student.

scores.py
from bytewyrm import ByteWyrm

wyrm = ByteWyrm("bwk_YOUR_KEY_HERE")

wyrm.store.add(
    player="Drake",
    score=12500,
)

records = wyrm.store.records()
That is enough to send data to your ByteWyrm Project.

Quick start

Start here.

You need Python, the ByteWyrm package, and an API key from your tutor.

1

Install ByteWyrm

python -m pip install bytewyrm
2

Use your key

Your tutor will give you a key beginning with bwk_.

from bytewyrm import ByteWyrm

wyrm = ByteWyrm(
    "bwk_YOUR_KEY_HERE"
)
3

Send some data

wyrm.store.add(
    player="Drake",
    score=12500,
)
4

Read it back

records = wyrm.store.records()

for record in records:
    print(record)
Getting an error? Check that your API key is correct and that the field names match the Store your tutor created.

Store

The main commands.

Store holds small structured records. Your tutor decides which fields the Store accepts and what rules apply to them.

.add()

Add a new record to the Store.

wyrm.store.add(
    player="Drake",
    score=12500,
)
.records()

Get records back from the Store.

records = wyrm.store.records(
    limit=10,
)
.latest()

Get the newest record.

latest = wyrm.store.latest()

if latest:
    print(latest)
.schema()

See the fields and types your Store accepts.

schema = wyrm.store.schema()

print(schema)
.records(...) sorting and filtering

Ask the server to sort or filter the records before returning them.

Highest scores first
scores = wyrm.store.records(
    sort_by="score",
    reverse=True,
    limit=10,
)
Only completed records
done = wyrm.store.records(
    where="completed",
    equals=True,
)

Your Project

Your tutor sets the rules.

Not every ByteWyrm Project accepts the same data. The Store is configured before you connect to it.

Fields

A Project might accept player and score, while another might use lap_time and finished.

Types

Fields can contain integers, floats, booleans or short pieces of text.

Limits

The server can limit record counts, request size and how quickly a key may send requests.

Record behaviour

A Store can keep every record, replace matching records, or keep only the highest or lowest value for a key.

If you are unsure what your Store expects, ask your tutor or use wyrm.store.schema().

Examples

Small game ideas.

These are all just different ways of using the same Store.

High scores

wyrm.store.add(
    player="Drake",
    score=12500,
)

scores = wyrm.store.records(
    sort_by="score",
    reverse=True,
    limit=10,
)

Fastest times

wyrm.store.add(
    player="Ember",
    time=42.7,
)

times = wyrm.store.records(
    sort_by="time",
    limit=10,
)

Completed levels

wyrm.store.add(
    level=3,
    completed=True,
)

finished = wyrm.store.records(
    where="completed",
    equals=True,
)

Data safety

Keep it game data.

ByteWyrm is for small amounts of non-sensitive game data such as scores, player nicknames, lap times, progress values and flags.

Do not store real names, email addresses, passwords, addresses, private messages, medical information, or other personal, sensitive or confidential information.

For tutors

Want your own ByteWyrm server?

ByteWyrm Server is open source and can be self-hosted. This is useful for tutors who want to create their own Projects, schemas, limits and student API keys.

1. Clone the server

git clone https://github.com/William-Nitrosis/bytewyrm-server.git
cd bytewyrm-server

2. Configure it

cp .env.example .env

Set your admin token, database location and optional Cloudflare Tunnel token.

3. Start with Docker

docker compose up -d --build

The included stack provides the API, admin dashboard, homepage and Cloudflare Tunnel connector.

Cloudflare Tunnel is optional. Self-hosters can use their own reverse proxy or deployment setup instead.