Skip to content
Template application using Flask to create an Amazon Affiliates storefront
JavaScript Python
Branch: master
Clone or download
This branch is 1 commit ahead, 1 commit behind maximebf:master.

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
amzstorefront
.gitignore
README.md
manage.py
requirements.txt

README.md

Amazon Storefront Template

An almost ready-to-use Python Flask application to create your own online shop on top of the Amazon Affiliates program using their Product Advertising API.

Features:

  • Easy to learn, easy to use
  • Easy to add products using Amazon's ASIN
  • Easy to customize and extend
  • Stays synchronized with Amazon
  • Optimized for caching engine (works great behind Varnish)
  • Small web admin and commands from the terminal
  • Uses Celery for background tasks
  • Built-in affiliates program

Installation

  1. Get the source code
  2. Install dependencies using pip install -r requirements.txt
  3. Create the db using ./manage.py create_db (uses sqlite by default)

Getting started

  1. Signup on Amazon Affiliates.
  2. Signup on AWS
  3. Edit the amzstorefront/settings.py with your authentification details
  4. Add categories and products
  5. Customize the templates and CSS
  6. Run!

Adding categories and products

To add a product you will need its ASIN which can be found in a product's URL or on the product's page in the Details section (it looks like: B003O6JIVE).

From the command line:

$ ./manage.py add_category Games
$ ./manage.py add_product B003O6JIVE Games

Running

Running the development server is as simple as:

$ ./manage.py runserver

In production, you can use uWSGI and Supervisor as explained here.

## Accessing the admin interface

A built-in admin interface is provided. It is very basic for the moment.

  1. Login at http://example.com/login with the credentials specified in settings.py
  2. Go to http://example.com/admin

Stay in sync with Amazon

Amazon requires in its ToS that products must display the last updated time of the price and that your this delay stays as low as possible.

Two ways to stay synchronized with Amazon:

  • Using cron calling the following command: ./manage.py update_all_products
  • Using Celery

Using Celery will require that a worker process is running as well as a Celery Beat instance. You can start a worker with an embeded beat using this command:

$ celery worker -A amzstorefront.tasks -B

Using Varnish

This application has been optimized to run behind Varnish so that everything can be cached. Use this simple rule to ensure the cart is not cached:

sub vcl_fetch {
    if ( !( req.url ~ "^/cart") ) {
        unset req.http.Cookie;
    }
}

Built-in affiliates program

You can motivate people to post links to your website by offering an affiliates program. It is built on top of Amazon Affiliates so your affiliates will need an Amazon Affiliates account.

Activate the affiliates program in the settings, switching ALLOW_AFFILIATES to True.

Affiliates can then link to your product pages with an afftag parameter containing their Amazon Affiliates tag. Eg: http://example.com/p/1-table-top?afftag=myamztag-30

If the visitor buys the content of its cart in the next 48 hours (set your own value in the settings using AFFILIATE_TAG_TTL), the Amazon tag of your affiliate will be used, meaning he gets the 6% commission.

You can’t perform that action at this time.