# Account orders

Source: https://developers.swell.is/frontend-api/account-orders

**Swell.js:**

Methods to manage orders placed by a customer.

#### List account orders

Return a list of orders placed by a customer, with offset pagination using `limit` and `page`.

You can also use the same method to return orders that have shipments with tracking information.

**List account orders**

**swell.js** `With offset pagination`

```javascript
await swell.account.listOrders({
  limit: 10,
  page: 2
})
```

**swell.js** `With shipments`

```javascript
await swell.account.listOrders({
  expand: 'shipments'
})
```

#### Get an account order

Return a single account order by ID.

**Get an account order**

**swell.js**

```javascript
await swell.account.getOrder('5fab561fb4a4d83c776f45bd')
```

**GraphQL:**

Methods to manage orders placed by a customer.

### List account orders

Return a list of orders placed by a customer. The parameters for the `getOrders` query are `_locale` and `_currency`.

You can also use the same query to return shipments with tracking information.

**List account orders**

**GraphQL** `With order details`

```graphql
query getOrders {
  account {
    orders {
      id
      dateCreated
      number
      accountId
      items {
        productId
        price
        quantity
      }
      grandTotal
      paid
      delivered
      billing {
        firstName
        lastName
        address1
        city
        zip
        state
        country
      }
      shipping {
        firstName
        lastName
        address1
        city
        zip
        state
        country
      }
    }
  }
}
```

**GraphQL** `With shipment details`

```graphql
query getOrdersWithShipments {
  account {
    orders {
      shipments {
        count
        results {
          dateCreated
          number
          canceled
          items {
            productId
            quantity
          }
          origin {
            location
          }
          destination {
            name
            address1
            city
            state
            zip
            country
          }
          service
          carrier
          trackingCode
          dateEstimated
        }
      }
    }
  }
}
```

### Get an account order

Return a single account order by order ID or order number.

The parameters for the `getOrderById` query are `id` (required), `_locale`, and `_currency`.

The parameters for the `getOrderByNumber` query are `number` (required), `_locale`, and `_currency`.

**Get an account order**

**GraphQL** `By order id`

```graphql
query getOrderById {
  orderById(id: "62acbadb3edcc300128d4178") {
    id
    dateCreated
    accountId
    items {
      productId
      price
      quantity
    }
    grandTotal
    paid
    delivered
    billing {
      firstName
      lastName
      address1
      city
      zip
      state
      country
    }
    shipping {
      firstName
      lastName
      address1
      city
      zip
      state
      country
    }
  }
}
```

**GraphQL** `By order number`

```graphql
query getOrderByNumber {
  orderByNumber(number: "100023") {
    id
    dateCreated
    accountId
    items {
      productId
      price
      quantity
    }
    grandTotal
    paid
    delivered
    billing {
      firstName
      lastName
      address1
      city
      zip
      state
      country
    }
    shipping {
      firstName
      lastName
      address1
      city
      zip
      state
      country
    }
  }
}
```
