Created
July 25, 2018 15:48
-
-
Save nicksnell/5b4e61ad64ae7ac1dba7795cd6a703d4 to your computer and use it in GitHub Desktop.
Tool for exporting indexes from Algolia
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
""" | |
Export an Algolia Index to JSON. | |
Usage: ALGOLIA_KEY=<some key> ALGOLIA_SECRET=<some secret> ALGOLIA_INDEX=<some index> python algolia_export.py | |
""" | |
import os | |
import json | |
from algoliasearch import algoliasearch | |
client = algoliasearch.Client( | |
os.environ.get('ALGOLIA_KEY'), | |
os.environ.get('ALGOLIA_SECRET') | |
) | |
index = client.init_index(os.environ.get('ALGOLIA_INDEX')) | |
hits = [] | |
for hit in index.browse_all({"query": ""}): | |
hits.append(hit) | |
with open('dump.json', 'w') as f: | |
json.dump(hits, f) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment