npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

extra-chicken

v1.0.1

Published

Extra chicken is an unofficial Chipotle API wrapper that allows you to programatically interact with the Chipotle website to view stores, menus, place orders, and more.

Downloads

2

Readme

Extra Chicken - An unofficial Chipotle API wrapper

Extra chicken is an unofficial Chipotle API wrapper that allows you to programatically interact with the Chipotle website to view stores, menus, place orders, and more.

Table of Contents

Installation

Usage Examples

API Documentation

Installation

npm install extra-chicken

Usage Examples

Initialize Chipotle Object

import Chipotle from 'extra-chicken' 

// creates a non-headless puppeteer instance that logs into the Chipotle site with the specified credentials
const chip = await Chipotle.create("[email protected]", "account-password", false)

Fetch the closest restaurant and get its menu

lat = 0 
long = 0
proximity = 10000
restaurants = await chip.searchRestaurants(lat, long, proximity)
const closestRestaurant = restaurants[0]
const menu = await chip.getRestaurantMenu(closestRestaurant.restaurantNumber)

Add Cart Items and Checkout

Notes about the cart and checkout process

  • Chipotle checkout requires the use of a saved credit card. Make sure you have a credit card saved on your Chipotle account if you plan to use automated checkout.

  • Chipotle carts use ETags which are returned in a header with every cart related action. All cart/order related methods will return an array with the first element being the data and the second element is the ETag required to continue modifying the cart.

const restaurantId = 3171
const [order, eTag] = await chip.createOrder(restaurantId) 
const [atcResponse, eTag2] = await chip.addItemToCart(
    order.orderId, 
    eTag, 
    "test", 
    [{ 
       "menuItemId":"CMG-101",
		"menuItemName":"Chicken Bowl",
		"quantity":1,
		"contents":[
		   {
			  "menuItemId":"CMG-5101",
			  "menuItemName":"Fajita Veggies",
			  "quantity":1,
			  "isUpSell":false,
			  "customizationId":2
		   },
		   {
			  "menuItemId":"CMG-5002",
			  "menuItemName":"Brown Rice",
			  "quantity":1,
			  "isUpSell":false,
			  "customizationId":2
		   },
		   {
			  "menuItemId":"CMG-5051",
			  "menuItemName":"Black Beans",
			  "quantity":1,
			  "isUpSell":false,
			  "customizationId":2
		   }
    }] as CreateOrderEntree[],
    [{
      "menuItemId": "CMG-4025",
		"menuItemName": "Tortilla on the Side",
		"quantity": 1,
		"isUpSell": false
    }] as CreateOrderContent[],
    [{
        "menuItemId":"CMG-2019",
        "menuItemName":"22 fl oz Tractor Organic Watermelon Limeade",
        "quantity":1,
        "isUpSell":false
    }] as CreateOrderContent[]
)
const [addUtensilsResponse, eTag3] = await chip.addUtensilsToOrder(order.orderId, eTag2)
// set the browser's stored order 
await chip.changeStoredOrder(eTag3, addUtensilsResponse.order) 

// poll pickup times 
const pickupTimes = await chip.getRestaurantPickupTimes(restaurantId)
// checkout order and pickup ASAP and pay with the card ending in 5432
const orderResult = await chip.browserCheckout(pickupTimes[0], "5432") 

API Documentation

Chipotle

The class representing the Chipotle API wrapper.

Kind: global class

chipotle.getToken() ⇒ string

Gets the JWT token associated with the object.

Kind: instance method of Chipotle
Returns: string - The JWT token.

chipotle.setUserAgent(userAgent)

Sets the browser's user agent.

Kind: instance method of Chipotle

| Param | Type | Description | | --- | --- | --- | | userAgent | string | The user agent. |

chipotle.searchRestaurants(latitude, longitude, searchRadius) ⇒ Array<Restaurant>

Searches for Chipotles near a lat long.

Kind: instance method of Chipotle
Returns: Array<Restaurant> - A list of restaurants near the location provided.

| Param | Type | Description | | --- | --- | --- | | latitude | number | The latitude of the location to search in. | | longitude | number | The longitude of the location to search in. | | searchRadius | number | The search radius. Unknown unit. Might be feet? |

chipotle.getRestaurantMenu(restaurantId) ⇒ GetMenuResponse

Gets a restaurant's menu.

Kind: instance method of Chipotle
Returns: GetMenuResponse - A response object containing the menu and store id.

| Param | Type | Description | | --- | --- | --- | | restaurantId | number | The id number of the restaurant. |

chipotle.createOrder(restaurantId) ⇒ Array<{order: Order, eTag: string}>

Creates an empty order.

Kind: instance method of Chipotle
Returns: Array<{order: Order, eTag: string}> - An order object as well as the associated ETag. The ETag is required to modify the order further (e.g. atc).

| Param | Type | Description | | --- | --- | --- | | restaurantId | number | The id number of the desired restaurant. |

chipotle.addItemToCart(orderId, eTag, mealName, entrees, sides, drinks) ⇒ Array<{addToOrderResponse: AddToOrderResponse, eTag: string}>

Adds item(s) to the specified cart.

Kind: instance method of Chipotle
Returns: Array<{addToOrderResponse: AddToOrderResponse, eTag: string}> - A response body containing the mealId, order contents, and swapped entrees. The second return value is the ETag.

| Param | Type | Description | | --- | --- | --- | | orderId | string | The target order id. | | eTag | string | The most recent ETag associated with the order. This is returned from createOrder and all order related methods. | | mealName | string | The name of the meal. This is commonly the customers name. | | entrees | Array<CreateOrderEntree> | An array of entrees to add to the order. | | sides | Array<CreateOrderContent> | An array of sides to add to the order. | | drinks | Array<CreateOrderContent> | An array of drinks to add to the order. |

chipotle.addUtensilsToOrder(orderId, eTag) ⇒ Array<{addUtensilsResponse: AddUtensilsResponse, ETag: string}>

Adds utensils to an order.

Kind: instance method of Chipotle
Returns: Array<{addUtensilsResponse: AddUtensilsResponse, ETag: string}> - A response body containing the utensil item id and the order body.

| Param | Type | Description | | --- | --- | --- | | orderId | string | The target order id. | | eTag | string | The most recent ETag associated with the order. This is returned from createOrder and all order related methods. |

chipotle.getWallet() ⇒ Array<Wallet>

Gets a list of saved payment methods.

Kind: instance method of Chipotle
Returns: Array<Wallet> - A list of saved payment methods.

chipotle.getRestaurantPickupTimes(restaurantId) ⇒ Array<string>

Gets a list of available pickup times at a specified restaurant.

Kind: instance method of Chipotle
Returns: Array<string> - An array of pickup times. The time is formatted YYYY-MM-DDTHH:MM:SS.

| Param | Type | Description | | --- | --- | --- | | restaurantId | number | The id of the target restaurant. |

chipotle.changeStoredOrder(eTag, order)

Changes the stored order data on the browser instance.

Kind: instance method of Chipotle

| Param | Type | Description | | --- | --- | --- | | eTag | string | The most recent ETag associated with the order. | | order | Order | The order body to save. |

chipotle.browserAtc(entree, drinks, sides, mealName, utensils)

Adds an entree + sides + drinks to cart using the browser. Not recommended to use over the changeStoredOrder and addItemToCart methods beucase it's prone to runtime errors and is slower than alternative methods.

Kind: instance method of Chipotle

| Param | Type | Description | | --- | --- | --- | | entree | CreateOrderEntree | The entree object to add. | | drinks | Array<CreateOrderContent> | An array of drink objects to add. | | sides | Array<CreateOrderContent> | An array of side objects to add. | | mealName | string | The name of the meal. Typically the customer's name. | | utensils | boolean | Whether to add utensils to the order. |

chipotle.browserCheckout(pickupTime, cardLastFour) ⇒ string | Array<CheckoutError>

Checks out the browser instance's current cart.

Kind: instance method of Chipotle
Returns: string | Array<CheckoutError> - An array of checkout errors or a success message.

| Param | Type | Description | | --- | --- | --- | | pickupTime | string | The order pickup time. This should be in the same format returned in getRestaurantPickupTimes (YYYY-MM-DDTHH:MM:SS). | | cardLastFour | string | The last four digits of the saved credit card. |

chipotle.checkout(orderId, eTag, shapeHeaders, wallet, pickupTime) ⇒ AxiosResponse

Checks out a specified order. Requires shape antibot headers. I don't have access to a shape cookie api so the function is largely undocumented.

Kind: instance method of Chipotle
Returns: AxiosResponse - Returns a response object instead of just the body for debugging purposes.

| Param | Type | Description | | --- | --- | --- | | orderId | string | The target order id. | | eTag | string | The most recent ETag associated with the order. | | shapeHeaders | ShapeHeaders | An object of shape antibot headers required for order submissions. | | wallet | Wallet | The payment method wallet object returned from getWallet. | | pickupTime | string | The order pickup time. This should be in the same format returned in getRestaurantPickupTimes (YYYY-MM-DDTHH:MM:SS). |

chipotle.login(email, password, [maxAttempts])

Logs the browser instance into a Chipotle account.

Kind: instance method of Chipotle

| Param | Type | Default | Description | | --- | --- | --- | --- | | email | string | | The account email. | | password | string | | The account password. | | [maxAttempts] | number | 5 | The max amount of login retry attempts. Default is 5 attempts. |

Chipotle.create(email, password, headless, [maxAttempts])

Creates a Chipotle object. Also logs into the specified chipotle account with login().

Kind: static method of Chipotle

| Param | Type | Default | Description | | --- | --- | --- | --- | | email | string | | The account email. | | password | string | | The account password. | | headless | boolean | | Whether to start the browser in headless mode or not. | | [maxAttempts] | number | 5 | The max amount of login retry attempts. default is 5 attempts. |