NAV Navbar
javascript
  • Introduction
  • Warehouse API
  • Deeplink API
  • On-Store API
  • On-Store Snippet
  • Introduction

    This is a list of API's open to Loop+ customers.

    Warehouse API

    Advanced Shipping Notice

    Response

    [
        {
            "id": 12345,
            "created_at": "dd/mm/yyyy",
            "order_id": 1234567890,
            "order_name": "#1234",
            "state": "open",
            "customer_email": "me@myself.com",
            "title": "Cool Product Name",
            "variant_title": "small",
            "sku": "THX-1138",
            "carrier": "USPS",
            "label_status": "in_transit",
            "label_updated_at": "dd/mm/yyyy",
            "tracking_number": "28735625627856237856287"
        }
    ]
    

    Endpoint to pull all packages by tracking statuses/timeframe.

    Request

    GET api/v1/returns/asn?from=dd/mm/yyyy&to=dd/mm/yyyy

    Header Description
    X-Authorization Authorization token
    Query Params Description
    from ASN start date, format dd/mm/yyyy
    to ASN end date, format dd/mm/yyyy

    Process Return

    {
        "id": 12345
    }
    

    Endpoint to process returns.

    Request

    POST api/v1/returns/{return id}/process

    Header Description
    X-Authorization Authorization token

    Return Details

    {
        "id": 12345,
        "created_at": "dd/mm/yyyy",
        "order_id": 1234567890,
        "order_name": "#1234",
        "state": "open",
        "line_items": [
            {
                "provider_line_item_id": 3985739845738957
                "sku": "THX-1138"
                "title": "Shirt",
                "variant_title": "small",
                "returned_at": "2017-05-30 15:55:00"
            }
        ],
        "customer_email": "me@myself.com",
        "carrier": "USPS",
        "label_status": "in_transit",
        "label_updated_at": "dd/mm/yyyy",
        "tracking_number": "28735625627856237856287"
    }
    

    Endpoint to process returns.

    Request

    GET api/v1/returns/?<query>=<value>

    You may only use one of the querys below at a time.

    Header Description
    X-Authorization Authorization token
    Query Params Description
    return_id id of the return
    order_name name on the order of the return
    order_id id associated with the order the return was placed on

    Deeplink API

    Authentication/Setup

    Set the request headers of all API requests to the following:

    content-type: application/json

    x-authorization: <api-key>

    POST

    POST http://api.loopreturns.com/order/link
    

    Payload

    {
      "designation": 80,
      "name": "#1234",
      "zip": "44481"
    }
    

    Response

    {
      "link": "https://example.loopreturns.com/as7d687atd78attsd78tas87dt7tdt7td"
    }
    

    HTTP Request

    POST http://api.loopreturns.com/order/link

    Payload Description
    designation This is your store id.
    name The Shopify order number
    zip the shipping zip code attached to the order
    Response Description
    link Link that will take the user directly to their order

    On-Store API

    Authentication/Setup

    Set the request headers of all API requests to the following:

    content-type: application/json

    x-authorization: <api-key>

    Initial Data

    Example URL: https://example.myshopify.com/?loop_total=1299&loop_base=799&loop_credit=500&loop_subdomain=example&loop_redirect_url=example.loopreturns.com%2F%23%2Fcredit&loop_customer_name=Jane%20Doe
    

    Example of data after decoding

    {
      loop_total: 1299,
      loop_base: 799,
      loop_credit: 500,
      loop_subdomain: "example",
      loop_redirect_uri: "example.loopreturns.com/#/credit",
      loop_customer_name: "Jane Doe"
    }
    

    When a customer is dropped onto your store from the app, there will be multiple parameters in the link address. It will be up to you to URI Decode these parameters and use them for your on-store experience. The parameters are as follows:

    URL Parameters Description
    loop_total total credit after tax in cents
    loop_base total credit without tax
    loop_credit amount of bonus credit
    loop_subdomain Loop's subdomain for you
    loop_redirect_uri redirect link back to the app
    loop_customer_name name of customer on the original order

    POST

    POST http://api.loopreturns.com/api/v1/cart/
    

    Payload

    {
      cart: [
        1532560506891,
        1532560506892
      ]
    }
    

    Response

    {
      "token": "15113876394d0bdd44dbdf80596f2c774b29837ae25",
      "data": {
        "cart": [
          1532560506891,
          1532560506892
        ]
      }
    }
    

    This initial call is used to create a cart in our system. It will return a cart token that will later be passed to the returns portal for cart retrieval. The token will change with every call.

    HTTP Request

    POST http://api.loopreturns.com/api/v1/cart/

    Payload Description
    Cart Array of Variant Ids

    Our system takes the Shopify Variant Ids sent to us and generates a cart. This cart will be held for 30 days before expiring or will be deleted when the return they are attached to is processed.

    Response Description
    Token Your token for the cart.
    Cart Array of current variants attached to the token.

    Complete Transaction

    URL

    http://<subdomain>.loopreturns.com/#/cart/<token>

    URL Parameters Description
    Subdomain This is the subdomain attached to your returns portal at loopreturns.com.
    Token The token you recieved in response to the POST request

    When a customer is satisfied with their cart, they should be redirected back to the app like this. From there, we will process the token and automatically add the items to the cart. All credit and tax calculations will be accounted for at this point and displayed to the customer.

    On-Store Snippet

    setKey

    Loop.setKey(apiKey)

    Parameters Description
    apiKey STRING - Loop developer API key

    The setKey function is used to set and store your API key for your snippet to use on it's calls to the server.

    setup

    Loop.setup(mode)

    Parameters Description
    mode STRING - Loop preconfiguration option("url", "input", "option")

    url

    -Many Shopify templates use url params to keep track of their variants. This mode is created to detect the variant in the URL param and send it to the Loop Cart when a customer hits "Add to Cart".

    -If your variant param is different from the default 'variant' key, you can update it the same you you configured the Add To Cart button with "Loop.config.targets.url".

    input

    -UNDER DEVELOPMENT

    option

    -UNDER DEVELOPMENT

    updateVariant

    Loop.updateVariant(variant, callback);

    Parameters Description
    variant STRING - Shopify variant ID
    callback FUNCTION - Optional, callback function

    The updateVariant method is used to change and store the variant id help in the snippet. This is useful for binding to change events, like a swatch select or any other input change. You can use Loop.submit() with no params at anytime after this and it will use the variant id of the last update.

    submit

    Loop.submit(variant)

    Parameters Description
    variant STRING - Optional, Shopify variant ID

    The submit function is used to create a token and send you back to the loop app automatically. This is great for flows that send you back to the app when adding an item to the cart. A 'variant' param should only needs to be specified if you have not been updating the variant id already.