Analog Bridge

Introduction

Analog Bridge is comprised of a JavaScript client and REST API which enables your users to import analog media directly into your app or website.

Official PHP, Python, and Ruby client libraries available.

Getting Started

Your account provides you with a set of keys for testing and production. Each set contains a secret key and a public key. The secret key is used for authentication on backend API requests and the public key is used for initializing the frontend client widget.

To load the widget successfully:
1. Include analogbridge.js
2. Initialize AnalogBridge with
a) Public Key
b) Customer auth token


<!-- Frontend code -->
<!-- include analogbridge.js -->
<script src="https://analogbridge.io/analogbridge.js"></script>

<!-- init AnalogBridge -->


<script type="text/javascript">
var widget = AnalogBridge.init({
    key: "Your Public Key",
    customerToken: "Customer auth token from backend",
    onOpen: function () {
        //
    },
    onClose: function () {
        //
    }
});
</script>

//Backend code
//request customer auth token
$bridge = new \AnalogBridge\Customer("Your secret API Key");
$customer = $bridge->create([
    "email" => "demo@analogbridge.io"
]);

echo $customer->auth;

#Backend code
params = {
    "email": "test@gmail.com",
    "shipping": {
        "first_name": "Abe"
    }
}

resp = analogbridge.Customer.create(params=params)
print(resp['auth'])

# Backend code
resp = AnalogBridge::Customer.create(
  email: "demo@analogbridge.io",
  shipping: {
    first_name: "John",
  },
  metadata: {
    user_id: "123456",
  }
)

print resp.auth


Full Example

In many cases you will want to load the customer auth token and init the AnalogBridge widget on demand.

In this example, when a user clicks the "Import Analog" button, a request is made to your app's /analog/customer/token route which requests an auth token for your logged in user from the AnalogBridge API.

We optionally provide customer shipping information which improves the user experience for your customer.


<!-- Frontend code -->

<!-- Your import analog button -->
<button id="analog-bridge">Import Analog</button>


<!-- include analogbridge.js -->
<script src="https://analogbridge.io/analogbridge.js"></script>

<!-- init AnalogBridge -->

<script type="text/javascript">
function init() {
    $.ajax({
        method: "GET",
        url: "/analog/customer/token",
        success: function (token) {
            widget = AnalogBridge.init({
                key: bridgePublicKey,
                customerToken: token,
                onOpen: function () {
                    //
                },
                onClose: function () {
                    //
                }
            });
        },
        error: function (err) {

        }
    });
}

$('#analog-bridge').on('click', function () {
    init();
});
</script>

//Backend code for route /analog/customer/token
//request customer auth token
$bridge = new \AnalogBridge\Customer("Your secret API Key");
$customer = $bridge->create([
    "email" => "demo@analogbridge.io",
    "shipping" => [
        "first_name" => "John",
        "last_name" => "Smith",
        "address1" => "3336 Commercial Ave",
        "city" => "Northbrook",
        "state" => "IL",
        "zip" => "60062",
        "phone" => "800-557-3508",
        "email" => "demo@analogbridge.io"
    ],
    "metadata" => [
        "user_id" => 123456
    ]
]);

echo $customer->auth;
# Backend code for route /analog/customer/token
# request customer auth token
params = {
    "email": "demo@analogbridge.io",
    "shipping": {
        "first_name": "John",
        "last_name": "Smith",
        "address1": "3336 Commercial Ave",
        "city": "Northbrook",
        "state": "IL",
        "zip": "60062",
        "phone": "800-557-3508",
        "email": "demo@analogbridge.io"
    },
    "metadata": {
        "user_id": 123456
    }
}

resp = analogbridge.Customer.create(params=params)
print(resp['auth'])
# Backend code for route /analog/customer/token
# request customer auth token
AnalogBridge::Customer.create(
  email: "demo@analogbridge.io",
  shipping: {
    first_name: "John",
    last_name: "Smith",
    address1: "3336 Commercial Ave",
    city: "Northbrook",
    state: "IL",
    zip: "60062",
    phone: "800-557-3508",
    email: "demo@analogbridge.io"
  },
  metadata: {
    user_id: "123456",
  }
)

