Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

http://fetchapp.com API Python Client

branch: develop

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 fetchapp
Octocat-spinner-32 .gitignore
Octocat-spinner-32 LICENSE.txt
Octocat-spinner-32 README.mkd
Octocat-spinner-32 README_OLD.mkd
Octocat-spinner-32 config.py.sample
Octocat-spinner-32 ez_setup.py
Octocat-spinner-32 setup.py
Octocat-spinner-32 tests.py
README.mkd

Unofficial FetchApp API Python Client

Fetch is a digital delivery application that makes selling downloadable products simple. It seamlessly integrates with popular carts and payment systems like Shopify, FoxyCart, PayPal, Google Checkout, and more. Fetch is hosted software so there's nothing to install and works on any platform.

Additional documentation is available at fetchapp.com/api.

Installation

If easy_install is available, you can use:

easy_install https://github.com/hiidef/FetchApp-API/tarball/develop

Tests

To run unit tests, copy config.py.sample to config.py and modify with your account information.

Basic Usage

Instantiate FetchApp.

fa = FetchApp(key, token)

Create a new account. url is a URL slug, example: "example_url".

fa.account_create(name, first_name, last_name, email, url)

{   'api_key': '24771755c6d',
    'api_token': 'egheijahkal4',
    'billing_email': 'example_user@gmail.com',
    'download_limit_per_item': 3,
    'email': 'example_user@gmail.com',
    'id': '2357',
    'name': 'b0185600-532e-4305-8c8a-8abbadd03977',
    'order_expiration_in_hours': None,
    'url': '24771755c6d.fetchapp.com'}

Information about your account.

fa.account()  

{   'api_key': '398dd38d04d',
    'api_token': 'na4yuwaekeey',
    'billing_email': 'example@gmail.com',
    'created_at': datetime.datetime(2014, 2, 11, 18, 48, 12, tzinfo=tzutc()),
    'currency': 'USD',
    'download_limit_per_item': 3,
    'email': 'example@gmail.com',
    'id': 103176,
    'name': '61b22110-c223-41eb-a1d0-1a163682ea18',
    'order_expiration_in_hours': None,
    'url': '398dd38d04d.fetchapp.com'}

Generate a new API token (this replaces your existing one).

fa.new_token()

'example_token'

List your downloads.

fa.downloads(per_page=None, page=None)

[   {   'downloaded_at': datetime.datetime(2014, 2, 7, 21, 56, 53, tzinfo=tzutc()),
    'filename': 'me.jpg',
    'id': 10890012,
    'ip_address': '72.133.39.230',
    'order_id': None,
    'order_item_id': None,
    'product_sku': None,
    'size_bytes': 182808}]

List your products.

fa.items(per_page=None, page=None, sku=None)

[   {   'created_at': datetime.datetime(2014, 1, 28, 20, 13, 40, tzinfo=tzutc()),
        'description': 'test',
        'download_count': 0,
        'downloads_uri': 'https://accountname.fetchapp.com/api/v2/products/test/downloads',
        'files_count': 1,
        'files_uri': 'https://accountname.fetchapp.com/api/v2/products/test/files',
        'id': 'test',
        'image_url': None,
        'name': 'test',
        'order_count': 28,
        'paypal_add_to_cart_link': '/sell/ohgofood/ppc',
        'paypal_buy_now_link': '/sell/ohgofood',
        'paypal_view_cart_link': '/cart/pp',
        'price': 1.0,
        'sku': 'test',
        'store_url': 'test-site.com'},
    {   'created_at': datetime.datetime(2014, 2, 11, 16, 15, 47, tzinfo=tzutc()),
        'description': 'test product',
        'download_count': 0,
        'downloads_uri': 'https://accountname.fetchapp.com/api/v2/products/sku/downloads',
        'files_count': 1,
        'files_uri': 'https://accountname.fetchapp.com/api/v2/products/sku/files',
        'id': 'sku',
        'image_url': None,
        'name': 'Title',
        'order_count': 18,
        'paypal_add_to_cart_link': '/sell/mthievoo/ppc',
        'paypal_buy_now_link': '/sell/mthievoo',
        'paypal_view_cart_link': '/cart/pp',
        'price': 3.0,
        'sku': 'sku',
        'store_url': None}]

List details of a specified product.

fa.item_details(sku)

