{
  "openapi": "3.0.3",
  "info": {
    "title": "SocialLens (sociallens.dev) Social Media Data API",
    "description": "SocialLens (sociallens.dev) is a read API for public social media data from 9 networks (Instagram, TikTok, X, Reddit, YouTube, Facebook, LinkedIn, Threads, Pinterest). One Bearer key reads public profiles, posts, comments and follower counts as JSON, pay as you go. This is the API at api.sociallens.dev, not the unrelated sociallens MCP on Glama or any same named GitHub repo. Full docs: https://sociallens.dev/docs",
    "version": "1.0.0",
    "contact": { "name": "SocialLens", "url": "https://sociallens.dev" },
    "license": { "name": "Proprietary", "url": "https://sociallens.dev/terms" }
  },
  "servers": [
    { "url": "https://api.sociallens.dev/v1", "description": "Production" }
  ],
  "externalDocs": { "description": "SocialLens docs", "url": "https://sociallens.dev/docs" },
  "security": [ { "bearerAuth": [] } ],
  "tags": [
    { "name": "Profiles", "description": "Public profile data and follower counts" },
    { "name": "Posts", "description": "Public post data and metrics" },
    { "name": "Comments", "description": "Public comments on a post" },
    { "name": "Follows", "description": "Follower and following lists (TikTok only)" },
    { "name": "System", "description": "Key check" }
  ],
  "paths": {
    "/profile": {
      "get": {
        "tags": ["Profiles"],
        "summary": "Get a public profile",
        "description": "Public profile for one account on any of the 9 networks: followers, following, bio, avatar, verified, private and more. Returns exists=false when the account is not found. Example key: Authorization: Bearer YOUR_API_KEY",
        "operationId": "getProfile",
        "parameters": [
          { "name": "platform", "in": "query", "required": true, "description": "Network", "schema": { "type": "string", "enum": ["instagram","tiktok","x","reddit","youtube","facebook","linkedin","threads","pinterest"] } },
          { "name": "username", "in": "query", "required": true, "description": "Handle without the @", "schema": { "type": "string" }, "example": "natgeo" }
        ],
        "responses": {
          "200": { "description": "Profile data", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Profile" } } } },
          "401": { "description": "Missing or invalid API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
          "400": { "description": "Bad request", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
        }
      }
    },
    "/post": {
      "get": {
        "tags": ["Posts"],
        "summary": "Get a public post",
        "description": "Public post data and metrics by URL. Available for 8 networks (all except LinkedIn).",
        "operationId": "getPost",
        "parameters": [
          { "name": "platform", "in": "query", "required": true, "description": "Network (LinkedIn not supported here)", "schema": { "type": "string", "enum": ["instagram","tiktok","x","reddit","youtube","facebook","threads","pinterest"] } },
          { "name": "url", "in": "query", "required": true, "description": "Full URL of the post", "schema": { "type": "string" } }
        ],
        "responses": {
          "200": { "description": "Post data", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Post" } } } },
          "401": { "description": "Missing or invalid API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
        }
      }
    },
    "/profile-posts": {
      "get": {
        "tags": ["Posts"],
        "summary": "List a profile's recent posts",
        "description": "Recent public posts for one account. Available for all 9 networks.",
        "operationId": "getProfilePosts",
        "parameters": [
          { "name": "platform", "in": "query", "required": true, "description": "Network", "schema": { "type": "string", "enum": ["instagram","tiktok","x","reddit","youtube","facebook","linkedin","threads","pinterest"] } },
          { "name": "username", "in": "query", "required": true, "description": "Handle without the @", "schema": { "type": "string" } }
        ],
        "responses": {
          "200": { "description": "List of posts", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/PostList" } } } },
          "401": { "description": "Missing or invalid API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
        }
      }
    },
    "/post-comments": {
      "get": {
        "tags": ["Comments"],
        "summary": "List comments on a post",
        "description": "Public comments on one post. Available for 5 networks: TikTok, Instagram, YouTube, Facebook and Reddit.",
        "operationId": "getPostComments",
        "parameters": [
          { "name": "platform", "in": "query", "required": true, "description": "Network", "schema": { "type": "string", "enum": ["tiktok","instagram","youtube","facebook","reddit"] } },
          { "name": "url", "in": "query", "required": true, "description": "Full URL of the post", "schema": { "type": "string" } }
        ],
        "responses": {
          "200": { "description": "List of comments", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CommentList" } } } },
          "401": { "description": "Missing or invalid API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
        }
      }
    },
    "/followers": {
      "get": {
        "tags": ["Follows"],
        "summary": "List followers (TikTok only)",
        "description": "Follower list for a TikTok account, paginated by cursor. Only TikTok is supported; for the follower count on any other network use /profile.",
        "operationId": "getFollowers",
        "parameters": [
          { "name": "platform", "in": "query", "required": true, "schema": { "type": "string", "enum": ["tiktok"] } },
          { "name": "username", "in": "query", "required": true, "schema": { "type": "string" } },
          { "name": "cursor", "in": "query", "required": false, "description": "Pagination cursor from next_cursor", "schema": { "type": "string" } }
        ],
        "responses": {
          "200": { "description": "Page of followers", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/AccountList" } } } },
          "401": { "description": "Missing or invalid API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
        }
      }
    },
    "/following": {
      "get": {
        "tags": ["Follows"],
        "summary": "List following (TikTok only)",
        "description": "Following list for a TikTok account, paginated by cursor. Only TikTok is supported.",
        "operationId": "getFollowing",
        "parameters": [
          { "name": "platform", "in": "query", "required": true, "schema": { "type": "string", "enum": ["tiktok"] } },
          { "name": "username", "in": "query", "required": true, "schema": { "type": "string" } },
          { "name": "cursor", "in": "query", "required": false, "description": "Pagination cursor from next_cursor", "schema": { "type": "string" } }
        ],
        "responses": {
          "200": { "description": "Page of accounts", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/AccountList" } } } },
          "401": { "description": "Missing or invalid API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
        }
      }
    },
    "/ping": {
      "get": {
        "tags": ["System"],
        "summary": "Check the API key",
        "description": "Returns ok=true and the user_id for a valid key. No social data, no charge.",
        "operationId": "getPing",
        "responses": {
          "200": { "description": "Key is valid", "content": { "application/json": { "schema": { "type": "object", "properties": { "ok": { "type": "boolean", "example": true }, "user_id": { "type": "integer" } } } } } },
          "401": { "description": "Missing or invalid API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": { "type": "http", "scheme": "bearer", "description": "Send your key as: Authorization: Bearer YOUR_API_KEY" }
    },
    "schemas": {
      "Profile": {
        "type": "object",
        "properties": {
          "exists": { "type": "boolean", "example": true },
          "platform": { "type": "string", "example": "instagram" },
          "username": { "type": "string", "example": "natgeo" },
          "name": { "type": "string", "nullable": true },
          "followers": { "type": "integer", "nullable": true, "description": "Exact follower count when available", "example": 267180646 },
          "followers_rounded": { "type": "integer", "nullable": true, "description": "Rounded follower count" },
          "is_exact": { "type": "boolean", "description": "True when followers is the exact number" },
          "following": { "type": "integer", "nullable": true },
          "likes": { "type": "integer", "nullable": true, "description": "TikTok total likes" },
          "videos": { "type": "integer", "nullable": true },
          "verified": { "type": "boolean", "nullable": true },
          "private": { "type": "boolean", "nullable": true },
          "bio": { "type": "string", "nullable": true },
          "avatar": { "type": "string", "nullable": true, "description": "Avatar image URL" },
          "category": { "type": "string", "nullable": true },
          "external_link": { "type": "string", "nullable": true },
          "boards_count": { "type": "integer", "nullable": true, "description": "Pinterest boards" }
        },
        "required": ["exists", "platform"]
      },
      "Post": {
        "type": "object",
        "properties": {
          "exists": { "type": "boolean" },
          "platform": { "type": "string" },
          "url": { "type": "string" },
          "likes": { "type": "integer", "nullable": true },
          "comments": { "type": "integer", "nullable": true },
          "shares": { "type": "integer", "nullable": true },
          "views": { "type": "integer", "nullable": true },
          "saves": { "type": "integer", "nullable": true, "description": "Pinterest saves" },
          "caption": { "type": "string", "nullable": true },
          "created_at": { "type": "string", "nullable": true }
        },
        "required": ["exists", "platform"]
      },
      "PostList": {
        "type": "object",
        "properties": {
          "platform": { "type": "string" },
          "username": { "type": "string" },
          "posts": { "type": "array", "items": { "$ref": "#/components/schemas/Post" } }
        }
      },
      "CommentList": {
        "type": "object",
        "properties": {
          "platform": { "type": "string" },
          "url": { "type": "string" },
          "comments": { "type": "array", "items": {
            "type": "object",
            "properties": {
              "author": { "type": "string", "nullable": true },
              "text": { "type": "string", "nullable": true },
              "likes": { "type": "integer", "nullable": true },
              "created_at": { "type": "string", "nullable": true }
            }
          } }
        }
      },
      "AccountList": {
        "type": "object",
        "properties": {
          "platform": { "type": "string", "example": "tiktok" },
          "accounts": { "type": "array", "items": {
            "type": "object",
            "properties": {
              "username": { "type": "string" },
              "name": { "type": "string", "nullable": true }
            }
          } },
          "next_cursor": { "type": "string", "nullable": true, "description": "Pass as cursor to get the next page" }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": { "type": "string", "example": "invalid_token" },
          "message": { "type": "string", "example": "key missing, wrong or revoked" }
        },
        "required": ["error"]
      }
    }
  }
}
