Save API

gd.py implements an interface to interact with saves of Geometry Dash.

Save

Warning

It is recommended to do a backup before working with saves.

Main save/load functionality is contained in SaveUtils, exported and intended to be used as gd.api.save instance.

Example of loading a local database:

import gd
database = gd.api.save.load()

Database

Database is python interface to saves of Geometry Dash.

Example of working with it:

db = gd.api.create_db()

print(db.load_my_levels())
# LevelCollection[<LevelAPI id=... version=... name=...>, ...]

levels = db.levels
# <Part len=...>

print(levels.get("LLM_02", 0))
# {"LLM_01": {...}, "LLM_02": ..., ...}
class gd.api.Part(*args, **kwargs)[source]
copy()a shallow copy of D[source]
set(key: str, value: T)None[source]

Same as self[key] = value.

dump_as_bytes()bytes[source]

Dump the part and return xml data.

dump()str[source]

Dump the part and return xml string.

class gd.api.Database(main: Optional[Union[bytes, str]] = None, levels: Optional[Union[bytes, str]] = None)[source]
is_empty()bool[source]

Check if the database is empty.

get_user_name()str[source]

Player name.

set_user_name(user_name: str)None[source]

Set player name to user_name.

property user_name

Player name.

get_password()str[source]

Player password.

set_password(password: str)None[source]

Set player password to password.

property password

Player password.

get_account_id()int[source]

Player Account ID, same as account_id of users.

set_account_id(account_id: int)None[source]

Set player Account ID to account_id.

property account_id

Player Account ID, same as account_id of users.

get_user_id()int[source]

Player User ID, same as id of users.

set_user_id(user_id: int)None[source]

Set player User ID to user_id.

property user_id

Player User ID, same as id of users.

get_udid()str[source]

Player UDID.

set_udid(udid: str)None[source]

Set player UDID to user_id.

property udid

Player UDID.

get_bootups()int[source]

Count of game bootups.

set_bootups(bootups: int)None[source]

Set bootups to bootups.

property bootups

Count of game bootups.

get_followed()List[int][source]

List of followed users.

set_followed(followed: Iterable[int])None[source]

Set followed users to followed.

property followed

List of followed users.

get_values()gd.api.database.LevelValues[source]

LevelValues that represent completed levels.

set_values(values: gd.api.database.LevelValues)None[source]

Set LevelValues to values.

property values

LevelValues that represent completed levels.

load_saved_levels()gd.api.database.LevelCollection[source]

Load saved levels into LevelCollection.

get_saved_levels()gd.api.database.LevelCollection

Load saved levels into LevelCollection.

dump_saved_levels(levels: gd.api.database.LevelCollection)None[source]

Dump saved levels from LevelCollection.

set_saved_levels(levels: gd.api.database.LevelCollection)None

Dump saved levels from LevelCollection.

property saved_levels

Load saved levels into LevelCollection.

load_created_levels()gd.api.database.LevelCollection[source]

Load created levels into LevelCollection.

get_created_levels()gd.api.database.LevelCollection

Load created levels into LevelCollection.

dump_created_levels(levels: gd.api.database.LevelCollection)None[source]

Dump created levels from LevelCollection.

set_created_levels(levels: gd.api.database.LevelCollection)None

Dump created levels from LevelCollection.

property created_levels

Load created levels into LevelCollection.

classmethod load(main: Optional[Union[str, pathlib.Path]] = None, levels: Optional[Union[str, pathlib.Path]] = None, main_file: Union[str, pathlib.Path] = 'CCGameManager.dat', levels_file: Union[str, pathlib.Path] = 'CCLocalLevels.dat')gd.api.database.Database[source]

Load the database. See load() for more.

dump(main: Optional[Union[str, pathlib.Path]] = None, levels: Optional[Union[str, pathlib.Path]] = None, main_file: Union[str, pathlib.Path] = 'CCGameManager.dat', levels_file: Union[str, pathlib.Path] = 'CCLocalLevels.dat')None[source]

Dump the database back. See dump() for more.

class gd.api.LevelStore(completed: List[int], stars: List[int], demons: List[int])[source]

Values that particular completed levels in the save.

class gd.api.LevelValues(official: List[int], normal: gd.api.database.LevelStore, timely: gd.api.database.LevelStore, gauntlet: gd.api.database.LevelStore, packs: List[int])[source]

Values that represent completed levels in the save.

Level Collection

class gd.api.LevelCollection(*args)[source]

Collection of LevelAPI objects.

get_by_name(name: str)Optional[gd.api.struct.LevelAPI][source]

Fetch a level by name. Returns None if not found.

dump(database: Optional[gd.api.database.Database] = None)None[source]

Dump levels to database, if provided. Otherwise, try to dump back to the database that created this collection.

LevelAPI

class gd.api.LevelAPI(*, use_default: bool = True, **kwargs)[source]