{   'created_at': datetime.datetime(2014, 2, 11, 18, 48, 14, tzinfo=tzutc()),
    'description': '54571bb1-f2d7-45d4-b463-f37ed2840980',
    'download_count': 0,
    'downloads_uri': 'https://accountname.fetchapp.com/api/v2/products/ac346f7e-93af-470f-80b8-d154442ad8b7/downloads',
    'files_count': 0,
    'files_uri': 'https://accountname.fetchapp.com/api/v2/products/ac346f7e-93af-470f-80b8-d154442ad8b7/files',
    'id': 'ac346f7e-93af-470f-80b8-d154442ad8b7',
    'image_url': None,
    'name': '927d9f94-1b45-4af0-8514-a3324968c4af',
    'order_count': 0,
    'paypal_add_to_cart_link': '/sell/xwngohgh/ppc',
    'paypal_buy_now_link': '/sell/xwngohgh',
    'paypal_view_cart_link': '/cart/pp',
    'price': 86.95,
    'sku': 'ac346f7e-93af-470f-80b8-d154442ad8b7',
    'store_url': None}

Delete a specified product.

fa.item_delete(sku)

True

Create a specified product.

fa.item_create(sku, name, price, description=None)

{   'created_at': datetime.datetime(2014, 2, 11, 18, 48, 14, tzinfo=tzutc()),
    'description': '54571bb1-f2d7-45d4-b463-f37ed2840980',
    'download_count': 0,
    'downloads_uri': 'https://accountname.fetchapp.com/api/v2/products/ac346f7e-93af-470f-80b8-d154442ad8b7/downloads',
    'files_count': 0,
    'files_uri': 'https://accountname.fetchapp.com/api/v2/products/ac346f7e-93af-470f-80b8-d154442ad8b7/files',
    'id': 'ac346f7e-93af-470f-80b8-d154442ad8b7',
    'image_url': None,
    'name': '927d9f94-1b45-4af0-8514-a3324968c4af',
    'order_count': 0,
    'paypal_add_to_cart_link': '/sell/xwngohgh/ppc',
    'paypal_buy_now_link': '/sell/xwngohgh',
    'paypal_view_cart_link': '/cart/pp',
    'price': 86.95,
    'sku': 'ac346f7e-93af-470f-80b8-d154442ad8b7',
    'store_url': None}

Update a specified product.

fa.item_update(sku, new_sku=None, name=None, price=None, description=None)

{   'created_at': datetime.datetime(2014, 2, 11, 18, 48, 14, tzinfo=tzutc()),
    'description': 'a1f389b2-f095-441a-a884-2f499d6b4ae6',
    'download_count': 0,
    'downloads_uri': 'https://accountname.fetchapp.com/api/v2/products/c4b1e380-c6db-44a0-960a-d7e28880aac1/downloads',
    'files_count': 0,
    'files_uri': 'https://accountname.fetchapp.com/api/v2/products/c4b1e380-c6db-44a0-960a-d7e28880aac1/files',
    'id': 'c4b1e380-c6db-44a0-960a-d7e28880aac1',
    'image_url': None,
    'name': '4a9b1d0b-4827-44a4-b673-04850a41a8cf',
    'order_count': 0,
    'paypal_add_to_cart_link': '/sell/xwngohgh/ppc',
    'paypal_buy_now_link': '/sell/xwngohgh',
    'paypal_view_cart_link': '/cart/pp',
    'price': 38.53,
    'sku': 'c4b1e380-c6db-44a0-960a-d7e28880aac1',
    'store_url': None}

List all the files for a product.

fa.item_list_files(sku)

[   {   'filename': 'sample.txt',
        'size_bytes': 13.0,
        'content_type': 'binary/octet-stream',
        'permalink': '/permalink/werwa',
        'permalink_full': 'http://accountname.fetchapp.com/permalink/werwa'}]

List all the downloads for an item.

fa.item_list_downloads(sku)

[   {   'filename': 'sample.txt',
        'id': '23570',
        'item_sku': 'example_sku',
        'ip_address': '76.128.69.128',
        'order_id': '1002',
        'size_bytes': 13.0,
        'downloaded_at': datetime.datetime(2011, 2, 8, 4, 19, 17, tzinfo=tzutc())}]

List statistics about a product.

fa.item_stats(sku)

