NAV Navbar
Logo
cURL Python JavaScript

Introduction

Welcome to the official documentation of the Opfront API! This documentation covers the design basics of our API, as well as the details of using it from one of our SDKs or the HTTP client of your choice. For more information on the SDKs themselves and more advanced examples, head over to our code documentation.

Standards

The Opfront API implements a set of standards intended to make the navigation of resources intuitive and predictable. These standards describe how resources are accessed, the form of requests and responses, as well as the signification of different status codes. Unless otherwise specified, you can safely assume that all resources described here will obey those same rules.

Responses

Example Successful Response

{
    "status_code": 200,
    "data": {
        "some": "data"
    }
}

Example Error Response

{
    "status_code": 400,
    "message": "Invalid Arguments"
}

Every request, regardless of resource or HTTP method, will be formatted the same way.

Success Response

Field Type Description
status_code  Int HTTP Status code of the response
data Object Response data

Error Response

Field Type Description
status_code Int HTTP Status code of the error
message String Error message

Create an Object

POST /houses

 {
     "address": "1147 Central Street",
     "city": "Brooklyn",
     "state": "Nove Scotia",
     "zip": "B5A 4A8",
     "phone": "902-748-1494"
 }

Response

{
    "status_code": 201,
    "data": {
        "id": 8,
        "address": "1147 Central Street",
        "city": "Brooklyn",
        "state": "Nova Scotia",
        "zip": "B5A 4A8",
        "phone": "902-748-1494"
    }
}

HTTP Request

POST /{collection}

URL Parameters

Parameter Description
collection Collection in which to create the item

Request Body

Any writeable model field can be set in the request body.

Get an Object

GET /houses/8

{
    "status_code": 200,
    "data": {
        "id": 8,
        "address": "1147 Central Street",
        "city": "Brooklyn",
        "state": "Nova Scotia",
        "zip": "B5A 4A8",
        "phone": "902-748-1494"
    }
}

You can fetch a specific instance of any resource (provided you have access to it).

HTTP Request

GET /{collection}/{item_id}

URL Parameters

Parameter Description
collection Name of the collection in which to look for the object
item_id ID of the object

List Objects

GET /houses?offset=6&size=2&summary=true&city=Brooklyn

{
    "status_code": 200,
    "data": {
        "hits": [
            {"id": 7, "address": "2215 Whitmore Road", "city": "Brooklyn"},
            {"id": 8, "address": "1147 Central Street", "city": "Brooklyn"}
        ],
        "offset": 6,
        "size": 2,
        "total": 8
    }
}

Every resource offers parameterable paging options and filters via the query string.

HTTP Request

GET /{collection}

URL Parameters

Parameter Description
collection Name of the collection to query

Query Parameters

Parameter Required Default Description
offset No 0 Number of records by which to offset the resuts
size No 10 Number of records to return
summary No False Whether to return the full resource, or only its summary

Update an Object

PATCH /houses/8

{
    "state": "Quebec"
}

Response

{
    "status_code": 200,
    "data": {
        "id": 8,
        "address": "1147 Central Street",
        "city": "Brooklyn",
        "state": "Quebec",
        "zip": "B5A 4A8",
        "phone": "902-748-1494"
    }
}

An object can be updated in a variety of ways. Essentially, the object can be updated in its entirety by issuing a PUT request, or you can choose to only update certain fields by issuing a PATCH request.

HTTP Request

PUT-PATCH /{collection}/{item_id}

URL Parameters

Parameter Description
collection Name of the collection in which to look for the object
item_id ID of the object

Request Body

Any writeable model field can be set in the request body.

Delete an Object

DELETE /houses/8

{
    "status_code": 204,
    "data": {}
}

HTTP Request

DELETE /{collection}/{item_id}

URL Parameters

Parameter Description
collection Name of the collection in which to look for the object
item_id ID of the object

Error Codes

The Opfront API uses the following error codes:

Error Code Meaning
400 Bad Request – Some fields are missing / invalid
401 Unauthorized – No token provided / Invalid token
403 Forbidden – You do not have access to this resource
404 Not Found – Specified resource does not exist
405 Method Not Allowed – You tried to access a resource with an invalid HTTP method
409 Conflict – You tried to create a resource that already exists
422 Unprocessable Entity – The request is well-formed, but some values are invalid
500 Internal Server Error – We had a problem with our server. Try again later.

