AMZN Search API is a Flask (About Flask) powered RESTful API wrapper to the Amazon search portal.
AMZN Search API has been tested and known to work on the following configurations:
- MacOS X 10.9.5
- Ubuntu 14.04 LTS
- Python 2.7, 3.5, and 3.6
- Route caching with Flask-Caching.
- GZIPed responses with Flask-Compress.
- CORS support with Flask-Cors
- Enforced SSL with Flask-SSLify
Check that the correct version of Python is installed
python -VActivate your virtualenv
Clone the repo
git clone git@github.com:reubano/amzn-search-api.gitInstall requirements
cd amzn-search-api
pip install -r base-requirements.txtRun API server
manage serveNow view the API documentation at http://localhost:5000
AMZN Search API comes with a built in script manager manage.py. Use it to
start the server, run tests, and initialize the database.
manage <command> [command-options] [manager-options]Start server
manage serveRun tests
manage testRun linters
manage lint
-m MODE, --cfgmode=MODE set the configuration mode, must be one of ['Production', 'Development', 'Test'] defaults to 'Development'. See config.py for details -f FILE, --cfgfile=FILE set the configuration file (absolute path)
runserver Runs the flask development server serve Runs the flask development server check Check staged changes for lint errors lint Check style with linters test Run nose, tox, and script tests add_keys Deploy staging app deploy Deploy staging app install Install requirements shell Runs a Python shell inside Flask application context.
Type manage <command> --help to view any command's options
manage manage serve --helpOutput
usage: manage serve [-?] [-t] [-T TIMEOUT] [-l] [-o] [-p PORT] [-h HOST]
Runs the flask development server
- optional arguments:
-?, --help show this help message and exit -t, --threaded Run multiple threads -T TIMEOUT, --timeout TIMEOUT
Fetch timeout
-l, --live Use live data -o, --offline Offline mode -p PORT, --port PORT The server port -h HOST, --host HOST The server host
Start production server on port 1000
manage serve -p 1000 -m ProductionThe following configurations settings are available in config.py:
| variable | description | default value |
|---|---|---|
| __DOMAIN__ | your custom domain | nerevu.com |
| CACHE_TIMEOUT | amount of time (in seconds) to cache responses | 60 minutes |
| API_RESULTS_PER_PAGE | the number of results returned per page | 24 |
| API_MAX_RESULTS_PER_PAGE | the maximum number of results returned per page | 1024 |
| API_URL_PREFIX | string to prefix each resource in the api url | '/api/v1' |
AMZN Search API references the following environment variables:
| variable | description |
|---|---|
| AWS_ACCESS_KEY_ID | your AWS access key ID |
| AWS_SECRET_ACCESS_KEY | your AWS access key secret |
| AWS_ASSOCIATE_TAG_US | your AWS Associate tag for US region |
| AWS_ASSOCIATE_TAG_UK | your AWS Associate tag for UK region |
To set an environment variable, e.g. MY_ENV, do the following:
echo 'export MY_ENV=value' >> ~/.profileFor a list of available resources, example requests and responses, and code samples, view the online documentation.
Getting gevent up and running is a bit tricky so follow these instructions carefully.
To use gevent, you first need to install libevent.
Linux
apt-get install libevent-devMac OS X via homebrew
brew install libeventMac OS X via macports
sudo port install libeventMac OS X via DMG
Now that libevent is handy, install the remaining requirements
pip install -r requirements.txtOr via the following if you installed libevent from macports
sudo CFLAGS="-I /opt/local/include -L /opt/local/lib" pip install gevent
pip install -r requirements.txtFinally, install foreman
sudo gem install foremanNow, you can run the application locally
foreman startYou can also specify what port you'd prefer to use
foreman start -p 5555If you haven't signed up for Heroku, go ahead and do that. You should then be able to add your SSH key to Heroku, and also heroku login from the commandline.
Install heroku and create your app
sudo gem install heroku
heroku create -s cedar app_nameAdd memcachier
heroku addons:add memcachierPush to Heroku
git push heroku masterStart the web instance and make sure the application is up and running
heroku ps:scale web=1
heroku psNow, we can view the application in our web browser
heroku openAnd anytime you want to redeploy, it's as simple as git push heroku master.
Once you are done coding, deactivate your virtualenv with deactivate.
$ tree . | sed 's/+----/├──/; /.pyc/d; /.DS_Store/d'
.
├── LICENSE
├── MANIFEST.in
├── Procfile
├── README.rst
├── app
│ ├── __init__.py
│ ├── api.py
│ ├── doc_parser.py
│ ├── frs.py
│ ├── helper.py
│ ├── static
│ │ ├── favicon-16x16.png
│ │ ├── favicon-32x32.png
│ │ ├── index.html
│ │ ├── oauth2-redirect.html
│ │ ├── swagger-ui-bundle.js
│ │ ├── swagger-ui-bundle.js.map
│ │ ├── swagger-ui-standalone-preset.js
│ │ ├── swagger-ui-standalone-preset.js.map
│ │ ├── swagger-ui.css
│ │ ├── swagger-ui.css.map
│ │ ├── swagger-ui.js
│ │ └── swagger-ui.js.map
│ ├── templates
│ │ └── index.html
│ ├── tests
│ │ ├── standard.rc
│ │ ├── test.sh
│ │ ├── test_site.py
│ ├── utils.py
│ ├── views.py
├── base-requirements.txt
├── config.py
├── dev-requirements.txt
├── helpers
│ ├── check-stage
│ ├── clean
│ ├── pippy
│ ├── srcdist
│ └── wheel
├── manage.py
├── py2-requirements.txt
├── requirements.txt
├── runtime.txt
├── setup.cfg
├── setup.py
├── test.txt
└── tox.iniFirst time
- Fork
- Clone
- Code (if you are having problems committing because of git pre-commit
hook errors, just run
manage checkto see what the issues are.) - Use tabs not spaces
- Add upstream
git remote add upstream https://github.com/reubano/amzn-search-api.git - Rebase
git rebase upstream/master - Test
manage test - Push
git push origin master - Submit a pull request
Continuing
- Code (if you are having problems committing because of git pre-commit
hook errors, just run
manage checkto see what the issues are.) - Use tabs not spaces
- Update upstream
git fetch upstream - Rebase
git rebase upstream/master - Test
manage test - Push
git push origin master - Submit a pull request
$ git shortlog -sn
95 Reuben CummingsFlask is a BSD-licensed microframework for Python based on Werkzeug, Jinja2 and good intentions.
AMZN Search API is distributed under the MIT License.