{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "215b81b2-7b82-4477-a9e7-8759b46662f0",
   "metadata": {},
   "source": [
    "# Setup - Load an API Key and Libraries"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "38e894e3",
   "metadata": {},
   "source": [
    "## Storing and Loading Your API Key Securely\n",
    "\n",
    "To securely store and use your API key in this notebook, follow these steps:\n",
    "\n",
    "1. **Generate an API key**:\n",
    "   - Follow instructions in the Getting Started documentation for Hub APIs to generate a Hub API Key.\n",
    "\n",
    "2. **Create a `.env` File**:\n",
    "   - In the same directory as this notebook, create a file named `.env`.\n",
    "   - Add the following line to the file, replacing `<your_api_key>` with your actual API key:\n",
    "     ```plaintext\n",
    "     API_KEY=<your_api_key>\n",
    "     ```\n",
    "   - Save the file.\n",
    "\n",
    "3. **Load the Key in the Notebook**:\n",
    "   - The following code snippet is already included in this notebook to load the key securely:\n",
    "     ```python\n",
    "     import os\n",
    "     from dotenv import load_dotenv\n",
    "     \n",
    "     load_dotenv(\".env\")  # Ensure the path matches your `.env` file location\n",
    "     key = os.getenv(\"API_KEY\")\n",
    "     ```\n",
    "   - This will load the `API_KEY` from your `.env` file into the `key` variable.\n",
    "\n",
    "4. **Keep the `.env` File Secure**:\n",
    "   - Do not share your `.env` file or API key.\n",
    "   - If you do accidentally share your key, delete it in the workspaces UI and request a new one.\n",
    "\n",
    "By following these steps, you can securely store and use your API key without exposing it in the notebook."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e5063414",
   "metadata": {},
   "source": [
    "## Setting Up the Workspace and Environment\n",
    "\n",
    "To ensure the notebook works correctly, you need to configure the `workspace` and `environment` variables. Follow these steps:\n",
    "1. **Ensure your workspace is configured for commercial orders**\n",
    "   - Follow instructions in the Hub documentation under `Data - Commercial` to link your commercial account to your workspace.\n",
    "2. **Set the `workspace` Variable**:\n",
    "   - In the following cell, the `workspace` variable should be set to the name of the workspace you wish to order data for.\n",
    "   - You can find the workspace name in the site UI.\n",
    "3. **Set the `environment` Variable**\n",
    "   - In the following cell, The environment variable determines which environment you are working in. It can only be one of the following values:\n",
    "     - prod (Production)\n",
    "     - staging (Staging)\n",
    "     - test (Testing)\n",
    "     - dev (Development)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9555e138-05ad-40c6-b5f6-07ab94156748",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "from dotenv import load_dotenv\n",
    "\n",
    "workspace = \"apalmer-tpzuk\"\n",
    "environment = \"prod\"\n",
    "\n",
    "load_dotenv(\".env\")\n",
    "api_key = os.getenv(\"API_KEY\")\n",
    "\n",
    "if environment == \"prod\":\n",
    "    platform_domain = \"https://prod.eodatahub.org.uk\"\n",
    "elif environment == \"staging\":\n",
    "    platform_domain = \"https://staging.eodatahub.org.uk\"\n",
    "elif environment == \"test\":\n",
    "    platform_domain = \"https://test.eodatahub.org.uk\"\n",
    "elif environment == \"dev\":\n",
    "    platform_domain = \"https://dev.eodatahub.org.uk\"\n",
    "else:\n",
    "    raise ValueError(\"Invalid environment. Choose from 'prod', 'staging', 'test', or 'dev'.\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c6f2117c-8b93-4834-8391-a727c67e70cb",
   "metadata": {},
   "outputs": [],
   "source": [
    "!pip install pystac-client xarray rasterio"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "765f67ed-a48d-4bbd-89a6-08cd52f905d3",
   "metadata": {},
   "source": [
    "# Create a pystac-client Client for the EODH Catalogue\n",
    "\n",
    "The EODH catalogue can be viewed through a UI on the Hub under the `Catalogue` tab.\n",
    "\n",
    "Our STAC catalogue can also be browsed programatically using tools such as pystac-client, using your api_key for authorisation. In the following example, our client is scoped to the Planet catalogue to refine a search for some Planet commercial data."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "97883a1a-0845-41f5-be29-7ee19e1e0fc6",
   "metadata": {},
   "outputs": [],
   "source": [
    "from pystac_client import Client\n",
    "\n",
    "# Limit scope of the top-level catalogue to Planet\n",
    "rc_url = f\"{platform_domain}/api/catalogue/stac/catalogs/commercial/catalogs/planet\"\n",
    "\n",
    "# Create STAC client\n",
    "stac_client = Client.open(rc_url, headers={\"Authorization\": f\"Bearer {api_key}\"})"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "df109ec1-82de-41ae-8b63-f525828c7f6d",
   "metadata": {},
   "source": [
    "# Search for Planet Data\n",
    "\n",
    "To demonstrate search capabilities, the following cell searches our catalogue for PSScene items that intersect a given polygon AOI."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4b9fe535-a186-44ed-8370-1c8f99078965",
   "metadata": {},
   "outputs": [],
   "source": [
    "geom = {\n",
    "    \"type\": \"Polygon\",\n",
    "    \"coordinates\": [\n",
    "        [\n",
    "            [9.6, 57.1],\n",
    "            [9.6, 57.0],\n",
    "            [9.8, 56.9],\n",
    "            [9.8, 57.0],\n",
    "            [9.6, 57.1],\n",
    "        ]\n",
    "    ],\n",
    "}\n",
    "search = stac_client.search(\n",
    "    max_items=10,\n",
    "    collections=['PSScene'],\n",
    "    intersects=geom,\n",
    ")\n",
    "for item in search.items():\n",
    "    print(item.get_self_href())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d282d3c8-fe56-4550-955b-f2edd17912fa",
   "metadata": {},
   "source": [
    "# Obtain a Quote for Planet Data\n",
    "\n",
    "Once an item of interest is found, you may obtain a quote for the item via a POST request to /quote following the item href.\n",
    "\n",
    "Change the `item_href` to any valid link to a STAC item in our Planet commercial catalogue to browse prices. Change the `coordinates` to an AOI to clip the item if required.\n",
    "\n",
    "Note: Coordinates are to be provided in longitude/latitude WGS84, and the polygon must be closed. Coordinates follow OGC GeoJSON specification.\n",
    "\n",
    "Note: Planet quotes are given in km<sup>2</sup>."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cf7d3fbf",
   "metadata": {},
   "outputs": [],
   "source": [
    "import requests\n",
    "\n",
    "item_href = \"https://staging.eodatahub.org.uk/api/catalogue/stac/catalogs/commercial/catalogs/planet/collections/PSScene/items/20250217_101155_07_24c7\"\n",
    "url = f\"{item_href}/quote\"\n",
    "headers = {\n",
    "    'accept': 'application/json', \n",
    "    'Content-Type': 'application/json', \n",
    "    'Authorization': f'Bearer {api_key}'\n",
    "}\n",
    "data =  {\n",
    "    \"coordinates\": [\n",
    "        [\n",
    "            [9.6, 57.1],\n",
    "            [9.6, 57.0],\n",
    "            [9.8, 56.9],\n",
    "            [9.8, 57.0],\n",
    "            [9.6, 57.1]\n",
    "        ]\n",
    "    ]\n",
    "}\n",
    "\n",
    "response = requests.post(url, headers=headers, json=data)\n",
    "\n",
    "print(\"Status Code\", response.status_code)\n",
    "print(\"Response \", response.json())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "992e4742",
   "metadata": {},
   "source": [
    "# Order Planet Data\n",
    "\n",
    "Once you are satisfied with the item and pricing, you may proceed with ordering the item via a POST request to /order following the item href.\n",
    "\n",
    "Change the `item_href` to any valid link to a STAC item in our Planet commercial catalogue to order it. Change the `coordinates` to an AOI to clip the item if required.\n",
    "The `productBundle` field may also be changed to adjust the processing done on the image. For details please see our guide on ordering commercial data on the Hub.\n",
    "\n",
    "Once an order is placed, the API response includes a Location header that links to the item in your workspace catalogue. This item will be updated with the order status and assets when they are ready.\n",
    "\n",
    "An order cannot be changed once it is placed, so please ensure the correct product and parameters are chosen."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e5349a0f-3747-4349-9dfd-30f12d512847",
   "metadata": {},
   "outputs": [],
   "source": [
    "import requests\n",
    "\n",
    "item_href = \"https://staging.eodatahub.org.uk/api/catalogue/stac/catalogs/commercial/catalogs/planet/collections/PSScene/items/20250217_101155_07_24c7\"\n",
    "url = f\"{item_href}/order\"\n",
    "headers = {\n",
    "    'accept': 'application/json', \n",
    "    'Content-Type': 'application/json', \n",
    "    'Authorization': f'Bearer {api_key}'\n",
    "}\n",
    "data =  {\n",
    "    \"productBundle\": \"General use\",\n",
    "    \"coordinates\": [\n",
    "        [\n",
    "            [9.6, 57.1],\n",
    "            [9.6, 57.0],\n",
    "            [9.8, 56.9],\n",
    "            [9.8, 57.0],\n",
    "            [9.6, 57.1]\n",
    "        ]\n",
    "    ]\n",
    "}\n",
    "\n",
    "response = requests.post(url, headers=headers, json=data)\n",
    "\n",
    "print(\"Status Code:\", response.status_code)\n",
    "print(\"Response:\", response.json())\n",
    "\n",
    "location_header = response.headers.get('Location')\n",
    "print(\"Item will shortly be available at:\", location_header)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "00e81bb7-5e24-4de9-baaa-9ad688e86b84",
   "metadata": {},
   "source": [
    "# Read STAC for Ordered Planet Data\n",
    "\n",
    "The STAC item can also be obtained through browsing your workspace catalogue. The following example demonstrates a search for a specific asset for an item."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "057d2a52-62c0-44c7-99b9-bcedb559c7e5",
   "metadata": {},
   "outputs": [],
   "source": [
    "from pystac import Item\n",
    "from pystac_client import CollectionClient\n",
    "\n",
    "data_i_ordered_earlier = f\"{platform_domain}/api/catalogue/stac/catalogs/user/catalogs/{workspace}/catalogs/commercial-data/catalogs/planet\"\n",
    "stac_client = Client.open(data_i_ordered_earlier, headers={\"Authorization\": f\"Bearer {api_key}\"})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "adedb354-a229-454f-bd54-c5434322d87f",
   "metadata": {},
   "outputs": [],
   "source": [
    "ordered_item = next(stac_client.get_items(\"20250217_101155_07_24c7\"))\n",
    "ordered_item"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5df62617-e8be-476e-8b5f-d684c0d0ee1c",
   "metadata": {},
   "outputs": [],
   "source": [
    "asset = ordered_item.get_assets()[\"20250217_101155_07_24c7_3B_AnalyticMS_clip.tif\"]\n",
    "asset"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "87eff8df-4daf-4d81-95b7-8f2665e2f5ec",
   "metadata": {},
   "source": [
    "# Fetch Ordered Planet Data\n",
    "\n",
    "Any asset link from a commercial data purchase can be downloaded via an authorised GET request to the asset href."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a8354c1e-fe58-4fdb-8c03-5f872c2f2c22",
   "metadata": {},
   "outputs": [],
   "source": [
    "import urllib3\n",
    "from io import BytesIO\n",
    "\n",
    "resp = urllib3.request(\"GET\", asset.href, headers={\"Authorization\": f\"Bearer {api_key}\"})\n",
    "resp.data[0:100]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8532b4f1",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "b8b59094-cf51-469d-b925-5036c473f4f7",
   "metadata": {},
   "source": [
    "# Plot Planet Data\n",
    "\n",
    "Visual assets can be viewed programmatically:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "25cdfe5c-7175-40d4-beba-3543526fd8c9",
   "metadata": {},
   "outputs": [],
   "source": [
    "from rasterio.plot import show\n",
    "import rasterio\n",
    "\n",
    "with rasterio.open(BytesIO(resp.data)) as src:\n",
    "    f = src.read()\n",
    "    fig, ax = plt.subplots(figsize=(10, 10))\n",
    "    show(f / 10000, ax=ax, title=\"PlanetScope Image\")\n",
    "    plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "21c2472d",
   "metadata": {},
   "source": [
    "# Further Visualisation of Planet Data\n",
    "\n",
    "Our TiTiler instance can also be used to visualise the data:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a610d2d5",
   "metadata": {},
   "outputs": [],
   "source": [
    "import requests\n",
    "from IPython.display import Image, display\n",
    "\n",
    "TITILER_PREVIEW_URL = f'{platform_domain}/titiler/core/cog/preview'\n",
    "TITILER_PREVIEW_PARAMS = {\n",
    "    'url': asset.href,\n",
    "    'bidx': 1,\n",
    "    'rescale': '2229,12331',\n",
    "    'colormap_name': 'rain_r'\n",
    "}\n",
    "\n",
    "response = requests.get(TITILER_PREVIEW_URL, params=TITILER_PREVIEW_PARAMS, headers={'Authorization': f'Bearer {api_key}'})\n",
    "\n",
    "# Display the image\n",
    "image = Image(response.content)\n",
    "display(image)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "10e37827",
   "metadata": {},
   "source": [
    "# Obtain a Quote for Airbus SAR Data\n",
    "\n",
    "Search and ordering capabilities are also in place for Airbus SAR items. Once an item of interest is found, you may obtain a quote for the item via a POST request to /quote following the item href.\n",
    "\n",
    "Change the `item_href` to any valid link to a STAC item in our Airbus commercial catalogue to browse prices. Change the `licence` to another supported licence if required. Supported licences are `Single User Licence`, `Multi User (2 - 5) Licence`, and `Multi User (6 - 30) Licence`.\n",
    "\n",
    "Note: Airbus SAR does not support clipping an item with an AOI."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "eb69a573",
   "metadata": {},
   "outputs": [],
   "source": [
    "import requests\n",
    "\n",
    "item_href = \"https://staging.eodatahub.org.uk/api/catalogue/stac/catalogs/commercial/catalogs/airbus/collections/airbus_sar_data/items/TSX-1_WS_S_wide_001R_97985_D33003943_29000\"\n",
    "url = f\"{item_href}/quote\"\n",
    "headers = {\n",
    "    'accept': 'application/json', \n",
    "    'Content-Type': 'application/json', \n",
    "    'Authorization': f'Bearer {api_key}'\n",
    "}\n",
    "data =  {\n",
    "    \"licence\": \"Single User Licence\",\n",
    "}\n",
    "\n",
    "response = requests.post(url, headers=headers, json=data)\n",
    "\n",
    "print(\"Status Code:\", response.status_code)\n",
    "print(\"Response:\", response.json())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "81d0c97c-62c2-47c0-8941-3bcbb8a2710a",
   "metadata": {},
   "source": [
    "# Order Airbus SAR Data\n",
    "\n",
    "Once you are satisfied with the item and pricing, you may proceed with ordering the item via a POST request to /order following the item href.\n",
    "\n",
    "Change the `item_href` to any valid link to a STAC item in our Airbus commercial catalogue to order it. Change the `licence` to another supported licence if required. Supported licences are `Single User Licence`, `Multi User (2 - 5) Licence`, and `Multi User (6 - 30) Licence`.\n",
    "\n",
    "The `productBundle` and `radarOptions` fields may also be changed to adjust the processing done on the image. Valid product bundles for SAR are `SSC`, `MGD`, `GEC`, and `EEC`. `radarOptions` include:\n",
    "  - `orbit` of `rapid` or `science`.\n",
    "  - `resolutionVariant` of `RE` or `SE`.\n",
    "  - `projection` of `Auto`, `UTM`, or `UPS`.\n",
    "  \n",
    "For further details please see Airbus documentation.\n",
    "\n",
    "Once an order is placed, the API response includes a Location header that links to the item in your workspace catalogue. This item will be updated with the order status and assets when they are ready.\n",
    "\n",
    "An order cannot be changed once it is placed, so please ensure the correct product and parameters are chosen."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "042cfc54-6acb-41bb-9e55-7d7de8b2efbc",
   "metadata": {},
   "outputs": [],
   "source": [
    "import requests\n",
    "\n",
    "item_href = \"https://staging.eodatahub.org.uk/api/catalogue/stac/catalogs/commercial/catalogs/airbus/collections/airbus_sar_data/items/TSX-1_WS_S_wide_001R_97985_D33003943_29000\"\n",
    "url = f\"{item_href}/order\"\n",
    "headers = {\n",
    "    \"accept\": \"application/json\", \n",
    "    \"Content-Type\": \"application/json\", \n",
    "    \"Authorization\": f\"Bearer {api_key}\"\n",
    "}\n",
    "data =  {\n",
    "    \"licence\": \"Single User Licence\",\n",
    "    \"productBundle\": \"SSC\",\n",
    "    \"radarOptions\": {\n",
    "        \"orbit\": \"rapid\"\n",
    "    }\n",
    "}\n",
    "\n",
    "response = requests.post(url, headers=headers, json=data)\n",
    "\n",
    "print(\"Status Code\", response.status_code)\n",
    "print(\"Response \", response.json())\n",
    "\n",
    "location_header = response.headers.get('Location')\n",
    "print(\"Item will shortly be available at:\", location_header)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4e9c5009",
   "metadata": {},
   "source": [
    "# Obtain a Quote for Airbus Optical Data\n",
    "\n",
    "Search and ordering capabilities are also in place for Airbus Optical items. Once an item of interest is found, you may obtain a quote for the item via a POST request to /quote following the item href.\n",
    "\n",
    "Change the `item_href` to any valid link to a STAC item in our Airbus commercial catalogue to browse prices. Change the `coordinates` to an AOI to clip the item if required.\n",
    "\n",
    "Note: Coordinates are to be provided in longitude/latitude WGS84, and the polygon must be closed. Coordinates follow OGC GeoJSON specification.\n",
    "\n",
    "Change the `licence` to another supported licence if required. Supported licences are:\n",
    "  - `Standard`\n",
    "  - `Background Layer`\n",
    "  - `Standard + Background Layer`\n",
    "  - `Academic`\n",
    "  - `Media Licence`\n",
    "  - `Standard Multi End-Users (2-5)`\n",
    "  - `Standard Multi End-Users (6-10)`\n",
    "  - `Standard Multi End-Users (11-30)`\n",
    "  - `Standard Multi End-Users (>30)`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "260e779e",
   "metadata": {},
   "outputs": [],
   "source": [
    "import requests\n",
    "\n",
    "item_href = \"https://staging.eodatahub.org.uk/api/catalogue/stac/catalogs/commercial/catalogs/airbus/collections/airbus_phr_data/items/DS_PHR1A_201203021558128_FR1_PX_W080S03_0221_01728\"\n",
    "url = f\"{item_href}/quote\"\n",
    "headers = {\n",
    "    'accept': 'application/json', \n",
    "    'Content-Type': 'application/json', \n",
    "    'Authorization': f'Bearer {api_key}'\n",
    "}\n",
    "data =  {\n",
    "    \"licence\": \"Standard\",\n",
    "    \"coordinates\": [\n",
    "        [\n",
    "            [-79.8,-2.1], \n",
    "            [-79.8,-2.2], \n",
    "            [-79.95,-2.2], \n",
    "            [-79.95,-2.1], \n",
    "            [-79.8,-2.1]\n",
    "        ]\n",
    "    ]\n",
    "}\n",
    "\n",
    "response = requests.post(url, headers=headers, json=data)\n",
    "\n",
    "print(\"Status Code\", response.status_code)\n",
    "print(\"Response \", response.json())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d2c3288d-e47f-4cf9-bd82-e22158d7bcb0",
   "metadata": {},
   "source": [
    "# Order Airbus Optical Data\n",
    "\n",
    "Once you are satisfied with the item and pricing, you may proceed with ordering the item via a POST request to /order following the item href.\n",
    "\n",
    "- Change the `item_href` to any valid link to a STAC item in our Airbus commercial catalogue to order it. \n",
    "- `coordinates` can optionally clip an item to an AOI.\n",
    "- `licence` must be set depending on the intended usage of the data. Supported licences are:\n",
    "  - `Standard`\n",
    "  - `Background Layer`\n",
    "  - `Standard + Background Layer`\n",
    "  - `Academic`\n",
    "  - `Media Licence`\n",
    "  - `Standard Multi End-Users (2-5)`\n",
    "  - `Standard Multi End-Users (6-10)`\n",
    "  - `Standard Multi End-Users (11-30)`\n",
    "  - `Standard Multi End-Users (>30)`\n",
    "- Set the `productBundle` field to adjust the processing done on the image. For details please see our guide on ordering commercial data on the Hub.\n",
    "- `endUserCountry` must match an Airbus country code corresponding to the user making the purchase.\n",
    "\n",
    "Once an order is placed, the API response includes a Location header that links to the item in your workspace catalogue. This item will be updated with the order status and assets when they are ready.\n",
    "\n",
    "An order cannot be changed once it is placed, so please ensure the correct product and parameters are chosen."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "38e0ae71-2271-4842-be9f-4e38720dc385",
   "metadata": {},
   "outputs": [],
   "source": [
    "import requests\n",
    "\n",
    "item_href = \"https://staging.eodatahub.org.uk/api/catalogue/stac/catalogs/commercial/catalogs/airbus/collections/airbus_phr_data/items/DS_PHR1A_201203021558128_FR1_PX_W080S03_0221_01728\"\n",
    "url = f\"{item_href}/order\"\n",
    "headers = {\n",
    "    'accept': 'application/json', \n",
    "    'Content-Type': 'application/json', \n",
    "    'Authorization': f'Bearer {api_key}'\n",
    "}\n",
    "data =  {\n",
    "    \"licence\": \"Standard\",\n",
    "    \"endUserCountry\": \"GB\",\n",
    "    \"productBundle\": \"General use\", \n",
    "    \"coordinates\": [\n",
    "        [\n",
    "            [-79.8,-2.1], \n",
    "            [-79.8,-2.2], \n",
    "            [-79.95,-2.2], \n",
    "            [-79.95,-2.1], \n",
    "            [-79.8,-2.1]\n",
    "        ]\n",
    "    ]\n",
    "}\n",
    "\n",
    "response = requests.post(url, headers=headers, json=data)\n",
    "\n",
    "print(\"Status Code:\", response.status_code)\n",
    "print(\"Response:\", response.json())\n",
    "\n",
    "location_header = response.headers.get('Location')\n",
    "print(\"Item will shortly be available at:\", location_header)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
