API Introduction

In this section you will learn how to interact with our web service and connect with our orering platform. As you go through the documentation of the different endpoints, you may want to test how our API works and what can you get from it.

Basic Concepts

The IFS web service is built on tried and true data transfer standards. Our API is built on the Representational State Transfer (REST) protocol. It is worth gleaning A basic understanding of REST if you do not already as it will make incorporating our web services much easier.

As with most REST services our endpoints often use the same parameters with your different GETs, POSTs, PUTs and DELETEs. The specific characteristics are detailed on our API Reference Page

API URL Convention

API calls use a strict and predictable convention within their URLs. Documented below are the individual pieces to a web service URL.

URL Segments

Base

The base url for all api calls begins with "api" after the host URL.

http://www.nwframing.com/IFS/api

Role

API calls require that a role assigned by us be used in the webservice URL. The role provided is validated against your IFS account and is also used to get or post information to your organization.

http://www.nwframing.com/IFS/api/{role}

ID*

Some api calls such getting a specific order's detail require an id to be supplied in the URL. ID typically represents an index identifier needed to call a specific data set. For instance when getting an order's detail, id represents the order's order number.

The id url segment is skipped on calls that do not require it.

http://www.nwframing.com/IFS/api/{role}/{api_call}/{id*}

Here is an example of an API call to retrieve details for an order with the order number "10" where the organization (role) is named "Sprockets".

Parameters

Many api calls require extra parameters to be sent in the request's query string.

http://www.nwframing.com/IFS/api/{role}/{api_call}/{id*}?{parameters}

Here is an example of an API call to retrieve a summary of new orders if your organization (role) is named "Sprockets".

Authentication

The IFS webservice uses basic authentication to validate requests. Basic authentication requires a user name and password passed in the request header as a Base64 encoded string. Applying the encoding depends on your platform. An example of how to do this using cURL is provided below.

cURL example in PHP

This code demonstrates how to set basic authentication in the headers. This is only part of a request.


$headers = array(
    'Authorization: Basic '. base64_encode("user:password")
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

Sending a request

All requests must be sent over http (web) protocol. The method of transport is largely up to your toolset. Below is an example provided in PHP.

cURL request example in PHP

This code demonstrates how to make an entire API call using PHP and cURL. For this particular demonstration we will be querying new orders.



/* Setup your parameters */
$username = 'someone@somewhere.com';
$password = 'secret';
$baseURL = 'http://www.nwframing.com/IFS/api/Sprockets';
$apiCall = 'Orders';
$parameters = 'status=new';
/* http://www.nwframing.com/IFS/api/Sprockets/Orders?status=new; */
$host = $baseURL.'/'.$apiCall.'?'.$parameters;

/* Setup cURL */
$process = curl_init($host);
/* Optional to receive a JSON encoded repsonse */
curl_setopt($process, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($process, CURLOPT_HEADER, 1);

/* This encodes the user name and password in base64 */
curl_setopt($process, CURLOPT_USERPWD, $username . ":" . $password);
curl_setopt($process, CURLOPT_TIMEOUT, 30);
curl_setopt($process, CURLOPT_RETURNTRANSFER, TRUE);
$return = curl_exec($process);
curl_close($process);

Additional Notes

Creating Orders

Submitted orders are imported in 30 minute intervals thus will not immediately display on your orders list. Note that all SKU’s must be setup in our system prior to being submitted with an order. If an order is submitted with a SKU that isn’t on your list of SKU’s then it won’t be imported into our system.

Error Codes & Reponses

200
OK
Successful Request.
201
Created
Element has been created.
400
BadRequest
Format of request is invalid.
404
NotFound
The api call does not exist
401
Unauthorized
Your credentials are invalid or expired.
403
Access Denied
You do not have premission to access or post data with the given call.
500
Internal Server Error
Something went wrong... Very very wrong.

Resources

Webhooks

Webhooks event driven HTTP callbacks that send data to a URL endpoint you define. Given the correct permissions, you can setup your webhooks by logging, navigating to the dashboard, clicking on your profile and then clicking the webhooks link.

Webhook Response Format

You can decide whether the data sent to your endpoint is formatted as JSON or XML.

Webhook Explorer