3_example_requests

Env Setup

Make sure you install optional tools first:

bash
make install_tools_optional

Test Relay with curl

Assuming you have an app staked for eth, you can query eth_blockNumber.

You can specify the service via the Target-Service-Id header:

bash
curl http://localhost:3070/v1 \
 -H "Target-Service-Id: eth" \
 -H "Authorization: test_api_key" \
 -d '{"jsonrpc": "2.0", "id": 1, "method": "eth_blockNumber" }'

Or by using the eth subdomain:

bash
curl http://eth.localhost:3070/v1 \
 -H "Authorization: test_api_key" \
 -d '{"jsonrpc": "2.0", "id": 1, "method": "eth_blockNumber" }'

Expected response:

response.json
{ "id": 1, "jsonrpc": "2.0", "result": "0x2f01a" }

Test WebSockets with wscat

For wscat installation instructions, see here.

Expected terminal prompt:

And subscribe to events:

Which will start sending events like so:

Load Testing Relays with relay-util

You can use this helper to send 100 requests with performance metrics:

Which runs the following command:

Load Testing WebSockets with websocket-load-test

You can use this helper to subscribe to events:

Subscribe to events:

Using Portal App ID instead of API Key

For the requests above, if your auth is configured to use Portal's authentication instead of API keys, you can send a request like so:

Or like so by sending the Portal-Application-ID header:

For WebSockets, the equivalent would be:

Or, by sending the Portal-Application-ID header:

Was this helpful?