Authentication

Our API is authenticated via JSON Web Tokens. Before making requests on the different endpoints offered by the API, you must first acquire an authentication token (used for making authenticated requests) as well as a refresh token (used to get a new token once it expires).

Unless specified, Opfront expects for the authentication token to be included with all API requests to the server in a header that looks like the following:

X-Auth-Token: zxcvzxcv

First Login

Example Request

from opfront import OpfrontSession

client = OpfrontSession(
  email="user@domain.com",
  password="12345asdf"
)
curl "/auth/"
  -X POST -d '{"email": "user@domain.com", "password": "12345asdf"}'\
  -H "Content-Type: application/json"

Example Response

{
  "data": {
    "auth_token": "TOKEN_HERE",
    "refresh_token": "TOKEN_HERE"
  },
  "status_code": 200
}

HTTP Request

POST https://api.opfront.ca/auth/login

Request Body

Parameter Required Type Default Description
email Yes String - Email address of the user you wish to authenticate as.
password Yes String - Password of the user you wish to authenticate as.

Refresh Authentication Token

Example Request

# Handled automatically by SDK
// Handled automatically by SDK
curl "/auth/refresh"
  -X POST -d '{"refresh_token": "TOKEN_HERE"}' \
  -H "Content-Type: application/json

Example Response

{
  "auth_token": "NEW_TOKEN"
}

HTTP Request

POST https://api.opfront.ca/auth/refresh

Request Body

Parameter Required Type Default Description
refresh_token Yes String - Refresh token for which to generate an auth token.

Fetch Current User

Our API also exposes a way to fetch the profile of an authenticated user.

Example Request

from opfront import OpfrontSession

client = OpfrontSession(
  email="user@domain.com",
  password="12345asdf"
)

user = client.user.me()
curl "/users/me"
  -X GET \
  -H "X-Auth-Token: YOUR_TOKEN"

Example Response

{
    "data": {
        "city": "Quebec",
        "confirmed": true,
        "country": "Canada",
        "created_at": "2017-06-22T14:11:46.818000+00:00",
        "date_of_birth": null,
        "email": "test2@opfront.ca",
        "eyesight_condition": null,
        "face_type": null,
        "first_name": "John",
        "gender": "M",
        "id": 12,
        "is_admin": false,
        "last_name": "Doe",
        "modified_at": "2017-06-22T14:11:46.818000+00:00",
        "phone": "1234567890",
        "postal_code": null,
        "province": "QC",
        "street_address": null
    },
    "status_code": 200
}

HTTP Request

GET https://api.opfront.ca/users/me

Banner

The Banner resource is the highest-level entity in our system. A banner represents a collection of stores under the same brand. Each banner is managed by a single owner (altough we have plans to allow multiple owners in the future), who may or may not be a store owner.

Field Required Type Default Writeable Filterable Description
id - Int - ✖️ ✔️ ID of the banner
created_at - String Current Date ✖️ ✔️ Creation date of the banner
modified_at - String Current Date ✖️ ✔️ Last modification of the banner
name ✔️ String - ✔️ ✔️ Name of the banner
owner_id ✔️ Int - ✖️ ✔️ ID of the banner owner
billing_city ✖️ String null ✔️ ✔️ Billing city
billing_province ✖️ String null ✔️ ✔️ Billing province
billing_country ✖️ String null ✔️ ✔️ Billing country
billing_postal_code ✖️ String null ✔️ ✔️ Billing postal code
billing_address ✖️ String null ✔️ ✔️ Billing street address
billing_email ✖️ String null ✔️ ✔️ Email to use for billing

Get a Banner

Example Request

from opfront import OpfrontSession

client = OpfrontSession(
    email="test@test.ca",
    password="12345"
)

banner_id = 13
banner = client.banner.get(banner_id)
curl "/banners/13"
    -X GET
    -H "X-Auth-Token: AUTH_TOKEN"

Example Response

{
    "data": {
        "billing_address": null,
        "billing_city": "Quebec",
        "billing_country": null,
        "billing_email": null,
        "billing_postal_code": null,
        "billing_province": null,
        "created_at": "2017-07-06T17:15:39.165000+00:00",
        "id": 2,
        "modified_at": "2017-07-06T17:15:39.165000+00:00",
        "name": "My Banner",
        "owner_id": 1
    },
    "status_code": 200
}

HTTP Request

