2bttns
  • Getting Started
    • What is 2bttns?
    • Quick Start
    • 🆕You Asked We Listened
  • HOW TO
    • Set up your Console
    • Use the API
    • Build a game
    • Manage game data
    • Integrate game via API
    • Retrieve scores via API
  • References
    • APIs
      • Authentication
      • Generate Game URL
      • Games
      • Game Objects
      • Tags
      • Players
      • Admin
      • Export/Import
    • Command Line Interface (CLI)
      • Install
      • Usage
      • Configuration
  • TUTORIALS
    • ✨Personalize profiles with 2bttns and Next.js
Powered by GitBook
On this page

Was this helpful?

  1. Getting Started

You Asked We Listened

2bttns is now compatible with any language.

PreviousQuick StartNextSet up your Console

Last updated 1 year ago

Was this helpful?

Interfacing with the API hosted on your Console has been simplified. We are excited to announce a significant update to the 2bttns platform, which will streamline the way users interface with our API. Effective immediately, the use of our Node.js server-side SDK, previously identified as @2bttns/sdk, is no longer a requirement for API interaction. Whether your project is built with Flask or Next.js, 2bttns is seamlessly compatible.

Key Changes:

  • 🔓No More SDK Dependency: Users can now interact with the API directly without the need for the @2bttns/sdk package or a backend Node server.

  • 🌎Universal Compatibility: Whether you are working on projects built with Flask, Next.js, or any other framework, the 2bttns API is now seamlessly compatible.

  • 🛹Direct Fetch Requests: API interaction is now simplified through direct fetch requests from the client side, using a newly introduced authentication method.

Generating a Bearer Token:

To interact with the 2bttns API, you must first generate an authentication Bearer token. This token ensures secure communication between your application and our API services.

Steps to Generate Your Token:

  1. Log in to Your Console: After you've setup, access your 2bttns console dashboard.

  2. Navigate to Settings: Find the Apps section in the settings menu.

  3. Generate Token: Use the app_id and secret value found in your Apps section as parameters to generate a new Bearer token. Ensure you save this token securely.

Using Your Bearer Token:

Once you have your Bearer token, you can use it to make authorized API requests. Attach the token to the headers of your fetch requests like so:

fetch('http://localhost:3262/api/resource', {
  method: 'GET',
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN_HERE'
  }
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));

Replace YOUR_TOKEN_HERE with your actual Bearer token and localhost:3262/api/resource with the desired API endpoint.

This is only the beginning

Thank you to everyone who has used 2bttns beta thus far. We're excited about opening up the flood gates to more compatible frameworks. As always, visit our Github, join our Discord, or anything that's easy for you to talk to us.

Visit our latest API Reference for a complete guide on using the API .

🆕
Page cover image

Generate JWT

get

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.

Authorizations
Query parameters
app_idstringRequired
secretstringRequired
expires_instringOptional
Responses
200
Successful response
application/json
Responsestring
default
Error response
application/json
get
GET /api/authentication/token?app_id=text&secret=text HTTP/1.1
Host: 
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
text
  • Key Changes:
  • Generating a Bearer Token:
  • GETGenerate JWT
  • This is only the beginning