# HTTP Gateways (optional)
As part of the Airnode deployment you can decide to deploy two different HTTP Gateways.
- HTTP Gateway: testing
- HTTP Signed Data Gateway: production use
# Gateway Differences
Both gateways are setup identically. The differences are in their purpose and response. Gateways are allowed only when deploying to AWS and GCP.
# HTTP Gateway
The regular HTTP gateway is strictly for testing purposes. Using a simple tool like CURL you can test that endpoints in the Airnode configuration are working properly without accessing the blockchain.
# HTTP Signed Data Gateway
The HTTP signed data gateway is used for production purposes. While it is
executed in a similar way as the HTTP gateway, its response is signed and does
not contain a rawValue
field. This gateway is executed by an off-chain code
source that may in turn push data to a blockchain.
# Setup
Enable either gateway in the config.json
file fields
nodeSettings.httpGateway
and nodeSettings.httpSignedDataGateway
.
- enabled: A boolean to enable/disable for the gateway.
- apiKey: A user defined API key to authenticate against the gateway. The key must have a length of between 30 - 120 characters.
- maxConcurrency: (optional) A number higher than zero that represents the maximum number of serverless functions serving gateway requests. When omitted, there is no maximum concurrency set.
"nodeSettings": {
"cloudProvider": {
"type": "aws",
"region": "us-east-1"
},
"airnodeWalletMnemonic": "${AIRNODE_WALLET_MNEMONIC}",
"heartbeat": {...},
"httpGateway": {
"enabled": true,
"apiKey": "${HTTP_GATEWAY_API_KEY}",
"maxConcurrency": 20
},
"httpSignedDataGateway": {
"enabled": true,
"apiKey": "${HTTP_SIGNED_DATA_GATEWAY_API_KEY}",
"maxConcurrency": 20
},
...
},
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Add the desired endpoints the gateways can respond to in the triggers.http[n]
and/or triggers.httpSignedData[n]
arrays. The corresponding arrays do not need
to match. You may want to test all endpoints but only serve certain endpoints
using the HTTP signed data gateway or via RRP.
// in config.json
"triggers": {
"rrp": [
{
"endpointId": "0x6db9e3e3d073ad12b66d28dd85bcf49f58577270b1cc2d48a43c7025f5c27af6",
"oisTitle": "CoinGecko Basic Request",
"endpointName": "coinMarketData",
}
],
"http": [
{
"endpointId": "0x6db9e3e3d073ad12b66d28dd85bcf49f58577270b1cc2d48a43c7025f5c27af6",
"oisTitle": "CoinGecko Basic Request",
"endpointName": "coinMarketData",
}
],
"httpSignedData": [
{
"endpointId": "0x6db9e3e3d073ad12b66d28dd85bcf49f58577270b1cc2d48a43c7025f5c27af6",
"oisTitle": "CoinGecko Basic Request",
"endpointName": "coinMarketData",
}
]
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Gateway URLs
A gateway URL is generated for each gateway (when enabled) when Airnode is
deployed. You can obtain the URLs api.httpGatewayUrl
and
api.httpSignedDataGatewayUrl
from the
receipt.json file
returned by the Airnode deployer. They are also available as part of the payload
sent from Airnode's heartbeat to your specified heartbeat URL.
# Using CURL
In order to execute an endpoint served by either gateway, the following are required as part of the CURL call.
- Make a POST request with the
endpointId
as a path parameter. AnendpointId
can found in config.json undertriggers.http.endpointId
ortriggers.httpSignedData.endpointId
. - Add the
Content-Type
header, set toapplication/json
. - Add the
x-api-key
header, set to the apiKey. Thex-api-key
can found in config.json undernodeSettings.httpGateway.apiKey
ornodeSettings.httpSignedDataGateway.apiKey
. - Place the parameters/encodedParameters in the request body.
CURL Parameters | In | CURL Options |
---|---|---|
Content-Type | header | -H 'Content-Type: application/json' |
x-api-key | header | -H 'x-api-key: 8d890a46-799d-48b3-a337-8531e23dfe8e' |
endpointId | path | <gatewayUrl>/0xf466b8feec...99e9f9f90453c |
* parameters HTTP Gateway | body | -d '{"parameters": {"param1": "myValue", "param2": 5}}' |
* encodedParameters HTTP Signed Data Gateway | body | -d '{"encodedParameters": "0x3173737300....000"}' |
* Parameters for the gateways are named differently. The HTTP signed data
gateway requires that the encodedParameters
be encoded using
Airnode ABI.
Replace <gatewayUrl>
in the examples below with a URL from the receipt.json
file using the httpGatewayUrl
or httpSignedDataGatewayUrl
field. The
receipt.json file is
created when you deploy an Airnode.
# Request
# Response
There are additional examples of using CURL to call the HTTP gateway in both the Quick Deploy AWS and Quick Deploy GCP tutorials.