Install themeparks via npm
masterInstall the themeparks library using npm to access ride wait times and park opening times for various theme parks.
npm install themeparks --saverepository·master·Indexed 20 days ago
https://github.com/cubehouse/themeparksAn unofficial API library for accessing ride wait times and park opening times for 62 theme parks worldwide, including Disney, Universal, and SeaWorld. The library provides a unified interface via the Themeparks.Parks namespace to retrieve real-time wait times and operating schedules as Promises.
Install the themeparks library using npm to access ride wait times and park opening times for various theme parks.
npm install themeparks --saveYou can enable debug mode using the standard NODE_DEBUG environment variable. Pass themeparks to see debug logs during execution.
To debug an online test:
NODE_DEBUG=themeparks npm run testonlineTo combine multiple environment variables (e.g., debugging a specific park):
NODE_DEBUG=themeparks PARKID=UniversalStudiosFlorida npm run testonlineThe library uses mocha for testing. You can run offline functional unit tests or online tests that verify actual connections to park APIs.
Offline Unit Tests Run these to test the library's logic without making network requests:
npm testOr run against source files directly:
npm run testdevOnline Tests Run these to check if the library still connects to park APIs correctly:
npm run testonlineTo test a specific park during an online test, set the PARKID environment variable:
PARKID=UniversalStudiosFlorida npm run testonlineThe Schedule class automatically manages its own persistence via an internal Cache instance.
Schedule is created, it calls CheckCacheStatus(). This returns a Promise that resolves once the cache has been successfully read from storage.SetDate or SetRange modifies the schedule, the class calls RequestCache(), which schedules a write to the cache after a 500ms debounce period.Cache getter.You can modify global library behavior by editing the properties of the Themeparks.Settings object. These settings affect caching and request timeouts.
// Example of setting a custom cache location
const Themeparks = require("themeparks");
Themeparks.Settings.Cache = __dirname + "/themeparks.db";The FetchWaitTimes() method retrieves ride status and wait times from the SixFlags API. It maps the API's status strings to internal status and wait time values:
| API Status | Internal Status | Wait Time Value |
|---|---|---|
AttractionStatusOpen | Operating | Integer (minutes) |
AttractionStatusClosed | Closed | -1 |
AttractionStatusTemporarilyClosed | Down | -2 |
AttractionStatusClosedForSeason | Closed | -1 |
AttractionStatusComingSoon | Closed | -3 |
| Other/Unknown | Down | -1 |
The library provides two ways to access the collection of supported theme park modules:
AllParks: An array containing all available park modules. This is useful for iterating through all supported parks.Parks: A keyed object where each property name corresponds to a specific park module. This is useful for direct access to a specific park by its identifier.Each park module in these collections provides the API for interacting with that specific theme park's data (e.g., ride wait times, schedules).
const { AllParks, Parks } = require('themeparks');
// Iterate through all parks
AllParks.forEach(park => {
console.log(park.name);
});
// Access a specific park directly
const magicKingdom = Parks.WaltDisneyWorldMagicKingdom;
console.log(magicKingdom.name);When creating a new park implementation by extending the Park class, you can pass an options object to the constructor to configure caching behavior, network settings, and scheduling.
Available Options:
cacheWaitTimesLength (Number, default: 300): Time in seconds to cache ride wait times.cacheOpeningTimesLength (Number, default: 3600): Time in seconds to cache park opening times.useragent (String|Function): A static User-Agent string or a generator function (compatible with random-useragent) to use for HTTP requests.proxyAgent (http.Agent): An HTTP Agent object (e.g., https-proxy-agent) to use as a proxy for all requests made by this park instance.scheduleDaysToReturn (Number, default: 60): The number of days the park's schedule should cover.Note: You cannot instantiate the Park class directly; you must use a specific park implementation.
const MyPark = require('./my-park-implementation');
const park = new MyPark({
cacheWaitTimesLength: 600,
cacheOpeningTimesLength: 7200,
useragent: 'MyCustomUserAgent/1.0',
proxyAgent: myProxyAgent,
scheduleDaysToReturn: 30
});To use the Tokyo Disneyland API framework, you must instantiate a class that extends DisneyTokyoPark. The constructor requires a parkId and fallbackEnglishNames to function correctly. You can optionally provide an apiKey, apiAuth, apiOS, apiBase, and apiVersion to override defaults.
Required Options:
parkId: The Tokyo Disneyland API park ID (e.g., for a specific park).fallbackEnglishNames: An object mapping facility codes to English ride data, used when scraping the official website fails.Optional Options:
apiKey: The API key for authentication.apiAuth: The API authentication string.apiOS: The operating system string (defaults to Android 9).apiBase: The base URL for the API (defaults to https://api-portal.tokyodisneyresort.jp).apiVersion: The API version string (defaults to 1.1.7).timezone: The timezone for the park (defaults to Asia/Tokyo).const DisneyTokyoPark = require('./path/to/disneyTokyoBase');
const myPark = new DisneyTokyoPark({
parkId: 'some_park_id',
fallbackEnglishNames: {
244: { name: 'Space Mountain', area: 'Tomorrowland' }
}
});To use the library, you can import themeparks and iterate over its Parks collection to instantiate specific park objects. This is useful for pre-loading park data into memory for fast access.
const ThemeParks = require("themeparks");
// construct our park objects and keep them in memory for fast access later
const Parks = {};
for (const park in ThemeParks.Parks) {
Parks[park] = new ThemeParks.Parks[park]();
}
// print each park's name, current location, and timezone
for (const park in Parks) {
console.log(`* ${Parks[park].Name} [${Parks[park].LocationString}]: (${Parks[park].Timezone})`);
}If you need to route requests through a proxy, pass a proxyAgent (an instance of an http.Agent) in the options object when constructing a park class.
// include the Themeparks library
const Themeparks = require("themeparks");
// include whichever proxy library you want to use (must provide an http.Agent object)
const SocksProxyAgent = require('socks-proxy-agent');
// create your proxy agent object
const MyProxy = new SocksProxyAgent("socks://socks-proxy-host", true);
// create your park object, passing in proxyAgent as an option
const DisneyWorldMagicKingdom = new Themeparks.Parks.WaltDisneyWorldMagicKingdom({
proxyAgent: MyProxy
});To access data, instantiate a specific park class from Themeparks.Parks.
Important: Create the park object once and reuse it for the lifetime of your application. Re-creating the object frequently is slow and causes unnecessary data fetching.
Use .GetWaitTimes() to retrieve ride wait times as a Promise, and .GetOpeningTimes() to retrieve park opening hours.
// include the Themeparks library
const Themeparks = require("themeparks");
// access a specific park
// Create this *ONCE* and re-use this object for the lifetime of your application
const DisneyWorldMagicKingdom = new Themeparks.Parks.WaltDisneyWorldMagicKingdom();
// Access wait times by Promise
const CheckWaitTimes = () => {
DisneyWorldMagicKingdom.GetWaitTimes().then((rideTimes) => {
rideTimes.forEach((ride) => {
console.log(`${ride.name}: ${ride.waitTime} minutes wait (${ride.status})`);
});
}).catch((error) => {
console.error(error);
}).then(() => {
setTimeout(CheckWaitTimes, 1000 * 60 * 5); // refresh every 5 minutes
});
};
CheckWaitTimes();