Created
June 15, 2022 07:28
-
-
Save bretton/35949862c1d368ff66b897ad78618f76 to your computer and use it in GitHub Desktop.
Get Amboss Magma LN channel capacity offers API list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
query GetMagmaOffers { | |
getOffers { | |
list { | |
account | |
amboss_fee_rate | |
base_fee | |
base_fee_cap | |
fee_rate | |
fee_rate_cap | |
id | |
max_size | |
min_block_length | |
min_size | |
seller_score | |
side | |
status | |
total_size | |
orders { | |
locked_size | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
if [ ! -f $1 ] || [ $# -ne 1 ] | |
then | |
echo Queries the amboss magma graphql API | |
echo "Usage:" | |
echo | |
echo "$0 getmagmaoffers.gql" | |
exit 1 | |
fi | |
# read the gql query from the file named in the argument | |
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | |
TOKEN=$(cat "${DIR}"/token) | |
QUERY=$(jq -n \ | |
--arg q "$(cat $1 | tr -d '\n')" \ | |
'{ query: $q }') | |
SERVER="https://api.amboss.space/graphql" | |
# do the query | |
#curl -s -X POST \ | |
# -H "Content-Type: application/json" \ | |
# -H "Authorization: bearer ${TOKEN}" \ | |
# --data "${QUERY}" \ | |
# "${SERVER}" | |
# no auth version below | |
curl -s -X POST \ | |
-H "Content-Type: application/json" \ | |
--data "${QUERY}" \ | |
"${SERVER}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
2023-05-20: might need to use python instead of bash, jq, curl. Something changed in the API and it only works with python now