eBay Search API is a Flask (About Flask) powered RESTful API wrapper to the EBay search portal.
eBay 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 -V
Activate your virtualenv
Clone the repo
git clone git@github.com:reubano/ebay-search-api.git
Install requirements
cd ebay-search-api
pip install -r base-requirements.txt
Run API server
manage serve
Now view the API documentation at http://localhost:5000
eBay 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 serve
Run tests
manage test
Run 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 --help
Output
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 Production
The 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' |
eBay Search API references the following environment variables:
variable | description | environment |
---|---|---|
EBAY_DEV_ID | your eBay device ID | |
EBAY_LIVE_APP_ID | your eBay AppID | Production |
EBAY_LIVE_CERT_ID | your eBay CertID | Production |
EBAY_LIVE_TOKEN | your eBay Token | Production |
EBAY_SB_APP_ID | your eBay AppID | Sandbox |
EBAY_SB_CERT_ID | your eBay CertID | Sandbox |
EBAY_SB_TOKEN | your eBay Token | Sandbox |
To set an environment variable, e.g. MY_ENV, do the following:
echo 'export MY_ENV=value' >> ~/.profile
For 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-dev
Mac OS X via homebrew
brew install libevent
Mac OS X via macports
sudo port install libevent
Mac OS X via DMG
Now that libevent is handy, install the remaining requirements
pip install -r requirements.txt
Or 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.txt
Finally, install foreman
sudo gem install foreman
Now, you can run the application locally
foreman start
You can also specify what port you'd prefer to use
foreman start -p 5555
If 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_name
Add memcachier
heroku addons:add memcachier
Push to Heroku
git push heroku master
Start the web instance and make sure the application is up and running
heroku ps:scale web=1
heroku ps
Now, we can view the application in our web browser
heroku open
And 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.ini
First time
- Fork
- Clone
- Code (if you are having problems committing because of git pre-commit
hook errors, just run
manage check
to see what the issues are.) - Use tabs not spaces
- Add upstream
git remote add upstream https://github.com/reubano/ebay-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 check
to 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 Cummings
Flask is a BSD-licensed microframework for Python based on Werkzeug, Jinja2 and good intentions.
eBay Search API is distributed under the MIT License.