print resp.auth

//Response (JSON)
{
    "cus_id": "cus_28b70539d2b10be293bdeb3c",
    "auth": "long_auth_token",
    "expires": 1481310922,
    "email": "demo@analogbridge.io",
    "shipping": {
        "first_name": "John",
        "last_name": "Smith",
        "company": null,
        "address1": "3336 Commercial Ave",
        "address2": null,
        "city": "Northbrook",
        "state": "IL",
        "zip": "60062",
        "country": "US",
        "phone": "800-557-3508",
        "email": "demo@analogbridge.io"
    },
    "metadata": {
        "user_id": 123456
    }
}

Customers

The customers API allows you to create, retrieve, update, delete, and list all of your customers.

Create a customer

Creates a new customer

POST https://api.analogbridge.io/v1/customers

Arguments

email:
(optional)
string The email of your customer
shipping:
(optional)
associative array The shipping information of your customer
first_name:
(optional)
string
last_name:
(optional)
string
company:
(optional)
string
address1:
(optional)
string
address2:
(optional)
string
city:
(optional)
string
state:
(optional)
string
zip:
(optional)
string
phone:
(optional)
string
email:
(optional)
string
metadata:
(optional)
associative array key/value pairs that describe the customer.
$bridge = new \AnalogBridge\Customer("Your secret API Key");
$customer = $bridge->create([
    "email" => "demo@analogbridge.io",
    "shipping" => [
        "first_name" => "John",
        "last_name" => "Smith",
        "address1" => "3336 Commercial Ave",
        "city" => "Northbrook",
        "state" => "IL",
        "zip" => "60062",
        "phone" => "800-557-3508",
        "email" => "demo@analogbridge.io"
    ],
    "metadata" => [
        "user_id" => 123456
    ]
]);
params = {
    "email": "demo@analogbridge.io",
    "shipping": {
        "first_name": "John",
        "last_name": "Smith",
        "address1": "3336 Commercial Ave",
        "city": "Northbrook",
        "state": "IL",
        "zip": "60062",
        "phone": "800-557-3508",
        "email": "demo@analogbridge.io"
    },
    "metadata": {
        "user_id": 123456
    }
}

analogbridge.Customer.create(params=params)
AnalogBridge::Customer.create(
  email: "demo@analogbridge.io",
  shipping: {
    first_name: "John",
    last_name: "Smith",
    address1: "3336 Commercial Ave",
    city: "Northbrook",
    state: "IL",
    zip: "60062",
    phone: "800-557-3508",
    email: "demo@analogbridge.io"
  },
  metadata: {
    user_id: "123456",
  }
)

//Response (JSON)
{
    "cus_id": "cus_28b70539d2b10be293bdeb3c",
    "auth": "long_auth_token",
    "expires": 1481310922,
    "email": "demo@analogbridge.io",
    "shipping": {
        "first_name": "John",
        "last_name": "Smith",
        "company": null,
        "address1": "3336 Commercial Ave",
        "address2": null,
        "city": "Northbrook",
        "state": "IL",
        "zip": "60062",
        "country": "US",
        "phone": "800-557-3508",
        "email": "demo@analogbridge.io"
    },
    "metadata": {
        "user_id": 123456
    }
}

Retrieve a customer

Retrieve an existing customer by customer id created during customer creation.

GET https://api.analogbridge.io/v1/customers/{cus_id}

Arguments

cus_id:
(required)
string The cus_id returned during customer create
$bridge = new \AnalogBridge\Customer("Your secret API Key");
$customer = $bridge->get("cus_28b70539d2b10be293bdeb3c");
analogbridge.Customer.find('cus_28b70539d2b10be293bdeb3c')
AnalogBridge::Customer.find("cus_28b70539d2b10be293bdeb3c")
//Response (JSON)
{
    "cus_id": "cus_28b70539d2b10be293bdeb3c",
    "auth": "long_auth_token",
    "expires": 1481310922,
    "email": "demo@analogbridge.io",
    "shipping": {
        "first_name": "John",
        "last_name": "Smith",
        "company": null,
        "address1": "3336 Commercial Ave",
        "address2": null,
        "city": "Northbrook",
        "state": "IL",
        "zip": "60062",
        "country": "US",
        "phone": "800-557-3508",
        "email": "demo@analogbridge.io"
    },
    "metadata": {
        "user_id": 123456
    }
}

Update a customer

Update an existing customer's information by using the cus_id from customer creation. Any unprovided parameters will have no effect on the customer object. The arguments for this call are mainly the same as for the customer creation call.

POST https://api.analogbridge.io/v1/customers/{cus_id}

Arguments

cus_id:
(required)
string The cus_id returned during customer create
email:
(optional)
string The email of your customer
shipping:
(optional)
associative array The shipping information of your customer
first_name:
(optional)
string
last_name:
(optional)
string
company:
(optional)
string
address1:
(optional)
string
address2:
(optional)
string
city:
(optional)
string
state:
(optional)
string
zip:
(optional)
string
phone:
(optional)
string
email:
(optional)
string
metadata:
(optional)
associative array key/value pairs that describe the customer.
$bridge = new \AnalogBridge\Customer("Your secret API Key");
$customer = $bridge->update("cus_28b70539d2b10be293bdeb3c", [
            "email" => "new-email@analogbridge.io",
            "shipping" => [
                "first_name" => "Mary",
                "last_name" => "Smith",
                "address1" => "123 Main St.",
                "city" => "New York",
                "state" => "NY",
                "zip" => "12345",
                "phone" => "800-557-3508",
                "email" => "new-email@analogbridge.io"
            ]
        ]);params = {
    "email": "new-email@analogbridge.io",
    "shipping": {
        "first_name": "Mary",
        "last_name": "Smith",
        "address1": "123 Main St.",
        "city": "New York",
        "state": "NY",
        "zip": "12345",
        "phone": "800-557-3508",
        "email": "new-email@analogbridge.io"
    }
}

resp = analogbridge.Customer.update(customer_id='cus_28b70539d2b10be293bdeb3c', params=params)

AnalogBridge::Customer.update(
    "cus_28b70539d2b10be293bdeb3c",
    "email": "new-email@analogbridge.io",
    "shipping": {
        "first_name": "Mary",
        "last_name": "Smith",
        "address1": "123 Main St.",
        "city": "New York",
        "state": "NY",
        "zip": "12345",
        "phone": "800-557-3508",
        "email": "new-email@analogbridge.io"
    }
)

//Response (JSON)
{
    "cus_id": "cus_28b70539d2b10be293bdeb3c",
    "auth": "long_auth_token",
    "expires": 1481328235,
    "email": "new-email@analogbridge.io",
    "shipping": {
        "first_name": "Mary",
        "last_name": "Smith",
        "company": null,
        "address1": "123 Main St.",
        "address2": null,
        "city": "New York",
        "state": "NY",
        "zip": "12345",
        "country": "US",
        "phone": "800-557-3508",
        "email": "new-email@analogbridge.io"
    },
    "metadata": {
        "user_id": 123456
    }
}

Delete a customer

Permanently deletes a customer.

DELETE https://api.analogbridge.io/v1/customers/{cus_id}

Arguments

cus_id:
(required)
string The cus_id returned during customer create
$bridge = new \AnalogBridge\Customer("Your secret API Key");
$customer = $bridge->delete("cus_28b70539d2b10be293bdeb3c");
resp = analogbridge.Customer.delete('cus_28b70539d2b10be293bdeb3c')
AnalogBridge::Customer.delete("cus_28b70539d2b10be293bdeb3c")


//Response (JSON)
{
    "cus_id": "cus_28b70539d2b10be293bdeb3c",
    "deleted": 1481325743
}

