-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Document new AsyncAPI and JSON-RPC endpoints
- Loading branch information
1 parent
a5d5faf
commit 9f6fa93
Showing
5 changed files
with
37 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,33 @@ | ||
# Basic Concepts | ||
|
||
Games need to communicate not just with their UI, but also the rest of the web2 world that may want to interact with the game state. | ||
Games need to communicate not just with their UI, but also the rest of the web2 world that may want to interact with the game state. Paima exposes multiple different endpoints to help both with humans and tools to access the game state. | ||
|
||
## OpenAPI | ||
## (REST) OpenAPI | ||
|
||
To achieve this, Paima Engine comes with support for [OpenAPI](https://www.openapis.org/) so humans can easily interact with the node and can easily generate client libraries for games in a variety of languages. After starting your node, visit `http://localhost:3333/docs/` to see all the endpoints. | ||
Paima Engine comes with support for [OpenAPI](https://www.openapis.org/) in two ways: | ||
- (for humans) `http://localhost:3333/docs/rest/ui` to visually see the REST API generated for the node | ||
- (for robots) `http://localhost:3333/docs/rest/spec.json` to access the OpenAPI specification for the node | ||
|
||
To have your game's OpenAPI definition also show up in the docs, simply place an `openapi.json` file inside the `packaged` folder generated by your game, and Paima will automatically detect it. | ||
Notably, the specification can be combined with tools like [openapi-typescript](https://www.npmjs.com/package/openapi-typescript) to generate a typescript library for your application. | ||
|
||
To have your game's OpenAPI definition also show up in the docs, simply place an `openapi.json` file inside the `packaged` folder generated by your game, and Paima will automatically detect it (this is done automatically for you in the Paima game templates) | ||
|
||
## (MQTT) AsyncAPI | ||
|
||
Paima Engine comes with support for [AsyncAPI](https://www.asyncapi.com/) in two ways: | ||
- (for humans) `http://localhost:3333/docs/asyncapi/ui` to visually see the AsyncAPI generated for the node | ||
- (for robots) `http://localhost:3333/docs/asyncapi/spec.yml` to access the AsyncAPI specification for the node | ||
|
||
You don't typically have to interact with the specification directly, as you typically interact with these through the [event log system](../100-state-machine/325-creating-events/100-events/100-general-interface.md) | ||
|
||
## (JSON-RPC) EVM RPC API | ||
|
||
Some tools only support the [EVM JSON-RPC specification](https://eips.ethereum.org/EIPS/eip-1474). Since Paima applications are non-EVM in nature (they aggregate multiple stacks, some of which might not even be EVM at all), it doesn't support this specification fully. | ||
|
||
However, Paima nodes expose a EVM RPC wrapper API that tries its best to emulate the same behavior as EVM. | ||
|
||
You can access the wrapper API at `http://localhost:3333/rpc/evm` | ||
|
||
*NOTE*: this feature is still experimental, and we will update which endpoints work and which ones don't as well as subtle differences at a later time | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -413,4 +413,12 @@ local $> rsync -r build/* [email protected]:/var/www/html/my-game-frontend | |
|
||
The server will generate backups, we recommend you keep them in a safe place, outside this same server to recover your state at any time. | ||
|
||
#### Reset the database | ||
|
||
If you need to wipe the database to reset from scratch, you can use the following | ||
|
||
```bash | ||
docker compose --env-file=.env.testnet down | ||
docker volume rm my-game-db | ||
docker compose --env-file=.env.testnet up -d | ||
``` |