GET https://api.opfront.ca/banners/{banner_id}

URL Parameters

Parameter Description
banner The ID of the banner to retrieve

List Banners

Example Request

curl "/banners?summary=true&owner_id=1"
    -X GET \
    -H 'X-Auth-Token: YOUR_TOKEN'
from opfront import OpfrontSession

client = OpfrontSession(
    email="test@test.ca",
    password="12345"
)

# The SDK handles the paging logic automatically
for banner in client.banner.list(summary=True, owner_id=1):
    print(banner.name)

Example Response

{
    "data": {
        "hits": [
            {
                "billing_address": null,
                "billing_city": "Quebec",
                "billing_country": null,
                "billing_email": null,
                "billing_postal_code": null,
                "billing_province": null,
                "created_at": "2017-07-06T17:15:39.165000+00:00",
                "id": 2,
                "modified_at": "2017-07-06T17:15:39.165000+00:00",
                "name": "My Banner",
                "owner_id": 1
            }
        ],
        "offset": 0,
        "size": 10,
        "total": 1
    },
    "status_code": 200
}

HTTP Request

GET https://api.opfront.ca/banners

Query Parameters

All query parameters defined in the standards plus:

Parameter Required Description
owner_id ✔️ ID of the owner by which to filter the banners

Update a Banner

Example Request

from opfront import OpfrontSession

client = OpfrontSession(
    email="test@test.ca",
    password="12345"
)

banner_id = 1
banner = client.banner.get(banner_id)

banner.name = "New Banner Name"
banner.save()
curl "/banners/1"
    -X PATCH -d '{"name": "New Banner Name"}' \
    -H 'X-Auth-Token: YOUR_TOKEN' \
    -H 'Content-Type: application/json' \

HTTP Request

PUT-PATCH https://api.opfront.ca/banners/{banner_id}

URL Parameters

Parameter Description
banner_id ID of the banner to update

Request Body

All writeable banner fields can be set in the request body.

Order

An Order represents a client’s order of one or more Products at a single Store.

Client Info Schema

Field Required Type Default Description
first_name ✔️ String - First name
last_name ✔️ String - Last name
email ✔️ String - Email address
address ✔️ String - Home address
phone  ✔️ String - Primary phone number

Order Status Flow

test img

Order Model

Field Required Type Default Writeable Filterable Description
id - Int - ✖️ ✔️ ID of the order
created_at - String Current Date ✖️ ✔️ Creation date of the order
modified_at - String Current Date ✖️ ✔️ Last modification of the order
product_ids ✔️ List<Int> - ✔️ ✖️ IDs of products in the order
client_info ✔️ ClientInfo - ✔️ ✖️ Information on the client making the order
store_id ✔️ Int - ✔️ ✔️ Store where the order is placed
availibilities ✖️ Object {} ✔️ ✖️ Availabilities of the client
status ✖️ String "new" ✔️ ✔️ Current status of the order

Create an Order

Example Request

from opfront import OpfrontSession

order_data = {
    'product_ids': [1, 2, 3],
    'client_info': {
        'first_name': 'John',
        'last_name': 'Doe',
        'email': 'john.doe@email.com',
        'address': '1286, Ward Road',
        'phone': '4181234567'
    },
    'store_id': 1,
}

client = OpfrontSession()

new_order = client.order(**order_data)
new_order.save()
curl "/orders"
    -X POST -d @new_order.json \
    -H "Content-Type: application/json" \

Example Response

{
    "data": {
        "availabilities": null,
        "client_info": {
            "address": "1286, Ward Road",
            "email": "john.doe@email.com",
            "first_name": "John",
            "last_name": "Doe",
            "phone": "418234567"
        },
        "created_at": "2017-06-01T18:39:44.241583+00:00",
        "id": 9,
        "modified_at": "2017-06-01T18:39:44.368535+00:00",
        "products": [
            {
                // Product Summary
            }
        ],
        "status": "new",
        "store": {
            // Store Summary
        }
    },
    "status_code": 201
}

HTTP Request

POST https://api.opfront.ca/orders

Request Body

All writeable order fields can be set in the request body.

Get an Order

Example Request

from opfront import OpfrontSession

client = OpfrontSession(
    email="test@test.ca",
    password="12345"
)

order_id = 13
order = client.order.get(order_id)
curl "/orders/13"
    -X GET \
    -H "X-Auth-Token: YOUR_TOKEN"