{   'currency': 'USD',
    'download_count': 0,
    'files_count': 0,
    'id': 'ec273d73-c154-44c0-93f1-042a8cc4d3a3',
    'order_count': 0,
    'price': 61.34,
    'sku': 'ec273d73-c154-44c0-93f1-042a8cc4d3a3'}

List all your orders.

# By default only shows most recent 25 orders
fa.orders(per_page=None, page=None, status=None)

[   {   'created_at': datetime.datetime(2014, 2, 11, 11, 4, 28, tzinfo=tzoffset(None, -28800)),
    'currency': 'USD',
    'custom_1': '7349633a-0d7b-40e3-b105-ef8206252372',
    'custom_2': '96b06cd0-816f-40fa-afe7-8919433bf2ae',
    'custom_3': 'fd07bb07-06f9-4cee-ba74-0b8e671f7f4d',
    'download_count': 0,
    'download_limit': None,
    'downloads_uri': 'https://accountname.fetchapp.com/api/v2/orders/f4d6f507-86b5-4b68-985b-7f252d196ae4/downloads',
    'email': 'example@gmail.com.com',
    'expiration_date': datetime.datetime(2014, 2, 11, 11, 3, 34, tzinfo=tzoffset(None, -28800)),
    'first_name': 'e452eed3-9a40-4cc2-9e67-a60e3edce424',
    'id': 'f4d6f507-86b5-4b68-985b-7f252d196ae4',
    'last_name': '6ad5a0a2-9638-4bf6-849a-09848d29a0f4',
    'link': '/get/adenax',
    'order_items_uri': 'https://accountname.fetchapp.com/api/v2/orders/f4d6f507-86b5-4b68-985b-7f252d196ae4/order_items',
    'product_count': 2,
    'status': 'expired',
    'total': 4.0,
    'vendor_id': 'f4d6f507-86b5-4b68-985b-7f252d196ae4'},
{   'created_at': datetime.datetime(2014, 2, 10, 15, 22, 33, tzinfo=tzoffset(None, -28800)),
    'currency': 'USD',
    'custom_1': '35180e14-b29a-4374-9b95-d40ced4d1aa5',
    'custom_2': '41d24219-56c3-4202-98f8-e13d15dcf4b2',
    'custom_3': 'c554b450-f67d-4391-82d2-ba9df328889b',
    'download_count': 0,
    'download_limit': None,
    'downloads_uri': 'https://accountname.fetchapp.com/api/v2/orders/f11d937a-c09d-4c8a-a16f-a72f2c009ca8/downloads',
    'email': 'example@gmail.com.com',
    'expiration_date': None,
    'first_name': '7d6407d2-16ad-4b1e-bc70-1227af119edd',
    'id': 'f11d937a-c09d-4c8a-a16f-a72f2c009ca8',
    'last_name': '47ce45d2-da16-4a94-8386-4b11870666b5',
    'link': '/get/nhijab',
    'order_items_uri': 'https://accountname.fetchapp.com/api/v2/orders/f11d937a-c09d-4c8a-a16f-a72f2c009ca8/order_items',
    'product_count': 1,
    'status': 'open',
    'total': 1.0,
    'vendor_id': 'f11d937a-c09d-4c8a-a16f-a72f2c009ca8'}]

Details of a specified order.

fa.order_details(order_id)

{   'created_at': datetime.datetime(2014, 2, 11, 14, 7, 8, tzinfo=tzoffset(None, -18000)),
'currency': 'USD',
'custom_1': '245c7cbd-be82-417b-990f-e872ca0eaaad',
'custom_2': '74e0b82c-ec03-4ff6-9905-918b35342d48',
'custom_3': 'b894fd6a-30d7-4ae6-ad14-2d716db54354',
'download_count': 0,
'download_limit': 5,
'downloads_uri': 'https://accountname.fetchapp.com/api/v2/orders/9b48baef-a8bf-4ee9-b8f4-9da107b2a18e/downloads',
'email': 'example@gmail.com.com',
'expiration_date': datetime.datetime(2014, 2, 12, 8, 7, 9, tzinfo=tzoffset(None, -18000)),
'first_name': '653f2018-65fb-4373-9649-0d26ae65e07f',
'id': '9b48baef-a8bf-4ee9-b8f4-9da107b2a18e',
'last_name': '292d3866-1daf-4578-bad4-c94fdbb99eac',
'link': '/get/rfbahs',
'order_items_uri': 'https://accountname.fetchapp.com/api/v2/orders/9b48baef-a8bf-4ee9-b8f4-9da107b2a18e/order_items',
'product_count': 2,
'status': 'open',
'total': 4.0,
'vendor_id': '9b48baef-a8bf-4ee9-b8f4-9da107b2a18e'}

