Getting started
Welcome to the papergames.io API documentation! This guide will walk you through the steps to integrate the API into your application and start initiating one-on-one game sessions.
Duration: ⏱️ 5 minutes
Getting an API key
Getting an API key is easy and can be done through the RapidAPI Hub. You simply need to subscribe to the BASIC plan for free.
Test your API Key
Head up to the endpoint tester and take some time to explore the API endpoints.
- Click on the
POST
Create an embeddable game session to create a room session. - Go ahead and click on the Test Endpoint button.
- The endpoint returns two URLs that can be embedded in your application to connect two players.
{
"uid": "{uid}",
"playUrl": "https://papergames.io/en/r/{uid}/embed/play",
"watchUrl": "https://papergames.io/en/r/{uid}/embed"
}
The playUrl
field contains an embeddable URL that can be integrated into an iframe for a user to play.
The watchUrl
field contains an embeddable URL that can be integrated into an iframe for a user to watch the game as a spectator.
The uid
field contains the identifier for the game session. It can be combined with Webhooks to update your system with the game score.
Embedding URLs
Once you know how to make API requests, you can proceed with a quick integration test (~5 minutes).
Initiate a game session for Player 1
- Call the API endpoint Create an embeddable game session on RapidAPI.
- Open our Codepen playground. You'll see a form and iframe placeholder.
- Copy the
playUrl
field provided by the API response (step 1) and paste its value on the Play url form field. - Fill in the Username field with John Doe, or any dummy username.
- Click on the Set iframe URL. The iframe initiates a game session on papergames.io and prompts the user with a Waiting message.
At this point, the first player is joined to a game session and will wait for another player to join.
Join the game session with Player 2
- Open a new private navigation tab on your browser.
- Repeat the steps 2 to 5 of the Initiate a game session for Player 1 section.
- When you click on the Set iframe URL, player 2 joins the session, and the players can play together.
Conclusion
Congratulations! You have successfully finished this quick introduction and now have a basic understanding of how to implement
our games on your platform.
If you have any questions or encounter issues, feel free to contact us. Happy gaming!