Skip to content
This repository was archived by the owner on Feb 24, 2026. It is now read-only.
This repository was archived by the owner on Feb 24, 2026. It is now read-only.

Wrong IDs for some NWL levels #9

Description

@DevenRam

I noticed that for memories and Shatter, the NLW api grabs the ID for the medium demons by the same name instead of the correct levels. This is likely due to both of the levels (the Extremes) have trailing spaces.

I noticed that in the index.js for the API, the following code is used to search for the level

async function fetchLevelData(name, creator, loose = false) {
    console.log("looking up metadata for", name, "by", creator);

    const params = new URLSearchParams(
        loose
            ? {
                  query: name,
                  filter: "cache_stars=10",
              }
            : {
                  filter: `cache_stars=10 AND cache_level_name='${name}'`,
              }
    );

    const { statusCode, headers, trailers, body } = await request(
        `https://history.geometrydash.eu/api/v1/search/level/advanced/?${params.toString()}`
    );
    const data = await body.json();

    if (!data.hits) {
        console.warn("got fucked up response from gdhistory:", data);
        return;
    }

    if (data.hits.length === 0 && !loose) {
        return await fetchLevelData(name, creator, true);
    } else if (data.hits.length === 0) {
        return undefined;
    }

    if (data.hits.length === 1) return data.hits[0];

    const exact = data.hits.filter((h) => h.cache_level_name.toLowerCase() === name.toLowerCase());
    if (exact.length === 1) return exact[0];

    const creatorHits = data.hits.filter(
        (h) =>
            creator.toLowerCase().includes(h.cache_username.toLowerCase()) ||
            h.cache_username.toLowerCase().includes(creator.toLowerCase())
    );
    if (creatorHits.length === 1) return creatorHits[0];

    return data.hits.sort((a, b) => b.cache_filter_difficulty - a.cache_filter_difficulty)[0]; // pick highest demon diff. somehow effective? very stupid
}

To fix this you could probably edit the exact bool to ignore whitespace.

It might be a good idea to add a filter such as cache_filter difficulty = 11 OR cache_filter_difficulty = 12 so that only Insane and Extreme demons are shown.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions