Unlock the power of REST credentials on Galxe to streamline data management and enhance user interactions. Simplify the credentialing process and leverage REST API integration for seamless project optimization and community engagement on Galxe.
REST type credential is a way for Galxe to pull data from your RESTful HTTPs backend (or any HTTP RESTful endpoint that you are legally allowed to use). It takes a single wallet address as input and outputs 0(false)/1(true) to indicate whether the wallet address is eligible. The workflow is:
Note: The user flow should allow our partners to check whether their API endpoint is public. If not, they should either create a public endpoint in the backend or add our IP address to their whitelist.
We support GET and POST methods:
GET: Endpoint, Headers, and Expression.
POST: Endpoint, Headers, Post Body, and Expression.
HTTP response format requirement
The response of the request, for both GET and POST, must be a valid JSON body. For example:
Valid response 1 🦸
{
"data": {
"is_ok": true,
}
}
Valid response 2 🦸
{
"is_ok": true
}
Invalid response example 1 ⛔
is_ok: true
Invalid response example 2 ⛔
<is_ok>true</is_ok>
The entire response body will then be extracted and passed to the Expression for evaluation.
GET
Endpoint
The RESTFul style URL to which we will send the HTTP GET request. The $address is the user address placeholder. You can put it on query params (info?address=$address) or as a path variable (/info/$address).
The response of the request must be a valid JSON string.
NOTE: galxe.com isn’t allowed.
Headers
Optional; HTTP request header.
NOTE: Cookie header isn’t allowed.
Expression
The expression is a JavaScript (ES6) function of the type signature: (object) => int. The object that will be passed as the parameter to the function is the entire response. The function should return either number 1 or 0, representing if the address is eligible for this subgraph credential. Behind the scenes, first, we send the request with the user's address to the endpoint, and then we will apply the function against the entire response body. If the returned value is 1, then the user can own this credential; otherwise, not. The function must be anonymous, which means that the first line of the expression should be like function(resp) {}, instead of let expression = (resp) => {}.
Example
Credential: Polygon OAT Holder
Endpoint
https://api.covalenthq.com/v1/matic-mainnet/address/$address/collection/0x5D666F215a85B87Cb042D59662A7ecd2C8Cc44e6/
Header
Authorization: Bearer YOUR_API_KEY
Query Output
{
"data": {
"updated_at": "2023-06-26T05:12:35.553904397Z",
"address": "0x123",
"collection": "0x5d666f215a85b87cb042d59662a7ecd2c8cc44e6",
"is_spam": false,
"items": []
},
"error": false,
"error_message": null,
"error_code": null
}
Expression
function(resp) {
if (resp.data.items != null && resp.data.items.length > 0) {
return 1;
}
return 0;
}
POST
Endpoint
The RESTFul style URL to which we will send the HTTP POST request. Unlike the above HTTP-GET-sourced type, no placeholder of the address is allowed in the URL.
The response of the request must be a valid JSON string.
NOTE: galxe.com isn’t allowed.
Headers
Optional; HTTP request header.
NOTE: Cookie header isn’t allowed.
Post Body
As part of a POST request, a data payload can be sent to the server in the body of the request. We only support JSON format post body, and $address must be included.
Expression
The expression is a JavaScript (ES6) function of type signature: (object) => int. The object that will be passed as the parameter to the function is the entire response. The function should return either number 1 or 0, representing if the address is eligible for this subgraph credential. Behind the scenes, first, we send the request with the user's address to the endpoint, and then we will apply the function against the entire response body. If the returned value is 1, then the user can own this credential, otherwise not. The function must be anonymous, which means that the first line of the expression should be like function(resp) {}, instead of let expression = (resp) => {}.
Example
Credential: Ethereum Balancer ($ETH Balance > 0)
Endpoint
https://mainnet.infura.io/v3/YOUR-API-KEY
Header
No header
Post Body
{
"jsonrpc": "2.0",
"method": "eth_getBalance",
"params": [
"$address",
"latest"
],
"id": 1
}
Query Output
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x7c2562030800"
}
Expression
function(resp) {
if (resp.result >= "0x0") {
return 1;
}
return 0;
}
FAQ: Can't test response on Galxe due to CORS?
CORS is a browser security check. To test on Galxe, your API must include galxe.com in the Access-Control-Allow-Origin header. Although it won't affect verification, it's recommended to add galxe.com to the CORS list. Otherwise, disable CORS in your browser with plugins to run the test.