playit.ggAPI docs

The playit API is available with playit Premium. You need a Premium account and an API key.

Quickstart#

This quickstart reads the rules of one firewall. It does not change the firewall.

  1. Get an API key#

    Create an API key with the /firewall/patch scope. For more information about scopes, see Authentication.

  2. Set up your shell#

    The examples in these docs use Bash and curl 7.76 or later. Enter your API key. The key does not show on screen.

    Bash
    export PLAYIT_API_BASE='https://api.playit.gg'
    read -r -s -p 'API key: ' PLAYIT_API_KEY && printf '\n'
    export PLAYIT_API_KEY
  3. Send a request#

    Replace the example ID with the ID of one of your firewalls. An empty changes list returns the current rules and changes nothing.

    RequestBash
    curl --silent --show-error --fail-with-body \
      --request POST \
      --url "${PLAYIT_API_BASE}/firewall/patch" \
      --header "Authorization: Api-Key ${PLAYIT_API_KEY}" \
      --header 'Content-Type: application/json' \
      --data-binary '{
        "firewall_id": "11111111-1111-4111-8111-111111111111",
        "changes": []
      }'

    The response contains the firewall rules:

    ResponseJSON
    {
      "status": "success",
      "data": {
        "rules": "0.0.0.0/0 deny\n::/0 deny\n",
        "rule_count": 0,
        "changed": false
      }
    }
  4. Clean up#

    When you are done, remove the key from your shell.

    Bash
    unset PLAYIT_API_KEY

Next steps#