Retrieve all customers

Retrieve a list of your customers.

GET https://api.analogbridge.io/v1/customers

Arguments

offset:
(optional, default is 0)
integer The starting offset for the list.
limit:
(optional, default is 10)
integer The number of records to retrieve. Maximum is 100 per call.
$bridge = new \AnalogBridge\Customer("Your secret API Key");
$customer = $bridge->all(["offset" => 100, "limit" => 100]);
resp = analogbridge.Customer.list(limit=100, offset=100)
AnalogBridge::Customer.list(limit: 100, offset: 100)

//Response (JSON)
{
    "offset": 100,
    "limit": 100,
    "total_count": 102,
    "list": [
        {
            "cus_id": "cus_e6bd1537e138d2c3495cdb57",
            "email": "test@test.com",
            "metadata": {
                "user_id": 123456,
                "custom": {
                    "a": "2",
                    "b": "3"
                }
            }
        },
        {
            "cus_id": "cus_d5026c9fee3c48b7d5809682",
            "email": "demo@analogbridge.io",
            "metadata": {
                "user_id": 1234567
            }
        }
    ]
}

Orders

The orders API allows you to retrieve customer order information and media urls for direct import into your app.

All media urls are hosted for 90 days from completion of an order. Best practice is to download and store all media files on your storage systems as file availability is not guaranteed beyond 90 days.

Retrieve all customer orders

Retrieve a list of all customer orders and respective order information, item urls, and metadata.

GET https://api.analogbridge.io/v1/customers/{cus_id}/orders

Arguments

cus_id:
(required)
string The cus_id returned during customer create
$bridge = new \AnalogBridge\Order("Your secret API Key");
$order = $bridge->all("cus_3ab7aa6ec5feda6fe8a3");
resp = analogbridge.Order.where(customer_id='cus_3ab7aa6ec5feda6fe8a3')
AnalogBridge::Order.where(customer_id: "cus_3ab7aa6ec5feda6fe8a3")


//Response (JSON)
[
    {
        "ord_id": "ord_fe310b878dc3313c3c2e",
        "cus_id": "cus_3ab7aa6ec5feda6fe8a3",
        "date": "2016-12-08 19:18:30",
        "total": 89.47,
        "subtotal": 89.47,
        "shipping": 0,
        "order_status": "Order Received from Client",
        "approval_status": "Approved",
        "instructions": "Transfer in numbered order",
        "tracking": null,
        "items": [
            {
                "id": 856962,
                "date": "1993-09-17 00:00:00",
                "title": "VHS #1",
                "is_image": 0,
                "is_video": 1,
                "video_hq_url": "https://eterna.gomemorable.com/users/883/883_1000_Eugene-and-Boris-Concert_HQ.mp4",
                "video_thumb_url": "https://eterna.gomemorable.com/users/883/883_1000_Eugene-and-Boris-Concert_thumb.jpg",
                "image_hq_url": null,
                "image_thumb_url": null
            },
            {
                "id": 856963,
                "date": "1995-09-23 00:00:00",
                "title": "VHS #2",
                "is_image": 0,
                "is_video": 1,
                "video_hq_url": "https://eterna.gomemorable.com/users/883/883_1000_1995-Jamaica-Cruise-_HQ.mp4",
                "video_thumb_url": "https://eterna.gomemorable.com/users/883/883_1000_1995-Jamaica-Cruise-_thumb.jpg",
                "image_hq_url": null,
                "image_thumb_url": null
            },
            ...
        ]
    }
]

Retrieve a single customer order

Retrieve a single customer order and respective order information, item urls, and metadata.

GET https://api.analogbridge.io/v1/customers/{cus_id}/orders/{ord_id}

Arguments