Delete a specified order.

fa.order_delete(order_id)

True

Expire a specified order.

fa.order_expire(order_id)

True

Send download email of a specified order.

fa.order_send_email(order_id)

True

List downloads for a specified order.

fa.order_downloads(order_id)

[   {   'filename': 'sample.txt',
        'id': '23570',
        'item_sku': 'example_sku',
        'ip_address': '76.128.69.128',
        'order_id': '1002',
        'size_bytes': 13.0,
        'downloaded_at': datetime.datetime(2011, 2, 8, 4, 19, 17, tzinfo=tzutc())}]

Display stats for a specified order.

fa.order_stats(order_id)

{   'currency': 'USD',
    'download_count': 0,
    'id': '9b48baef-a8bf-4ee9-b8f4-9da107b2a18e',
    'product_count': 2,
    'total': 4.0,
    'vendor_id': '9b48baef-a8bf-4ee9-b8f4-9da107b2a18e'}

List all order items for a specified order.

fa.order_list_items(order_id)

[   {   'created_at': datetime.datetime(2014, 2, 11, 11, 7, 9, tzinfo=tzoffset(None, -28800)),
    'custom_1': None,
    'custom_2': None,
    'custom_3': None,
    'download_count': 0,
    'downloads_uri': 'https://accountname.fetchapp.com/api/v2/orders/9b48baef-a8bf-4ee9-b8f4-9da107b2a18e/order_items/10795832/downloads',
    'files_uri': 'https://accountname.fetchapp.com/api/v2/orders/9b48baef-a8bf-4ee9-b8f4-9da107b2a18e/order_items/10795832/files',
    'id': 10795832,
    'license_key': None,
    'order_id': '9b48baef-a8bf-4ee9-b8f4-9da107b2a18e',
    'price': 1.0,
    'product_name': 'test',
    'sku': 'test'},
{   'created_at': datetime.datetime(2014, 2, 11, 11, 7, 10, tzinfo=tzoffset(None, -28800)),
    'custom_1': None,
    'custom_2': None,
    'custom_3': None,
    'download_count': 0,
    'downloads_uri': 'https://accountname.fetchapp.com/api/v2/orders/9b48baef-a8bf-4ee9-b8f4-9da107b2a18e/order_items/10795833/downloads',
    'files_uri': 'https://accountname.fetchapp.com/api/v2/orders/9b48baef-a8bf-4ee9-b8f4-9da107b2a18e/order_items/10795833/files',
    'id': 10795833,
    'license_key': None,
    'order_id': '9b48baef-a8bf-4ee9-b8f4-9da107b2a18e',
    'price': 3.0,
    'product_name': 'Title',
    'sku': 'sku'}]

Display details of a specified order's specified item.

fa.order_item_details(order_id, sku)

{   'created_at': datetime.datetime(2014, 2, 11, 11, 7, 9, tzinfo=tzoffset(None, -28800)),
    'custom_1': None,
    'custom_2': None,
    'custom_3': None,
    'download_count': 0,
    'downloads_uri': 'https://accountname.fetchapp.com/api/v2/orders/9b48baef-a8bf-4ee9-b8f4-9da107b2a18e/order_items/10795832/downloads',
    'files_uri': 'https://accountname.fetchapp.com/api/v2/orders/9b48baef-a8bf-4ee9-b8f4-9da107b2a18e/order_items/10795832/files',
    'id': 10795832,
    'license_key': None,
    'order_id': '9b48baef-a8bf-4ee9-b8f4-9da107b2a18e',
    'price': 1.0,
    'product_name': 'test',
    'sku': 'test'}

Display the files of a specified order's specified item.

fa.order_item_files(order_id, sku)

[   {   'download_count': 0,
        'downloads': [],
        'downloads_remaining': None,
        'filename': 'me.jpg',
        'guid': 'vgpaij',
        'link': '/files/vgpaij',
        'type': 'file'}]

Display the downloads of a specified order's specified item.