Example Response

{
    "data": {
        "availabilities": null,
        "client_info": {
            "address": "1286, Ward Road",
            "email": "john.doe@email.com",
            "first_name": "John",
            "last_name": "Doe",
            "phone": "418234567"
        },
        "created_at": "2017-06-01T18:39:44.242000+00:00",
        "id": 9,
        "modified_at": "2017-06-01T18:39:44.369000+00:00",
        "products": [
            {
                // Product info
            }
        ],
        "status": "new",
        "store": {
            // Store info
        }
    },
    "status_code": 200
}

HTTP Request

GET https://api.opfront.ca/orders/<order_id>

URL Parameters

Parameter Description
order_id The ID of the order to retrieve

List Orders

Example Request

curl "/orders?summary=true&store_id=3"
    -X GET \
    -H "Auth-Token: YOUR_TOKEN"
from opfront import OpfrontSession

client = OpfrontSession(
    email="test@test.ca",
    password="12345"
)

# The SDK handles the paging logic automatically
for order in client.order.list(summary=True, store_id=3):
    print(order.product_ids)

Example Response

{
    "data": {
        "hits": [
            {
                "client_info": {
                    "address": "69, love station",
                    "email": "larry.pee@helloladies.com",
                    "first_name": "Larry",
                    "last_name": "Party",
                    "phone": "123"
                },
                "created_at": "Wed, 31 May 2017 14:19:31 GMT",
                "id": 1,
                "products": [
                    {
                        // Product summary
                    }
                ],
                "status": "new",
                "store": 3
            },
        ],
        "offset": 0,
        "size": 10,
        "total": 1
    },
    "status_code": 200
}

HTTP Request

GET https://api.opfront.ca/orders

Query Parameters

All query parameters defined in the standards plus:

Parameter Required Description
store_id ✔️ ID of the store to query

Update an Order

Example Request

from opfront import OpfrontSession

client = OpfrontSession(
    email="test@test.ca",
    password="12345"
)

order = client.order.get(18)
order.status = "done"
order.save()
curl "/orders/18"
    -X PATCH -d '{"status":  "done"}' \
    -H "X-Auth-Token: YOUR_TOKEN" \
    -H "Content-Type: application/json"

Example Response

{
    "data": {
        "availabilities": null,
        "client_info": {
            "address": "1286, Ward Road",
            "email": "john.doe@email.com",
            "first_name": "John",
            "last_name": "Doe",
            "phone": "418234567"
        },
        "created_at": "2017-06-01T18:39:44.242000+00:00",
        "id": 18,
        "modified_at": "2017-06-01T18:39:44.369000+00:00",
        "products": [
            {
                // Product info
            }
        ],
        "status": "done",
        "store": {
            // Store info
        }
    },
    "status_code": 200
}

HTTP Request

PUT-PATCH https://api.opfront.ca/orders/{order_id}

URL Parameters

Parameter Description
order_id ID of the order to update

Request Body

All writeable order fields can be set in the request body.

Delete an Order

Example Request

from opfront import OpfrontSession

client = OpfrontSession(
    email="test@test.ca",
    password="12345"
)

an_order = client.order.get(18)
an_order.delete()
# OR
client.order.delete(18)
curl "/orders/18"
    -X DELETE \
    -H "X-Auth-Token: YOUR_TOKEN"

Example Response

{
    "status_code": 204,
    "data": {}
}

HTTP Request

DELETE https://api.opfront.ca/orders/<order_id>

URL Parameters

Parameter Description
order_id The ID of the order to delete

Product

The Product resource is basically a cross-product between a Store and a Spectacle. It represents an inventory entry of a single spectacle for a single store.

Product Model

Field Required Type Default Writeable Filterable Description
id - Int - ✖️ ✔️ ID of the product
created_at - String Current Date ✖️ ✔️ Creation date of the product
modified_at - String Current Date ✖️ ✔️ Last modification of the product
name ✔️ String - ✔️ ✔️ Name of the product
external_id ✔️ String - ✔️ ✔️ ID of the product in the store’s system
description ✔️ String - ✔️ ✔️ Description of the product
store_id ✔️ Int - ✔️ ✔️ ID of the store to which the product belongs
spectacle_id ✖️ String - ✔️ ✔️ ID of the spectacle attached to the product
quantity ✖️ Int null ✔️ ✔️ In-store product quantity (null when quantity unknown)
price ✖️ Float null ✔️ ✔️ Price of the product (null when price unknown)
external_sku ✖️ String null ✔️ ✔️ SKU of the product in the store’s inventory
synced ✖️ Boolean true ✔️ ✔️ Whether the product is synced
is_publicly_visible ✖️ Boolean false ✔️ ✔️ Whether the product is publicly listed

