Skip to content

Instantly share code, notes, and snippets.

@ajmarkow
Last active April 23, 2021 21:20
Show Gist options
  • Save ajmarkow/f04f440870353625f6ad1075c28657cb to your computer and use it in GitHub Desktop.
Save ajmarkow/f04f440870353625f6ad1075c28657cb to your computer and use it in GitHub Desktop.
#!/bin/bash​
while getopts n: flag
do
case "${flag}" in
n) query=${OPTARG};;
esac
done
APICALL=$(curl -s -b "session=YOURSESSIONCOOKIEVALUE" "https://admin.rechargeapps.com/admin/search?query=$query" |jq ".[] | .id")
RED='\033[0;31m'
NC='\033[0m' # No Color
echo "${RED}---------------------------${NC}"
echo " "
echo "The store ID is ${RED}$APICALL${NC}";
echo " "
echo "${RED}---------------------------${NC}"
@ajmarkow
Copy link
Author

This will search the ReCharge API for a store ID. Pass the flag -n "YOUR STORE URL" along with the script name in order to run it. It is designed for a unique identifier currently, so it does not work with queries that return more than one store.

To set it up initially you need to make YOURSESSIONCOOKIEVALUE equal to the value of your session cooklie listed in Dev Tools on your browser when accessing the ReCharge Admin Sites.

@ajmarkow
Copy link
Author

Also you must have jq installed for this to work as it uses jq to parse the JSON from the API. I recommend installing brew, then using brew to install jq.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment