{
  "name": "Collect historical price data from Polymarket Up/Down markets into Supabase",
  "nodes": [
    {
      "id": "0d480251-1006-46eb-8526-5dd691b1b6e0",
      "name": "Form to include slug of the market",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -80,
        1472
      ]
    },
    {
      "id": "2b3d83c3-3956-4058-80ff-6b6d148b36e7",
      "name": "Find the Event ID from the Slug",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        160,
        1472
      ]
    },
    {
      "id": "8cb89840-af67-448d-885b-b124a60d10aa",
      "name": "Find the Series ID from the slug",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        368,
        1472
      ]
    },
    {
      "id": "a4aa1ae4-b11d-42dd-86ff-b910b35e55c4",
      "name": "Find All the Events for that Series ID",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        608,
        1472
      ]
    },
    {
      "id": "4a8f70a4-a5d6-4cbe-9bb5-70d76ffa3568",
      "name": "Split Events into Itens",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        816,
        1472
      ]
    },
    {
      "id": "d39da386-6233-473f-b482-e2e99d5b3de3",
      "name": "Register Events in Table Polymarket_Btc_1h_Event_List_1",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        1024,
        1472
      ]
    },
    {
      "id": "431fc60a-c04e-41a9-9660-8ff739c7c857",
      "name": "Start Getting Prices Data",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -80,
        1984
      ]
    },
    {
      "id": "8ff754f3-336a-4283-bec6-6b8c1bfc2324",
      "name": "Fetch 100 unprocessed events",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        144,
        1984
      ]
    },
    {
      "id": "310e269a-3a8e-43e8-81e6-9c1704dc5d57",
      "name": "Fetch UP/DOWN tokens and end time",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        384,
        1984
      ]
    },
    {
      "id": "c1b27a89-0910-4b34-95c1-a13301ee90bb",
      "name": "Store UP/DOWN tokens and end time",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        592,
        1984
      ]
    },
    {
      "id": "b5aa83a5-3b98-4d10-81fc-41df78730af5",
      "name": "Check if market has closed",
      "type": "n8n-nodes-base.if",
      "position": [
        784,
        1984
      ]
    },
    {
      "id": "3346e316-6909-4297-944a-e61ca0310024",
      "name": "Mark open markets as processed",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        960,
        1808
      ]
    },
    {
      "id": "ccf9a57d-1359-41af-a709-996e64c1335b",
      "name": "Convert end time to Unix timestamp",
      "type": "n8n-nodes-base.dateTime",
      "position": [
        1072,
        2000
      ]
    },
    {
      "id": "1e18314a-0655-48e8-a953-eefe37f6781e",
      "name": "Convert end time to numeric and set start time",
      "type": "n8n-nodes-base.set",
      "position": [
        1280,
        2000
      ]
    },
    {
      "id": "42762ec5-8f83-4ef5-9a13-930bc84be4b2",
      "name": "Fetch price history",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1520,
        2000
      ]
    },
    {
      "id": "40ffe602-3655-4129-8e82-0b62f9b5771a",
      "name": "Split prices and timestamps into arrays",
      "type": "n8n-nodes-base.set",
      "position": [
        1728,
        2000
      ]
    },
    {
      "id": "5717d052-a3c8-4a7d-922a-9f807e8e9f90",
      "name": "Store in Supabase",
      "type": "n8n-nodes-base.supabase",
      "position": [
        1936,
        2000
      ]
    },
    {
      "id": "18f6b48e-6c49-4335-8be7-72e47176aa24",
      "name": "Mark as processed",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        2144,
        2000
      ]
    },
    {
      "id": "fd90ddc5-5024-487d-a90b-61c2ce776abe",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -208,
        1776
      ],
      "parameters": {
        "width": 2544,
        "height": 448,
        "content": "## Extracts price data and stores it in Supabase in batches of 100."
      }
    },
    {
      "id": "88b1b2ba-0c41-409a-9889-4620025d8ba8",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -208,
        1376
      ],
      "parameters": {
        "width": 1504,
        "height": 320,
        "content": "## Fetches and stores all event IDs in a series based on a user-provided event slug."
      }
    },
    {
      "id": "960ff291-7985-41c6-8c39-abe14d9088e0",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -816,
        1056
      ],
      "parameters": {
        "width": 512,
        "height": 1232,
        "content": "## Tutorial\n**This n8n template retrieves historical prices from Polymarket serial markets such as Bitcoin Up or Down, S&P 500 Up or Down, and similar markets.**\n\nThe main use cases are data collectio"
      }
    },
    {
      "id": "582b8319-904e-48c1-b350-267cba30357e",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -208,
        1056
      ],
      "parameters": {
        "width": 876,
        "height": 280,
        "content": "## Slug Example\n![](https://imgur.com/StX3juA.pngfull-width)"
      }
    },
    {
      "id": "bab3e34d-59ac-4109-a1b2-a66aebf19599",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1248,
        1712
      ],
      "parameters": {
        "width": null,
        "height": 512,
        "content": "## Adjust the StartTimeUnix to match the selected market\nIn this example, StartTimeUnix is set to 1 hour before EndTimeUnix, since the sample market used has a one-hour duration. If the market is long"
      }
    }
  ],
  "connections": {
    "Mark as processed": {
      "main": [
        [
          {
            "node": "Fetch 100 unprocessed events",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Store in Supabase": {
      "main": [
        [
          {
            "node": "Mark as processed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch price history": {
      "main": [
        [
          {
            "node": "Split prices and timestamps into arrays",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Events into Itens": {
      "main": [
        [
          {
            "node": "Register Events in Table Polymarket_Btc_1h_Event_List_1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Start Getting Prices Data": {
      "main": [
        [
          {
            "node": "Fetch 100 unprocessed events",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if market has closed": {
      "main": [
        [
          {
            "node": "Mark open markets as processed",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Convert end time to Unix timestamp",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch 100 unprocessed events": {
      "main": [
        [
          {
            "node": "Fetch UP/DOWN tokens and end time",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Find the Event ID from the Slug": {
      "main": [
        [
          {
            "node": "Find the Series ID from the slug",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Find the Series ID from the slug": {
      "main": [
        [
          {
            "node": "Find All the Events for that Series ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch UP/DOWN tokens and end time": {
      "main": [
        [
          {
            "node": "Store UP/DOWN tokens and end time",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Store UP/DOWN tokens and end time": {
      "main": [
        [
          {
            "node": "Check if market has closed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert end time to Unix timestamp": {
      "main": [
        [
          {
            "node": "Convert end time to numeric and set start time",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Form to include slug of the market": {
      "main": [
        [
          {
            "node": "Find the Event ID from the Slug",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Find All the Events for that Series ID": {
      "main": [
        [
          {
            "node": "Split Events into Itens",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split prices and timestamps into arrays": {
      "main": [
        [
          {
            "node": "Store in Supabase",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert end time to numeric and set start time": {
      "main": [
        [
          {
            "node": "Fetch price history",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Register Events in Table Polymarket_Btc_1h_Event_List_1": {
      "main": [
        []
      ]
    }
  }
}