Create a Product

Example Request

from opfront import OpfrontSession

product_data = {
    'name': 'Test product',
    'external_id': '42',
    'description': 'A product',
    'store_id': 1,
    'spectacle_id': "583eede09712a6643d2a0d19"
}

client = OpfrontSession(
    email="test@test.ca",
    password="12345"
)

new_product = client.product(**product_data)
new_product.save()
curl "/products"
    -X POST -d @new_product.json \
    -H "Content-Type: application/json" \
    -H "X-Auth-Token: YOUR_TOKEN"

Example Response

{
    "data": {
        "created_at": "2017-05-31T19:52:16.896669+00:00",
        "description": "A Product.",
        "external_id": "42",
        "external_sku": null,
        "id": 6,
        "is_publicly_visible": false,
        "modified_at": "2017-05-31T19:52:16.896695+00:00",
        "name": "Test Product",
        "price": null,
        "quantity": null,
        "spectacle": {
            // Spectacle Data
        },
        "store_id": 1,
        "synced": true
    },
    "status_code": 201
}

HTTP Request

POST https://api.opfront.ca/products

Request Body

All writeable product fields can be set in the request body.

Get a Product

Example Request

from opfront import OpfrontSession

client = OpfrontSession()

product_id = 13
product = client.product.get(product_id)
curl "/products/13"
    -X GET

Example Response

{
    "data": {
        "created_at": "2017-05-31T19:52:16.897000+00:00",
        "description": "A Product.",
        "external_id": "42",
        "external_sku": null,
        "id": 6,
        "is_publicly_visible": false,
        "modified_at": "2017-05-31T19:52:16.897000+00:00",
        "name": "Test Product",
        "price": null,
        "quantity": null,
        "spectacle": {
            // Spectacle Data
        },
        "store_id": 1,
        "synced": true
    },
    "status_code": 200
}

HTTP Request

GET https://api.opfront.ca/products/<product_id>

URL Parameters

Parameter Description
product_id The ID of the product to retrieve

List Products

Example Request

curl "/products?summary=true&store_id=3&synced=False"
    -X GET
from opfront import OpfrontSession

client = OpfrontSession()

# The SDK handles the paging logic automatically
for product in client.product.list(summary=True, store_id=3, synced=False):
    print(product.name)

Example Response

{
    "data": {
        "hits": [
            {
                "id": 6,
                "name": "Test Product",
                "quantity": null,
                "spectacle": {
                    // Spectacle Summary
                }
            }
        ],
        "offset": 0,
        "size": 10,
        "total": 1
    },
    "status_code": 200
}

HTTP Request

GET https://api.opfront.ca/products

Query Parameters

All query parameters defined in the standards plus:

Parameter Required Description
store_id ✔️ ID of the store to query
banner_id ✔️ ID of the banner to query
spec_filters ✖️ URL-encoded JSON filter object used to filter products by their spectacle’s attributes

Update a Product

Example Request

from opfront import OpfrontSession

client = OpfrontSession(
    email="test@test.ca",
    password="12345"
)

product = client.product.get(18)
product.name = 'New Name'
product.save()
curl "/products/18"
    -X PATCH -d '{"name": "New Name"}' \
    -H "X-Auth-Token: YOUR_TOKEN" \
    -H "Content-Type: application/json"

HTTP Request

PUT-PATCH https://api.opfront.ca/products/{product_id}

URL Parameters

Parameter Description
product_id ID of the product to update

Request Body

All writeable product fields can be set in the request body.

Delete a Product

Example Request

from opfront import OpfrontSession

client = OpfrontSession(
    email="test@test.ca",
    password="12345"
)

a_product = client.product.get(18)
a_product.delete()
# OR
client.product.delete(18)
curl "/products/18"
    -X DELETE \
    -H "X-Auth-Token: YOUR_TOKEN"

Example Response

{
    "status_code": 204,
    "data": {}
}

HTTP Request

DELETE https://api.opfront.ca/products/<product_id>

URL Parameters

Parameter Description
product_id The ID of the product to delete

Spectacle

The Spectacle resource represents an item as it exists outside a store. Concretely, our spectacle catalog is the catalog from which store owners will have the ability to choose from when building their online store.

Frame Shapes

cat-eye

cat-eye

aviator

aviator

squared

squared

round

round

oval

oval

oversized

oversized

Contours

Spectacle Model

Field Required Type Default Writeable Filterable Description
id - String - ✖️ ✔️ ID of the spectacle
created_at - String Current Date ✖️ ✔️ Creation date of the spectacle
modified_at - String Current Date ✖️ ✔️ Last modification of the spectacle
name ✔️ String - ✔️ ✔️ Display name of the spectacle
gender ✔️ String - ✔️ ✔️ Gender targeted by the spectacle
category ✔️ String - ✔️ ✔️ Spectacle category
color_code ✔️ String - ✔️ ✔️ Color code of the spectacle
sku ✔️ String - ✔️ ✔️ Manufacturer’s spectacle SKU
colors ✖️ List<String> [] ✔️ ✖️ Colors present on the frame
material ✖️ String null  ✔️ ✔️ Principal material constituting the frame (null when unknown)
shape ✖️ String null ✔️ ✔️ Shape of the frame (null when unknown)
contour ✖️ String null ✔️ ✔️ Type of contour
brand_name ✖️ String null ✔️ ✔️ Spectacle brand (null when unknown)
brand_url ✖️ String null ✔️ ✔️ Brand website (null when brand unknown)
manufacturer_name ✖️ String null ✔️ ✔️ Spectacle manufacturer (null when unknown)
manufacturer_url ✖️ String null ✔️ ✔️ Manufacturer website (null when manufacturer unknown)
images ✖️ Object {} ✔️ ✖️ Images of the spectacle
sizes ✖️ List<Object> [] ✔️ ✖️ Different spectacle dimensions
variants ✖️ List<Object> [] ✔️ ✖️ Different spectacle variants
is_premium ✖️ Boolean false ✔️ ✔️ Whether the spectacle’s pictures are of premium quality

Store

The store resource essentially represents a physical selling location, with it’s own inventory. For now, stores have only one owner, but we have plans to support multiple owners soon.

Store Model

Field Required Type Default Writeable Filterable Description
id - Int - ✖️ ✔️ ID of the store
created_at - String Current Date ✖️ ✔️ Creation date of the store
modified_at - String Current Date ✖️ ✔️ Last modification of the store
name ✔️ String - ✔️ ✔️ Store name
phone ✔️ String - ✔️ ✔️ Store phone number
street_address ✔️ String - ✔️ ✔️ Street address of the store
city ✔️ String - ✔️ ✔️ City
province ✔️ String - ✔️ ✔️ Province
postal_code ✔️ String - ✔️ ✔️ Store zip code
owner_id ✔️ Int - ✔️ ✔️ ID of the store’s owner
banner_id ✔️ Int - ✔️ ✔️ ID of the store’s banner
currency ✖️ String "CAD" ✔️ ✔️ Currency in use by the store
email ✖️ String null ✔️ ✔️ Store email (null when same as owner email)
domain_name ✖️ String null ✔️ ✔️ Domain name of the store (null when domain unknown)
country ✖️ String Canada ✔️ ✔️ Store country

Create a Store

Example Request

from opfront import OpfrontSession

client = OpfrontSession(
    email="test@test.ca",
    password="12345"
)

STORE_DATA = {
    'name': 'Test Store',
    'phone': '1234567890',
    'street_address': '12 Test',
    'city': 'Quebec',
    'province': 'QC',
    'postal_code': 'A1A 1A1',
    'owner_id': 1,
    'banner_id': 1
}

new_store = client.store(**STORE_DATA)
curl "/stores"
    -X POST -d @new_store.json \
    -H "Content-Type: application/json" \
    -H "X-Auth-Token: YOUR_TOKEN"

Example Response

{
    "data": {
        "banner": {
            "billing_city": "Quebec",
            "billing_country": "Canada",
            "billing_province": "QC",
            "id": 1,
            "name": "TestBanner"
        },
        "city": "Quebec",
        "country": "Canada",
        "created_at": "2017-07-05T15:21:37.286224+00:00",
        "currency": "CAD",
        "domain_name": null,
        "email": null,
        "id": 15,
        "modified_at": "2017-07-05T15:21:37.286256+00:00",
        "name": "Test Store",
        "owner_id": 1,
        "phone": "1234567890",
        "postal_code": "A1A 1A1",
        "province": "QC",
        "street_address": "12 Test"
    },
    "status_code": 201
}

