🖥️Portal APIs
Through integrating with the Sunflower Land API you will be able to access player data, burn and mint items!
Setup & Authorisation
Inside of your .env
point your API to the dev server.
When you run your application, you will need a custom JWT (authorisation token) that gives your portal users access to load game data and persist. For security, this JWT can only be created from the Sunflower Land Game.
Players who access your portal will provide this jwt
to you through the url parameters. For instance:
crop-boom.sunflower-land.com/?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
You can then use this jwt
to make calls to load player data and other useful APIs.
If you are testing locally, you can quickly attain a jwt
by calling the authorisePortal()
inside of portalUtils.ts
Load Player Data
To load a player's data, you can use the endpoint above where PORTAL_ID
is your portal name.
See the example below in loadPortal.ts
Sending Events
Your portals are hosted inside of Sunflower Land which gives them access to range of events that you can fire off.
To perform these events, you send messages to the parent iframe. Don't worry, we've already coded this up for you!
Purchase
Would you like players to spend SFL or resources inside of your game?
purchase()
in portalUtil.ts
to spend a players SFL or items.
Store Progress
played()
in portalUtil.ts
to record a players progress, attempts and score.
Claim Prize
If there are prizes available (talk to SFL team), you can allow a player to claim them.
claimPrize()
in portalUtil.ts
will close the portal and claim the prize.
Note: A players score must be saved first before claiming a prize.
Last updated