forta-api

Forta API Example Queries & Issue Tracker

View the Project on GitHub forta-network/forta-api

Query today’s alerts associated with certain addressees

What information will I get?

This query will return today’s alerts associated with certain wallets or smart contract addresses. This query can be useful if you’d like to monitor or analyze a specific contract or wallet activity:

Some example use cases:

How to execute this query?

Step 1: Go to Forta API Sandbox. Make sure the endpoint is set to https://api.forta.network/graphql in the top left corner before proceeding to the next steps.

Sandbox Endpoint Screenshot

Step 2: Create a new workspace.

New Workspace Screenshot

Step 3: Paste the following query in the Operation panel. For more details on the available alert fields, please checkout the AlertsResponse Schema.

query todaysAlerts($input: AlertsInput) {
  alerts(input: $input) {
    pageInfo {
      hasNextPage
      endCursor {
        alertId
        blockNumber
      }
    }
    alerts {
      addresses
      name
      protocol
      findingType
      source {
        transactionHash
        block {
          number
          timestamp
          chainId
        }
      }
      severity
      metadata
    }
  }
}

Operation Panel Screenshot

Step 4: Replace the placeholders in the following query parameters and paste them in the Variable panel. For more details on the available query parameters, please checkout the AlertsInput Schema

{
  "input": {
    "first": 5,
    "addresses": [<ADDRESS_A>, <ADDRESS_B>],
    "chainId": 1,
    "blockSortDirection": "asc",
    "blockDateRange": {
      "startDate": "2022-02-01",
      "endDate": "2022-02-01"
    }
  }
}

Variable Panel Screenshot

Step 5: Click on the blue submit button on the Operation panel to execute the query.

The button will look like the following:

NOTE: The button text will be different depending on the query name.

Query Submit Button Screenshot

And that’s it! You should be able to see the query results in the Response panel on the right.

The results are paginated, how do I get the next page?

If the output returns "hasNextPage": true, add the after query parameter in the input object to get the next page of alerts and execute the query.

{
  "input": {
    ...
    "after": {
      "blockNumber": "<END_CURSOR_BLOCK_NUMBER>",
      "alertId": "<END_CURSOR_ALERT_ID>"
    }
  }
}