HTTP Request

POST https://api.opfront.ca/stores

Request Body

All writeable store fields can be set in the request body.

Get a Store

Example Request

from opfront import OpfrontSession

client = OpfrontSession(
    email="test@test.ca",
    password="12345"
)

store_id = 13
store = client.store.get(store_id)
curl "/stores/13"
    -X GET \
    -H "X-Auth-Token: YOUR_TOKEN"

Example Response

{
    "data": {
        "city": "Quebec",
        "country": "canada",
        "created_at": "2017-05-31T14:19:31.658000+00:00",
        "currency": "CAD",
        "domain_name": "leo-opto.com",
        "email": "leo@leo-optp.ca",
        "id": 13,
        "last_sync": "2017-05-31T14:19:31.658000+00:00",
        "modified_at": "2017-05-31T14:19:31.658000+00:00",
        "name": "Leo opto",
        "owner_id": 1,
        "banner_id": 1,
        "phone": "4446568989",
        "postal_code": "g1g1g1",
        "province": "qc",
        "street_address": "226 joseph est"
    },
    "status_code": 200
}

HTTP Request

GET https://api.opfront.ca/stores/<store_id>

URL Parameters

Parameter Description
store_id The ID of the store to retrieve

List Stores

Example Request

from opfront import OpfrontSession

client = OpfrontSession(
    email="test@test.ca",
    password="12345"
)

for store in client.store.list(summary=True, banner_id=1):
    print(store.street_address)
curl "/stores?summary=true&banner_id=3"
    -X GET \
    -H "X-Auth-Token: YOUR_TOKEN"

Example Response

{
    "data": {
        "hits": [
            {
                "city": "Quebec",
                "country": "Canada",
                "email": null,
                "id": 16,
                "name": "Demo Store",
                "phone": "1234567890",
                "postal_code": "G1G 1G1",
                "province": "QC",
                "street_address": "18 place ave"
            }
        ],
        "offset": 0,
        "size": 10,
        "total": 4
    },
    "status_code": 200
}

HTTP Request

GET https://api.opfront.ca/stores

Query Parameters

All query parameters defined in the standards plus:

Parameter Required Description
banner_id ✔️ ID of the banner to query

Update a Store

Example Request

from opfront import OpfrontSession

client = OpfrontSession(
    email="test@test.ca",
    password="12345"
)

store = client.store.get(18)
store.street_address = '12 test rd'
store.save()
curl "/stores/18"
    -X PATCH -d '{"street_address": "12 test rd"}' \
    -H "X-Auth-Token: YOUR_TOKEN" \
    -H "Content-Type: application/json"

Example Response

{
    "data": {
        "banner": {
            "billing_city": "Quebec",
            "billing_country": null,
            "billing_province": null,
            "id": 1,
            "name": "OptoBanner"
        },
        "city": "Quebec",
        "country": "canada",
        "created_at": "2017-07-04T18:41:15.287000+00:00",
        "currency": "CAD",
        "domain_name": "leo-opto.com",
        "email": "leo@leo-optp.ca",
        "id": 1,
        "modified_at": "2017-07-05T15:51:48.601194+00:00",
        "name": "Leo opto",
        "owner_id": 2,
        "phone": "4446568989",
        "postal_code": "g1g1g1",
        "province": "qc",
        "street_address": "12 test rd"
    },
    "status_code": 200
}

HTTP Request

PUT-PATCH https://api.opfront.ca/stores/{store_id}

URL Parameters

Parameter Description
store_id ID of the store to update

Request Body

All writeable store fields can be set in the request body.

Delete a Store

Example Request

from opfront import OpfrontSession

client = OpfrontSession(
    email="test@test.ca",
    password="12345"
)

store_id = 12
store = client.store.get(store_id)

store.delete()
# OR
client.store.delete(store_id)
curl "/stores/12"
    -X DELETE \
    -H "X-Auth-Token: YOUR_TOKEN"

Example Response

{
    "status_code": 204,
    "data": {}
}

HTTP Request

DELETE https://api.opfront.ca/stores/{store_id}

URL Parameters

Parameter Description
store_id ID of the store to delete