Fake Store API Carts API

Shopping cart operations.

Operations 5

GET /carts Get all carts #
POST /carts Add a new cart #
GET /carts/{id} Get a single cart #
PUT /carts/{id} Update a cart #
DELETE /carts/{id} Delete a cart #

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/fake-store-api:fake-store-api-carts-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

fake-store-api-carts-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: FakeStore Carts API
  description: A free fake API for testing and prototyping e-commerce applications.
  version: old-version-production
  contact:
    email: support@fakestoreapi.com
    url: https://fakestoreapi.com/docs
  x-logo:
    url: /icons/logo.png
    href: /
servers:
- url: https://fakestoreapi.com
tags:
- name: Carts
  x-displayName: 🛍️ Carts
paths:
  /carts:
    get:
      summary: Get all carts
      description: Retrieve a list of all available carts.
      operationId: getAllCarts
      tags:
      - Carts
      x-code-samples:
      - lang: javascript
        label: JavaScript (Browser)
        source: "fetch('https://fakestoreapi.com/carts')\n  .then(response => response.json())\n  .then(data => console.log(data));"
      - lang: nodejs
        label: Node.js (Axios)
        source: "const axios = require('axios');\naxios.get('https://fakestoreapi.com/carts')\n  .then(response => console.log(response.data));"
      - lang: php
        label: PHP
        source: "<?php\n  $response = file_get_contents('https://fakestoreapi.com/carts');\n  echo $response;\n?>"
      - lang: curl
        label: cURL
        source: curl -X GET 'https://fakestoreapi.com/carts'
      - lang: python
        label: Python
        source: 'import requests

          response = requests.get(''https://fakestoreapi.com/carts'')

          print(response.json())'
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Cart'
        '400':
          description: Bad request
    post:
      summary: Add a new cart
      description: Create a new cart.
      operationId: addCart
      tags:
      - Carts
      x-code-samples:
      - lang: javascript
        label: JavaScript (Browser)
        source: "const cart = { userId: 1, products: [{ id: 1 }] };\nfetch('https://fakestoreapi.com/carts', {\n  method: 'POST',\n  headers: { 'Content-Type': 'application/json' },\n  body: JSON.stringify(cart)\n})\n  .then(response => response.json())\n  .then(data => console.log(data));"
      - lang: nodejs
        label: Node.js (Axios)
        source: "const axios = require('axios');\nconst cart = { userId: 1, products: [{ id: 1 }] };\naxios.post('https://fakestoreapi.com/carts', cart)\n  .then(response => console.log(response.data));"
      - lang: php
        label: PHP
        source: "<?php\n  $cart = json_encode(['userId' => 1, 'products' => [['id' => 1]]]);\n  $ch = curl_init('https://fakestoreapi.com/carts');\n  curl_setopt($ch, CURLOPT_POST, 1);\n  curl_setopt($ch, CURLOPT_POSTFIELDS, $cart);\n  curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);\n  $response = curl_exec($ch);\n  curl_close($ch);\n  echo $response;\n?>"
      - lang: curl
        label: cURL
        source: 'curl -X POST ''https://fakestoreapi.com/carts'' -H ''Content-Type: application/json'' -d ''{"userId": 1, "products": [{"id": 1}]}'''
      - lang: python
        label: Python
        source: 'import requests

          cart = {''userId'': 1, ''products'': [{''id'': 1}]}

          response = requests.post(''https://fakestoreapi.com/carts'', json=cart)

          print(response.json())'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Cart'
      responses:
        '201':
          description: Cart created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Cart'
        '400':
          description: Bad request
  /carts/{id}:
    get:
      summary: Get a single cart
      description: Retrieve details of a specific cart by ID.
      operationId: getCartById
      tags:
      - Carts
      x-code-samples:
      - lang: javascript
        label: JavaScript (Browser)
        source: "fetch('https://fakestoreapi.com/carts/1')\n  .then(response => response.json())\n  .then(data => console.log(data));"
      - lang: nodejs
        label: Node.js (Axios)
        source: "const axios = require('axios');\naxios.get('https://fakestoreapi.com/carts/1')\n  .then(response => console.log(response.data));"
      - lang: php
        label: PHP
        source: "<?php\n  $response = file_get_contents('https://fakestoreapi.com/carts/1');\n  echo $response;\n?>"
      - lang: curl
        label: cURL
        source: curl -X GET 'https://fakestoreapi.com/carts/1'
      - lang: python
        label: Python
        source: 'import requests

          response = requests.get(''https://fakestoreapi.com/carts/1'')

          print(response.json())'
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Cart'
        '400':
          description: Bad request
    put:
      summary: Update a cart
      description: Update an existing cart by ID.
      operationId: updateCart
      tags:
      - Carts
      x-code-samples:
      - lang: javascript
        label: JavaScript (Browser)
        source: "const cart = { userId: 1, products: [{ id: 2 }] };\nfetch('https://fakestoreapi.com/carts/1', {\n  method: 'PUT',\n  headers: { 'Content-Type': 'application/json' },\n  body: JSON.stringify(cart)\n})\n  .then(response => response.json())\n  .then(data => console.log(data));"
      - lang: nodejs
        label: Node.js (Axios)
        source: "const axios = require('axios');\nconst cart = { userId: 1, products: [{ id: 2 }] };\naxios.put('https://fakestoreapi.com/carts/1', cart)\n  .then(response => console.log(response.data));"
      - lang: php
        label: PHP
        source: "<?php\n  $cart = json_encode(['userId' => 1, 'products' => [['id' => 2]]]);\n  $ch = curl_init('https://fakestoreapi.com/carts/1');\n  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');\n  curl_setopt($ch, CURLOPT_POSTFIELDS, $cart);\n  curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);\n  $response = curl_exec($ch);\n  curl_close($ch);\n  echo $response;\n?>"
      - lang: curl
        label: cURL
        source: 'curl -X PUT ''https://fakestoreapi.com/carts/1'' -H ''Content-Type: application/json'' -d ''{"userId": 1, "products": [{"id": 2}]}'''
      - lang: python
        label: Python
        source: 'import requests

          cart = {''userId'': 1, ''products'': [{''id'': 2}]}

          response = requests.put(''https://fakestoreapi.com/carts/1'', json=cart)

          print(response.json())'
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Cart'
      responses:
        '200':
          description: Cart updated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Cart'
        '400':
          description: Bad request
    delete:
      summary: Delete a cart
      description: Delete a specific cart by ID.
      operationId: deleteCart
      tags:
      - Carts
      x-code-samples:
      - lang: javascript
        label: JavaScript (Browser)
        source: "fetch('https://fakestoreapi.com/carts/1', {\n  method: 'DELETE'\n})\n  .then(response => response.json())\n  .then(data => console.log(data));"
      - lang: nodejs
        label: Node.js (Axios)
        source: "const axios = require('axios');\naxios.delete('https://fakestoreapi.com/carts/1')\n  .then(response => console.log(response.data));"
      - lang: php
        label: PHP
        source: "<?php\n  $ch = curl_init('https://fakestoreapi.com/carts/1');\n  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');\n  $response = curl_exec($ch);\n  curl_close($ch);\n  echo $response;\n?>"
      - lang: curl
        label: cURL
        source: curl -X DELETE 'https://fakestoreapi.com/carts/1'
      - lang: python
        label: Python
        source: 'import requests

          response = requests.delete(''https://fakestoreapi.com/carts/1'')

          print(response.json())'
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
      responses:
        '200':
          description: Cart deleted successfully
        '400':
          description: Bad request
components:
  schemas:
    Cart:
      type: object
      properties:
        id:
          type: integer
        userId:
          type: integer
        products:
          type: array
          items:
            $ref: '#/components/schemas/Product'
    Product:
      type: object
      properties:
        id:
          type: integer
        title:
          type: string
        price:
          type: number
          format: float
        description:
          type: string
        category:
          type: string
        image:
          type: string
          format: uri
x-provenance:
  method: harvested
  publisher: Fake Store API
  source: https://fakestoreapi.com/docs-data
  note: split by refine-openapis from the provider's own published document, verified by fetch (openapi/_original/*.fetch.json);
    stamped by stamp-openapi-provenance.py (roadmap#793)