cus_id:
(required)
string The cus_id returned during customer create
ord_id:
(required)
string The ord_id for an order
$bridge = new \AnalogBridge\Order("Your secret API Key");
$order = $bridge->get("cus_3ab7aa6ec5feda6fe8a3", "ord_fe310b878dc3313c3c2e");
resp = analogbridge.Order.where(
    customer_id='cus_3ab7aa6ec5feda6fe8a3',
    order_id='ord_fe310b878dc3313c3c2e'
)
AnalogBridge::Order.where(
  order_id: "ord_fe310b878dc3313c3c2e",
  customer_id: "cus_3ab7aa6ec5feda6fe8a3"
)

//Response (JSON)
{
    "ord_id": "ord_fe310b878dc3313c3c2e",
    "cus_id": "cus_3ab7aa6ec5feda6fe8a3",
    "date": "2016-12-08 19:18:30",
    "total": 89.47,
    "subtotal": 89.47,
    "shipping": 0,
    "order_status": "Order Received from Client",
    "approval_status": "Approved",
    "instructions": "Transfer in numbered order",
    "tracking": null,
    "items": [
        {
            "id": 856962,
            "date": "1993-09-17 00:00:00",
            "title": "VHS #1",
            "is_image": 0,
            "is_video": 1,
            "video_hq_url": "https://eterna.gomemorable.com/users/883/883_1000_Eugene-and-Boris-Concert_HQ.mp4",
            "video_thumb_url": "https://eterna.gomemorable.com/users/883/883_1000_Eugene-and-Boris-Concert_thumb.jpg",
            "image_hq_url": null,
            "image_thumb_url": null
        },
        {
            "id": 856963,
            "date": "1995-09-23 00:00:00",
            "title": "VHS #2",
            "is_image": 0,
            "is_video": 1,
            "video_hq_url": "https://eterna.gomemorable.com/users/883/883_1000_1995-Jamaica-Cruise-_HQ.mp4",
            "video_thumb_url": "https://eterna.gomemorable.com/users/883/883_1000_1995-Jamaica-Cruise-_thumb.jpg",
            "image_hq_url": null,
            "image_thumb_url": null
        },
        ...
    ]
}

Retrieve all orders ready for import

Provides all orders that have items for import.

GET https://api.analogbridge.io/v1/orders/import-ready

$bridge = new \AnalogBridge\Order("Your secret API Key");
$order = $bridge->import_ready();
resp = analogbridge.Order.import_ready()
AnalogBridge::Order.import_ready

//Response (JSON)
[
    {
        "cus_id": "cus_5c5c5254882986ef6745",
        "orders": [
            "ord_4f66d77594318f53a4d5",
            "ord_e6bd1537e138d2c3495c"
        ]
    },
    {
        "cus_id": "cus_3ab7aa6ec5feda6fe8a3",
        "orders": [
            "ord_fe310b878dc3313c3c2e"
        ]
    },
    ...
]

Products

A list of all products.

GET https://api.analogbridge.io/v1/products

Attributes

name:
string Name of media format
price:
float Price of media format per unit
url:
string Image URL for media format
product_id:
integer Product id for media format
unit_name:
string Measurement unit for media format
category_name:
string Category name for type of media format
$bridge = new \AnalogBridge\Product();
$products = $bridge->all();
resp = analogbridge.Product.list()
AnalogBridge::Product.list

//Response (JSON)
[
    {
        "name": "35mm Slides",
        "price": 0.69,
        "url": "https://analogbridge.s3.amazonaws.com/images/format_35mmslides.jpg",
        "product_id": 13,
        "unit_name": "slide",
        "category_name": "image"
    },
    {
        "name": "Super 8mm Film",
        "price": 14.5,
        "url": "https://analogbridge.s3.amazonaws.com/images/format_super8.jpg",
        "product_id": 16,
        "unit_name": "50ft reel",
        "category_name": "film"
    },
    ...
]

Errors

Analog Bridge API standard error codes.

Attributes

status_code:
integer Error code
message:
string A description of the error
400 Bad Request - The request failed validation

401 Unauthorized - The request failed authorization

403 Forbidden - The request is forbidden

404 Not Found - Endpoint does not exist

500, 502, 503, 504 Server errors