fa.order_item_downloads(order_id, sku)

[   {   'filename': 'sample.txt',
        'id': '23570',
        'item_sku': 'example_sku',
        'ip_address': '76.128.69.128',
        'order_id': '1002',
        'size_bytes': 13.0,
        'downloaded_at': datetime.datetime(2011, 2, 8, 4, 19, 17, tzinfo=tzutc())}]

Create an order. skus should be a list of SKUs to update. expiration_date can be a string or a datetime. send_email should be a boolean.

fa.order_create(order_id, first_name, last_name, email, skus, custom_fields=None, expiration_date=None, send_email=None, download_limit=None, ignore_items=None)

{   'created_at': datetime.datetime(2014, 2, 11, 14, 30, 10, tzinfo=tzoffset(None, -18000)),
    'currency': 'USD',
    'custom_1': '3a3ee5fb-fa71-44b6-957e-bf20be252681',
    'custom_2': '3fc75c85-34a6-4e57-9cd7-7a34087c4e21',
    'custom_3': None,
    'download_count': 0,
    'download_limit': 5,
    'downloads_uri': 'https://accountname.fetchapp.com/api/v2/orders/1c4f5a71-545c-4a99-84a5-7ce9c41cb0fa/downloads',
    'email': 'example@gmail.com.com',
    'expiration_date': datetime.datetime(2014, 2, 12, 8, 30, 10, tzinfo=tzoffset(None, -18000)),
    'first_name': '956bcf07-cf61-449f-b091-46a302af50af',
    'id': '1c4f5a71-545c-4a99-84a5-7ce9c41cb0fa',
    'last_name': '785dcb79-bec8-4f89-bc19-7ba8d3ff4ddb',
    'link': '/get/mmkaix',
    'order_items_uri': 'https://accountname.fetchapp.com/api/v2/orders/1c4f5a71-545c-4a99-84a5-7ce9c41cb0fa/order_items',
    'product_count': 2,
    'status': 'open',
    'total': 4.0,
    'vendor_id': '1c4f5a71-545c-4a99-84a5-7ce9c41cb0fa'}

Update a specified order. skus should be a list of SKUs to update. expiration_date can be a string or a datetime. send_email should be a boolean.

fa.order_update(
    order_id=None, 
    first_name=None, 
    last_name=None, 
    email=None, 
    skus=None,
    custom_fields=None,
    expiration_date=None, 
    send_email=None, 
    download_limit=None, 
    ignore_items=None)

{   'created_at': datetime.datetime(2014, 2, 11, 14, 30, 10, tzinfo=tzoffset(None, -18000)),
    'currency': 'USD',
    'custom_1': '5dd1030b-ea09-46b4-9506-b376e2bd0fd3',
    'custom_2': 'ddbd1bdc-97e8-4824-9ca1-cccc0f5a527e',
    'custom_3': 'e30f6ef3-fd1a-4e2a-abde-c91f0f5d4d2c',
    'download_count': 0,
    'download_limit': 5,
    'downloads_uri': 'https://accountname.fetchapp.com/api/v2/orders/1c4f5a71-545c-4a99-84a5-7ce9c41cb0fa/downloads',
    'email': 'example@gmail.com.com',
    'expiration_date': datetime.datetime(2014, 2, 12, 8, 30, 11, tzinfo=tzoffset(None, -18000)),
    'first_name': '16590042-b55b-4fdd-ace9-7ca1c713699f',
    'id': '1c4f5a71-545c-4a99-84a5-7ce9c41cb0fa',
    'last_name': '6376ffe1-9ba3-4139-ab76-3b01c245bb4b',
    'link': '/get/mmkaix',
    'order_items_uri': 'https://accountname.fetchapp.com/api/v2/orders/1c4f5a71-545c-4a99-84a5-7ce9c41cb0fa/order_items',
    'product_count': 2,
    'status': 'open',
    'total': 4.0,
    'vendor_id': '1c4f5a71-545c-4a99-84a5-7ce9c41cb0fa'}

List your files.

fa.files(per_page=None, page=None)

[   {   'content_type': 'binary/octet-stream',
    'filename': 'me.jpg',
    'id': 289258,
    'permalink': '/permalink/dnooma',
    'size_bytes': 182808,
    'type': 'file',
    'url': None}]
Something went wrong with that request. Please try again.