Quick Start
Create personalized content feeds, marketplaces, social networks, and more with just a few lines of code.
Last updated
Was this helpful?
Create personalized content feeds, marketplaces, social networks, and more with just a few lines of code.
Last updated
Was this helpful?
Ensure you have the following installed in your environment:
If you are using macOS or Linux, skip to the setup steps.
Ensure Docker Desktop is installed and configured with the WSL 2 backend. .
Use a WSL terminal for the following commands. Open it using wsl.exe
in your Windows Command Prompt/PowerShell.
Once that's done, continue with the setup method below.
2bttns
is a containerized application, seamlessly running in the background through Docker.
When you launch , you gain access to the Console: a built-in admin panel for creating and hosting interactive games. The Console makes it easy to build one or multiple apps through one dashboard, allowing you to manage data, create games, and much more, all with just a couple of clicks. Follow these steps to quickly set up your development environment using 2bttns.
new
With the CLI installed, you can now create a new console. Follow the steps to configure your Console with your DATABASE_URL
. As of now, 2bttns exclusively supports PostgreSQL database.
In your terminal, execute:
Make sure Docker is running!🐳
Behind the scenes, this will:
create a docker-compose.yml
file in the current directory.
launch your Console,
apply migrations to your specified database,
seed the database with examples (optional)
The next step involves setting up an admin account to access your Console securely.
💡Helpful Tip: We recommend using the Username/Password authentication method. You can achieve this through the following command, executed inside your container using the 2bttns-cli
tool:
You're all set! 🎉
With your Console setup, you're ready to upload data, develop, and host your games.
You can take down the containers using the following command in the same directory as the docker-compose.yml
file:
To start your 2bttns/2bttns container up again, run:
To avoid occupying your terminal window while running the container, include the --detach
(or -d
) flag like this:
Clearing Persisted Data
If you'd like to clear out the persisted data within your Postgres database without affecting the Docker Volume:
Note: This command removes the volume that stores your database data. Use with caution as this action cannot be undone.
You can always change these in your docker-compose.yml
file at any time. These are the environment variables you can configure for your 2bttns admin console.
DATABASE_URL
The URL of the Postgres database to connect to.
postgresql://username:password@db-hostname:port/db
NEXTAUTH_SECRET
The secret used by NextAuth. You can generate a new secret on the command line with: openssl rand -base64 32
placeholder-secret-remember-to-change
NEXTAUTH_URL
The URL of the 2bttns app.
http://localhost:3262
GITHUB_ID
The GitHub OAuth app ID, if you want to allow admin users to sign in via GitHub.
1234567890
GITHUB_SECRET
The GitHub OAuth app secret that corresponds to your GITHUB_ID
.
placeholder-secret-remember-to-change
Now with your Console running, we can make fetch requests for everything.
Generate a Bearer token to authenticate your fetch requests between your app and your Console.
2bttns will use your app_id
and secret
to your Console to generate a JWT. Navigate to your Console, click Settings, and make sure you're on the Apps tab.
Here's an example fetch request:
2. Generate URL to your Game: Now that you've generated your bearer token, you can use the full RESTful API within the Console.
Here's an example where we generate a Play URL using node-fetch
:
Getting scored data: To retrieve scored data for a particular game and user, you can use the /api/games/getPlayerScores
endpoint and pass in the game_id
and player_id
.
You can also retrieve scored data for a particular, across all Game Objects and Games:
You can use the API to generate games, manage data, and much more.
To get started, open your Console at
Returns a JSON Web Token (JWT) you can use to authenticate API calls to 2bttns.
You can get the app_id
and secret
from your 2bttns admin console, under Settings/Apps.
Returns a URL you can use to send a user to play a game in 2bttns.
ID of the app you've created in 2bttns
Secret of the app you've created in 2bttns
ID of the game you want to play in 2bttns
ID of the player you want to play in 2bttns. If the player doesn't already exist, it will be created.
Get a Player's score data for a specific Game.
The game id to get scores for
^[a-zA-Z0-9_-]+$
The player id to get scores for
^[a-zA-Z0-9_-]+$
Whether to include game objects in the response
false
Get ranked Game Object results for a player
ID value. Only alphanumeric, underscore, and hyphen are allowed.
^[a-zA-Z0-9_-]+$
Specify comma-separated input tags that will be used to score the game objects associated with the output tag.
If the output tag is included in the input tags, the player's score for those game object will be used as base scores
Specify the output tag of the game objects to get ranked results for