SEARCH_INSTRUCTIONS Search instructions with a powerful filter built on top of Elasticsearch
Overview
This method allows you to search through program instructions with a robust filter object. There are many types of filters you can apply and you can find information regarding those in the Filters section of the docs. The endpoint example here shows off one of the many filters.
Filters
As mentioned above, the api definition here illustrates one of Carpool's many filter types. All queries that accept a filter object in the POST body can make use of any of the potential filters. Please see the Instruction Filters section of the documentation to better understand how they are implemented for instruction queries.
👓 page Instruction Filters Example - Basic
Program - Cypher Protocol
Description - Get all instructions associated with the authority account at pubkey 8mpT...Mguz
Javascript
Copy mvar myHeaders = new Headers ();
myHeaders .append ( "x-api-key" , "<API_KEY>" );
myHeaders .append ( "Content-Type" , "application/json" );
var raw = JSON .stringify ({
"type" : "SEARCH_INSTRUCTIONS" ,
"query" : {
"programId" : "CYPH3o83JX6jY6NkbproSpdmQ5VWJtxjfJ5P8veyYVu3" ,
"filter" : {
"type" : "INSTRUCTION_ACCOUNT" ,
"accountPubKey" : "8mpTNU6vpLSD9mWx4BQt2S6sz2yP39ZhQ9TuMXY4MgUz" ,
"accountName" : "authority"
}
}
});
var requestOptions = {
method : 'POST' ,
headers : myHeaders ,
body : raw ,
redirect : 'follow'
};
fetch ( "https://mainnet.carpool.dev/query/solana" , requestOptions)
.then (response => response .text ())
.then (result => console .log (result))
.catch (error => console .log ( 'error' , error));
cURL
Copy curl --location 'https://mainnet.carpool.dev/query/solana' \
--header 'x-api-key: <API_KEY>' \
--header 'Content-Type: application/json' \
--data '{
"type": "SEARCH_INSTRUCTIONS",
"query": {
"programId": "CYPH3o83JX6jY6NkbproSpdmQ5VWJtxjfJ5P8veyYVu3",
"filter": {
"type": "INSTRUCTION_ACCOUNT",
"accountPubKey": "8mpTNU6vpLSD9mWx4BQt2S6sz2yP39ZhQ9TuMXY4MgUz",
"accountName": "authority"
}
}
}'
Example - Advanced
Program - Cypher Protocol
Description - Get all instructions associated with the authority account at pubkey 8mpT...Mguz. Search in a specific time range and return up to 20 objects.
Javascript
Copy var myHeaders = new Headers ();
myHeaders .append ( "x-api-key" , "<API_KEY>" );
myHeaders .append ( "Content-Type" , "application/json" );
var raw = JSON .stringify ({
"type" : "SEARCH_INSTRUCTIONS" ,
"query" : {
"programId" : "CYPH3o83JX6jY6NkbproSpdmQ5VWJtxjfJ5P8veyYVu3" ,
"filter" : {
"type" : "INSTRUCTION_ACCOUNT" ,
"accountPubKey" : "8mpTNU6vpLSD9mWx4BQt2S6sz2yP39ZhQ9TuMXY4MgUz" ,
"accountName" : "authority"
} ,
"timeRange" : {
"before" : "2023-07-17T22:53:09+0000" ,
"after" : "2023-07-11T22:53:09+0000"
} ,
"failures" : false ,
"fields" : [] ,
"sort" : {
"order" : "asc"
} ,
"pagination" : {
"limit" : 20 ,
"offset" : 0
}
}
});
var requestOptions = {
method : 'POST' ,
headers : myHeaders ,
body : raw ,
redirect : 'follow'
};
fetch ( "https://mainnet.carpool.dev/query/solana" , requestOptions)
.then (response => response .text ())
.then (result => console .log (result))
.catch (error => console .log ( 'error' , error));
cURL
Copy curl --location 'https://mainnet.carpool.dev/query/solana' \
--header 'x-api-key: <API_KEY>' \
--header 'Content-Type: application/json' \
--data '{
"type": "SEARCH_INSTRUCTIONS",
"query": {
"programId": "CYPH3o83JX6jY6NkbproSpdmQ5VWJtxjfJ5P8veyYVu3",
"filter": {
"type": "INSTRUCTION_ACCOUNT",
"accountPubKey": "8mpTNU6vpLSD9mWx4BQt2S6sz2yP39ZhQ9TuMXY4MgUz",
"accountName": "authority"
},
"timeRange": {
"before": "2023-07-17T22:53:09+0000",
"after": "2023-07-11T22:53:09+0000"
},
"failures": false,
"fields": [],
"sort": {
"order": "asc"
},
"pagination": {
"limit": 20,
"offset": 0
}
}
}'
Last updated 9 months ago