{
  "id": "sdkProfileToSheets",
  "name": "SDK · Public profile to Google Sheets",
  "nodes": [
    {
      "id": "run-manually",
      "name": "Run manually",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ],
      "parameters": {}
    },
    {
      "id": "profile-url",
      "name": "Profile URL",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        240,
        0
      ],
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "profile-url",
              "name": "profile_url",
              "type": "string",
              "value": "REPLACE_WITH_A_PUBLIC_PROFILE_URL"
            }
          ]
        },
        "options": {}
      }
    },
    {
      "id": "get-sdk-profile",
      "name": "Get SDK profile",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        480,
        0
      ],
      "parameters": {
        "url": "https://api.socialdatakit.com/v1/workflows/profile",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "url",
              "value": "={{ $json.profile_url }}"
            },
            {
              "name": "cache_max_age",
              "value": "1d"
            }
          ]
        },
        "options": {
          "timeout": 35000,
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        }
      }
    },
    {
      "id": "profile-columns",
      "name": "Profile columns",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        720,
        0
      ],
      "parameters": {
        "jsCode": "return $input.all().map(item => ({json: item.json.data}));"
      }
    },
    {
      "id": "append-to-google-sheets",
      "name": "Append to Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        960,
        0
      ],
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "REPLACE_WITH_SPREADSHEET_ID",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "SDK Profiles",
          "mode": "name"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "url": "={{ $json.url ?? \"\" }}",
            "platform": "={{ $json.platform ?? \"\" }}",
            "identifier": "={{ $json.identifier ?? \"\" }}",
            "display_name": "={{ $json.display_name ?? \"\" }}",
            "entity_id": "={{ $json.entity_id ?? \"\" }}",
            "followers": "={{ $json.followers ?? \"\" }}",
            "following": "={{ $json.following ?? \"\" }}",
            "posts": "={{ $json.posts ?? \"\" }}",
            "likes": "={{ $json.likes ?? \"\" }}",
            "total_views": "={{ $json.total_views ?? \"\" }}",
            "observed_at": "={{ $json.observed_at ?? \"\" }}",
            "rounded_fields": "={{ $json.rounded_fields ?? \"\" }}",
            "status": "={{ $json.status ?? \"\" }}",
            "error_code": "={{ $json.error_code ?? \"\" }}",
            "data_mode": "={{ $json.data_mode ?? \"\" }}"
          },
          "schema": [
            {
              "id": "url",
              "displayName": "url",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "platform",
              "displayName": "platform",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "identifier",
              "displayName": "identifier",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "display_name",
              "displayName": "display_name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "entity_id",
              "displayName": "entity_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "followers",
              "displayName": "followers",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "following",
              "displayName": "following",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "posts",
              "displayName": "posts",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "likes",
              "displayName": "likes",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "total_views",
              "displayName": "total_views",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "observed_at",
              "displayName": "observed_at",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "rounded_fields",
              "displayName": "rounded_fields",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "status",
              "displayName": "status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "error_code",
              "displayName": "error_code",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "data_mode",
              "displayName": "data_mode",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {
          "cellFormat": "RAW"
        }
      }
    },
    {
      "id": "setup-instructions",
      "name": "Setup instructions",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        200,
        -300
      ],
      "parameters": {
        "content": "## SDK profile → Google Sheets\n1. Import sdk-profile-columns.csv into a sheet named SDK Profiles.\n2. Set Profile URL.\n3. Get SDK profile: select Header Auth credential, name x-api-key, value your SDK key. Use sc_test_ first for free samples.\n4. Append to Google Sheets: connect Google and set the spreadsheet ID.\n5. Run manually. Live fresh requests use 1 credit; cached responses are free.\nOptional: replace manual trigger with Schedule Trigger after testing. No credentials are embedded.",
        "height": 260,
        "width": 700
      }
    }
  ],
  "connections": {
    "Run manually": {
      "main": [
        [
          {
            "node": "Profile URL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Profile URL": {
      "main": [
        [
          {
            "node": "Get SDK profile",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get SDK profile": {
      "main": [
        [
          {
            "node": "Profile columns",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Profile columns": {
      "main": [
        [
          {
            "node": "Append to Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {},
  "tags": []
}
