Authentication
StreamingFast Substreams authentication reference
A StreamingFast authentication token is required for connecting to the Substreams endpoints.
First, obtain an API key by visiting our Portal:
Use your API Key to obtain a shorter-lived authentication token using
curl
:curl -s https://auth.streamingfast.io/v1/auth/issue --data-binary '{"api_key": "your-secret-key"}'
Set the token as an
ENV
variable through the terminal by using:export SUBSTREAMS_API_TOKEN="your_token"
The
substreams
run
command checks the SUBSTREAMS_API_TOKEN
environment variable for the token by default. You can change that with the --substreams-api-token-envvar
flag.Place this function in your terminal profile (
.bashrc
or .zshrc
), for a quick all-in-one token fetcher:export STREAMINGFAST_KEY=server_YOUR_KEY_HERE
function sftoken {
export SUBSTREAMS_API_TOKEN=$(curl https://auth.streamingfast.io/v1/auth/issue -s --data-binary '{"api_key":"'$STREAMINGFAST_KEY'"}' | jq -r .token)
echo "Token set on in SUBSTREAMS_API_TOKEN"
}
Then obtain a new key and set it in your environment by running:
$ sftoken
- 1.The
api_key
specified here is one starting withserver_
,web_
ormobile_
, obtained through the StreamingFast Portal.