Product API
Fulfillment guide
Store Locator

Store Locator

Find nearby stores

Example request

var request = require("request");
 
var options = {
  method: 'POST',
  url: 'https://api.foodin.ai/stores/,
  headers: {
    'Accept': 'application/json',
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  json: {
    "find_by": {
      "address_line_1": "50 Beale St",
      "postal_code": "94105"
    }
  }
};
 
request(options, function (error, response, body) {
  if (error) throw new Error(error);
 
  console.log(body);
});

The response contains the array of store locations near the address.

Example response

{
  "stores": [
    {
      "store_id": "123",
      "name": "Example Location 1",
      "location_code": "123-4567",
      "address": "123 Main St",
      "city": "San Francisco",
      "postal_code": "94105",
      "flags": {
        "alcohol": true,
        "pickup": false,
        "pickup_only": false
      }
    },
    {
      "store_id": "124",
      "name": "Example Location 2",
      "location_code": "123-4678",
      "address": "456 Park Ave",
      "city": "San Francisco",
      "postal_code": "94105",
      "flags": {
        "alcohol": true,
        "pickup": false,
        "pickup_only": false
      }
    },
    {
      "store_id": "125",
      "name": "Example Location 3",
      "location_code": "123-4789",
      "address": "789 Market St",
      "city": "San Francisco",
      "postal_code": "94105",
      "flags": {
        "alcohol": false,
        "pickup": false,
        "pickup_only": false
      }
    }
  ],
  "is_partial": false
}

From the response returned in your development environment, choose a store to use in this tutorial. You'll substitute the location code for the variable <location_code> in requests.

Create a Foodin user account

The user account should contain the minimum information required by Foodin to create and fulfill an order. The account must have at least a unique user ID and the customer's first name. The user ID is defined by you, but it must be unique for all store customers. For example, you might choose user names or loyalty card IDs.

Example request

{ var request = require("request");
 
var options = {
    method: 'POST',
    url: 'https://api.foodin.ai/users',
    headers: {
        'Accept': 'application/json',
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json'
    },
    body: {
        "user_id": "kamalsingh1234",
        "first_name": "kamal",
        "last_name": "singh",
        "phone_number": "8005550101"
    },
    json: true
};
 
request(options, function (error, response, body) {
    if (error) throw new Error(error);
 
    console.log(body);
});
 

Example response

{
  "user_id": "kamalsingh1234",
  "first_name": "Kamal",
  "last_name": "Singh",
  "phone_number": "8005550101"
}

If the user account already exists, for example if you or someone else has tried this tutorial on your development environment recently, the request returns the status code 400 User already created. You can continue the tutorial with this ID or call the method again with a different user ID.

Reserve a time slot for delivery

Example request

const request = require("request");
 
const options = {
  method: "POST",
  url: " https://api.foodin.ai/users/kamalsingh1234/service_options/cart/delivery",
  headers: {
    Accept: "application/json",
    Authorization: "Bearer YOUR_API_KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    address: {
      address_line_1: "50 Beale St",
      postal_code: "94105",
    },
    items: [
      {
        line_num: "1",
        count: 10,
        weight: 1,
        item: {
          upc: "<item_upc>",
        },
      },
    ],
    location_code: "<location_code>",
  }),
};
 
request(options, (error, response) => {
  if (error) throw new Error(error);
  console.log(response.body);
});

The response contains a list of available time slots. Timestamps are returned in Coordinated Universal Time (UTC).

Example response

{
    "service_options": [
        {
            "id": 3310259,
            "date": "2021-06-04",
            "window": {
                "immediate_hour": 2
            },
            "availability": {
                "available": true,
                "reasons": [],
                "item_codes": []
            }
        },
    ...
  ]
}