A client for fetching and bookmarking Super Mario Maker courses.
Super Mario Maker Client will fetch course data from the Super Mario Maker bookmark portal site. (https://supermariomakerbookmark.nintendo.net) It will also allow you to use your Nintendo Network ID and password to log in and bookmark courses to play immediately in game on your Wii U console.
Future planned features for Super Mario Maker Client include searching for courses, viewing rankings, and anything else you can do from the Super Mario Maker bookmark portal site.
Note: The Super Mario Maker bookmark portal site does not provide a convenient data API for retrieving this data so Super Mario Maker Client must consume the same HTML that is presented to web browsers. Super Mario Maker Client's functionality could break if and when Nintendo makes changes to the Super Mario Maker bookmark portal site.
If all you want is course data, begin by importing the fetchCourse
function:
import {
fetchCourse
} from 'super-mario-maker-client';
The fetchCourse
function accepts two arguments:
courseId
: A 16-digit course id including hyphenscallbackFunction
: A function that accepts two arguments:error
: Either anError
instance ornull
course
: Either a course object orundefined
if an error occurred
fetchCourse(courseId, (error, course) => {
if (error) {
// handle error
return;
}
// consume course data
});
The course object will contain all of the data that could be found in the HTML. It may contain any or all of the following properties:
attempts
: The number of attempts that have been made on this coursecleardBy
: An array of players that have cleared this coursecleared
: This will betrue
if the logged in user has cleared this courseclearRate
: The clear rate as a number from0
to100
clears
: The number of clears on this coursecourseId
: The course idcreatedAt
: A string indicating when the course was created. It may be a date like11/29/2015
or a relative time like7 days ago
.creator
: The player that created this coursecsrfToken
: This is an authentication token that is required to bookmark the course. It will be different every time.difficulty
: The difficulty of this course. It will be one ofeasy
,normal
,expert
, orsuperExpert
.firstClearBy
: The player who first cleared this coursegameStyle
: The game style used by this course. It will be one ofsuperMarioBros
,superMarioBros3
,superMarioWorld
, ornewSuperMarioBrosU
.imageUrl
: The URL of this course's imagemiiversePostUrl
: The URL of this course's Miiverse postplayers
: The number of players who have played this courserecentPlayers
: An array of players who have played this coursestarredBy
: An array of players who have starred this coursestars
: The number of stars on this coursetag
: This course's tagthumbnailUrl
: The URL of this course's thumbnailtitle
: The title of this coursetweets
: The number of times this course has been shared on TwitteruploadDate
: ADate
object for when this course was uploaded. IfcreatedAt
is a date string, that date will be used and the time will be set to midnight in your local timezone. IfcreatedAt
is a relative time, that amount of time will be subtracted from now.yourBestTime
: The fastest time that the logged in user cleared this course. This is measured in milliseconds.worldRecord
: The world record for this course.
Each player object may contain any or all of the following properties:
country
: Abbreviation of the player's countrymedals
: The number of medals the player has been awarded. This is usually only set for the course creator.miiIconUrl
: The URL of this player's mii iconmiiName
: The name of this player's mii
The worldRecord object may contain any or all of the following properties:
player
: The player who holds the world record for this course.time
: The world record time. This is measured in milliseconds.
In order to access all the features of Super Mario Maker Client, you will need
to log in with your Nintendo Network ID and password. Begin by importing the
logIn
function:
import {
logIn
} from 'super-mario-maker-client';
The logIn
function accepts two arguments:
config
: A configuration object with the following properties:password
: Your Nintendo Network passwordusername
: Your Nintendo Network ID
callbackFunction
: A function that accepts two arguments:error
: Either anError
instance ornull
superMarioMakerClient
: Either a Super Mario Maker Client instance orundefined
if an error occurred
Once you have an instance of Super Mario Maker Client, you may call methods such
as fetchCourse
, bookmarkCourse
, unbookmarkCourse
, or logOut
.
The fetchCourse
method works exactly the same as the fetchCourse
function
described above.
The bookmarkCourse
method accepts two arguments:
config
: A configuration object with the following properties:courseId
: The course id to bookmarkcsrfToken
: The CSRF token assigned to the course
callbackFunction
: A function that accepts one argument:error
: Either anError
instance ornull
The unbookmarkCourse
method accepts two arguments:
* config
: A configuration object with the following properties:
* courseId
: The course id to unbookmark
* csrfToken
: The CSRF token assigned to the course
* callbackFunction
: A function that accepts one argument:
* error
: Either an Error
instance or null
The logOut
method immediately destroys the client's session state. The
session may remain active on the server for some time. There are no arguments.
logIn({
password: 'nintendoNetworkPassword',
username: 'nintendoNetworkId'
}, (error, superMarioMakerClient) => {
if (error) {
// handle error
return;
}
superMarioMakerClient.fetchCourse(courseId, (error, course) => {
if (error) {
// handle error
return;
}
superMarioMakerClient.bookmarkCourse(course, error => {
if (error) {
// handle error
return;
}
superMarioMakerClient.logOut();
});
});
});
Note: Super Mario Maker Client is restricted to sending one request at a time.
Calling the bookmarkCourse
, fetchCourse
, logIn
, or unbookmarkCourse
methods many times at once will cause the requests to be queued up.
If needed, you can create an instance of Super Mario Maker Client directly.
Begin by importing SuperMarioMakerClient
:
import SuperMarioMakerClient from 'super-mario-maker-client';
It will work the same either way if SuperMarioMakerClient
is called as a
constructor function with the new keyword or as a factory function without the
new keyword. The function accepts on optional configuration object as the only
argument with the following optional properties:
csrfTokenHeaderName
: Defaults toX-CSRF-Token
gameStyles
: Defaults to{ sb: 'superMarioBros', sb3: 'superMarioBros3', sbu: 'newSuperMarioBrosU', sw: 'superMarioWorld' }
lang
: Defaults toen-US
sessionCookieName
: Defaults to_supermariomakerbookmark_session
superMarioMakerAuthUrl
: Defaults tohttps://supermariomakerbookmark.nintendo.net/users/auth/nintendo
superMarioMakerBookmarkUrl
: Defaults tohttps://supermariomakerbookmark.nintendo.net
Note: Changing these configurations is not recommended.
Once an instance is created, the bookmarkCourse
, fetchCourse
, logIn
,
logOut
, and unbookmarkCourse
methods will work as described above with one
exception: The logIn
method will not return the instance to the callback
function. There is also a read-only Boolean property isLoggedIn
.
https://github.com/solmsted/super-mario-maker-client
The master
branch will always point to the current stable release. Every
release will be tagged by version. The develop
branch will contain all new
commits between releases. Pull requests should be based from and sent to the
develop
branch.
Note: Due to an npm issue (npm/npm#10074), the
in-publish
module is required to prevent npm from doing unnecessary work when
running npm install
locally for this package. This causes npm to always log
errors and return a failure status when running npm install
locally, even
though the install process probably completed without error.
Several extra npm scripts are set up for convenience:
npm run build
: generate the lib directorynpm run doc
: generate the doc directorynpm run lint
: run eslint on the source code and tests
Running unit tests requires three environment variables to be set:
COURSE_ID=0000-0000-0000-0000 PASSWORD=nintendoNetworkPassword USERNAME=nintendoNetworkId npm test --coverage
Copyright (c) 2015 Steven Olmsted [email protected]
This software is provided "as is", without any express or implied warranties, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. In no event will the authors or contributors be held liable for any direct, indirect, incidental, special, exemplary, or consequential damages however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise), arising in any way out of the use of this software, even if advised of the possibility of such damage.
Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter and distribute it freely in any form, provided that the following conditions are met:
-
The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
-
Altered source versions may not be misrepresented as being the original software, and neither the name of Steven Olmsted nor the names of authors or contributors may be used to endorse or promote products derived from this software without specific prior written permission.
-
This notice must be included, unaltered, with any source distribution.