Skip to content

Instantly share code, notes, and snippets.

@elliott-king
Created October 30, 2019 16:03
Show Gist options
  • Save elliott-king/8492ad010035f2eef27cfd2f897e8381 to your computer and use it in GitHub Desktop.
Save elliott-king/8492ad010035f2eef27cfd2f897e8381 to your computer and use it in GitHub Desktop.
Usage when selecting 'copy as cURL' in various browsers.
curl 'https://q0tmlopf1j-dsn.algolia.net/1/indexes/*/queries?x-algolia-agent=Algolia%20for%20vanilla%20JavaScript%20(lite)%203.27.0%3BJS%20Helper%202.25.1&x-algolia-application-id=Q0TMLOPF1J&x-algolia-api-key=30a0c84a152d179ea8aa1a7a59374d08' -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:68.0) Gecko/20100101 Firefox/68.0' -H 'Accept: application/json' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'content-type: application/x-www-form-urlencoded' -H 'Origin: https://www.carnegiehall.org' -H 'Connection: keep-alive' -H 'DNT: 1' -H 'Cache-Control: max-age=0, no-cache' -H 'Pragma: no-cache' --data '{"requests":[{"indexName":"sitecore-events","params":"query=&hitsPerPage=10&page=0&facets=%5B%22eventtype%22%2C%22seasonnumber%22%2C%22facilityfacet%22%2C%22genre%22%2C%22instrument%22%5D&tagFilters=&facetFilters=%5B%22eventtype%3ACarnegie%20Hall%20Presents%22%2C%22eventtype%3AFree%20Events%22%2C%22facilityfacet%3AOffsite%22%2C%5B%22facilityfacet%3AOffsite%22%5D%5D&numericFilters=%5B%22startdate%3E1572441713100%22%5D"},{"indexName":"sitecore-events","params":"query=&hitsPerPage=1&page=0&attributesToRetrieve=%5B%5D&attributesToHighlight=%5B%5D&attributesToSnippet=%5B%5D&tagFilters=&analytics=false&clickAnalytics=false&facets=genre&numericFilters=%5B%22startdate%3E1572441713100%22%5D&facetFilters=%5B%22eventtype%3ACarnegie%20Hall%20Presents%22%2C%22eventtype%3AFree%20Events%22%2C%22facilityfacet%3AOffsite%22%2C%5B%22facilityfacet%3AOffsite%22%5D%5D"},{"indexName":"sitecore-events","params":"query=&hitsPerPage=1&page=0&attributesToRetrieve=%5B%5D&attributesToHighlight=%5B%5D&attributesToSnippet=%5B%5D&tagFilters=&analytics=false&clickAnalytics=false&facets=facilityfacet&numericFilters=%5B%22startdate%3E1572441713100%22%5D&facetFilters=%5B%22eventtype%3ACarnegie%20Hall%20Presents%22%2C%22eventtype%3AFree%20Events%22%2C%22facilityfacet%3AOffsite%22%5D"},{"indexName":"sitecore-events","params":"query=&hitsPerPage=1&page=0&attributesToRetrieve=%5B%5D&attributesToHighlight=%5B%5D&attributesToSnippet=%5B%5D&tagFilters=&analytics=false&clickAnalytics=false&facets=instrument&numericFilters=%5B%22startdate%3E1572441713100%22%5D&facetFilters=%5B%22eventtype%3ACarnegie%20Hall%20Presents%22%2C%22eventtype%3AFree%20Events%22%2C%22facilityfacet%3AOffsite%22%2C%5B%22facilityfacet%3AOffsite%22%5D%5D"}]}'
import requests
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; rv:68.0) Gecko/20100101 Firefox/68.0',
'Accept': 'application/json',
'Accept-Language': 'en-US,en;q=0.5',
'content-type': 'application/x-www-form-urlencoded',
'Origin': 'https://www.carnegiehall.org',
'Connection': 'keep-alive',
'DNT': '1',
'Cache-Control': 'max-age=0, no-cache',
'Pragma': 'no-cache',
}
params = (
('x-algolia-agent', 'Algolia for vanilla JavaScript (lite) 3.27.0;JS Helper 2.25.1'),
('x-algolia-application-id', 'Q0TMLOPF1J'),
('x-algolia-api-key', '30a0c84a152d179ea8aa1a7a59374d08'),
)
data = [
('{"requests":[{"indexName":"sitecore-events","params":"query', ''),
('hitsPerPage', '10'),
('hitsPerPage', '1'),
('hitsPerPage', '1'),
('hitsPerPage', '1'),
('page', '0'),
('page', '0'),
('page', '0'),
('page', '0'),
('facets', '["eventtype","seasonnumber","facilityfacet","genre","instrument"]'),
('facets', 'genre'),
('facets', 'facilityfacet'),
('facets', 'instrument'),
('tagFilters', ''),
('tagFilters', ''),
('tagFilters', ''),
('tagFilters', ''),
('facetFilters', '["eventtype:Carnegie Hall Presents","eventtype:Free Events","facilityfacet:Offsite",["facilityfacet:Offsite"]]'),
('facetFilters', '["eventtype:Carnegie Hall Presents","eventtype:Free Events","facilityfacet:Offsite",["facilityfacet:Offsite"]]"},{"indexName":"sitecore-events","params":"query='),
('facetFilters', '["eventtype:Carnegie Hall Presents","eventtype:Free Events","facilityfacet:Offsite"]"},{"indexName":"sitecore-events","params":"query='),
('facetFilters', '["eventtype:Carnegie Hall Presents","eventtype:Free Events","facilityfacet:Offsite",["facilityfacet:Offsite"]]"}]}'),
('numericFilters', '["startdate>1572441713100"]"},{"indexName":"sitecore-events","params":"query='),
('numericFilters', '["startdate>1572441713100"]'),
('numericFilters', '["startdate>1572441713100"]'),
('numericFilters', '["startdate>1572441713100"]'),
('attributesToRetrieve', '[]'),
('attributesToRetrieve', '[]'),
('attributesToRetrieve', '[]'),
('attributesToHighlight', '[]'),
('attributesToHighlight', '[]'),
('attributesToHighlight', '[]'),
('attributesToSnippet', '[]'),
('attributesToSnippet', '[]'),
('attributesToSnippet', '[]'),
('analytics', 'false'),
('analytics', 'false'),
('analytics', 'false'),
('clickAnalytics', 'false'),
('clickAnalytics', 'false'),
('clickAnalytics', 'false'),
]
response = requests.post('https://q0tmlopf1j-dsn.algolia.net/1/indexes/*/queries', headers=headers, params=params, data=data)
#NB. Original query string below. It seems impossible to parse and
#reproduce query strings 100% accurately so the one below is given
#in case the reproduced version is not "correct".
# response = requests.post('https://q0tmlopf1j-dsn.algolia.net/1/indexes/*/queries?x-algolia-agent=Algolia%20for%20vanilla%20JavaScript%20(lite)%203.27.0%3BJS%20Helper%202.25.1&x-algolia-application-id=Q0TMLOPF1J&x-algolia-api-key=30a0c84a152d179ea8aa1a7a59374d08', headers=headers, data=data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment