{
 "openapi": "3.1.0",
 "info": {
  "title": "EGC Tracker API",
  "version": "1.0.0",
  "description": "Read-only database of which tech companies win X through their founders and employees: winning posts, the accounts behind them, and whole-team strategy. Guide for agents: https://egctracker.com/agent-guide.md"
 },
 "servers": [
  {
   "url": "https://egctracker.com/api/v1"
  }
 ],
 "security": [
  {
   "bearer": []
  },
  {}
 ],
 "paths": {
  "/lookup": {
   "get": {
    "summary": "Resolve a company, person or market name to its id",
    "description": "Not counted against the daily allowance.",
    "parameters": [
     {
      "name": "q",
      "in": "query",
      "description": "Name, @handle or market.",
      "schema": {
       "type": "string"
      },
      "required": true
     },
     {
      "name": "type",
      "in": "query",
      "description": "Restrict the search.",
      "schema": {
       "type": "string",
       "enum": [
        "auto",
        "team",
        "person",
        "market"
       ],
       "default": "auto"
      }
     },
     {
      "name": "limit",
      "in": "query",
      "description": "Rows to return, 1 to 100. Default 20.",
      "schema": {
       "type": "integer",
       "minimum": 1,
       "maximum": 100,
       "default": 20
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Resolve a company, person or market name to its id",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Envelope"
        }
       }
      }
     },
     "default": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/markets": {
   "get": {
    "summary": "List the markets with company and view counts",
    "parameters": [],
    "responses": {
     "200": {
      "description": "List the markets with company and view counts",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Envelope"
        }
       }
      }
     },
     "default": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/posts/winning": {
   "get": {
    "summary": "Winning posts: the biggest posts and biggest outliers of a window",
    "parameters": [
     {
      "name": "market",
      "in": "query",
      "description": "Market id from /markets, for example fintech or coding.",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "company",
      "in": "query",
      "description": "Team slug, to look inside one team.",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "since",
      "in": "query",
      "description": "Time window. Default 7d.",
      "schema": {
       "type": "string",
       "enum": [
        "24h",
        "7d",
        "30d"
       ],
       "default": "7d"
      }
     },
     {
      "name": "role",
      "in": "query",
      "description": "Author role.",
      "schema": {
       "type": "string",
       "enum": [
        "founder",
        "employee"
       ]
      }
     },
     {
      "name": "minFollowers",
      "in": "query",
      "description": "Only accounts with at least this many followers.",
      "schema": {
       "type": "integer"
      }
     },
     {
      "name": "maxFollowers",
      "in": "query",
      "description": "Only accounts with at most this many followers.",
      "schema": {
       "type": "integer"
      }
     },
     {
      "name": "format",
      "in": "query",
      "description": "Post format.",
      "schema": {
       "type": "string",
       "enum": [
        "text",
        "image",
        "video",
        "gif"
       ]
      }
     },
     {
      "name": "minViews",
      "in": "query",
      "description": "Only posts with at least this many views.",
      "schema": {
       "type": "integer"
      }
     },
     {
      "name": "search",
      "in": "query",
      "description": "Only posts whose text contains this.",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "sortBy",
      "in": "query",
      "description": "views, outlier (times the author's usual), recent or likes.",
      "schema": {
       "type": "string",
       "enum": [
        "views",
        "outlier",
        "recent",
        "likes"
       ],
       "default": "views"
      }
     },
     {
      "name": "order",
      "in": "query",
      "description": "Sort direction.",
      "schema": {
       "type": "string",
       "enum": [
        "desc",
        "asc"
       ],
       "default": "desc"
      }
     },
     {
      "name": "limit",
      "in": "query",
      "description": "Rows to return, 1 to 100. Default 20.",
      "schema": {
       "type": "integer",
       "minimum": 1,
       "maximum": 100,
       "default": 20
      }
     },
     {
      "name": "offset",
      "in": "query",
      "description": "Rows to skip.",
      "schema": {
       "type": "integer",
       "minimum": 0,
       "default": 0
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Winning posts: the biggest posts and biggest outliers of a window",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Envelope"
        }
       }
      }
     },
     "default": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/hooks": {
   "get": {
    "summary": "Openings, formats and lengths that win in a market, with examples",
    "parameters": [
     {
      "name": "market",
      "in": "query",
      "description": "Market id from /markets, for example fintech or coding.",
      "schema": {
       "type": "string"
      },
      "required": true
     },
     {
      "name": "since",
      "in": "query",
      "description": "Time window. Default 30d.",
      "schema": {
       "type": "string",
       "enum": [
        "24h",
        "7d",
        "30d"
       ],
       "default": "30d"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Openings, formats and lengths that win in a market, with examples",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Envelope"
        }
       }
      }
     },
     "default": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/companies": {
   "get": {
    "summary": "Companies ranked by the reach of their people",
    "parameters": [
     {
      "name": "market",
      "in": "query",
      "description": "Market id from /markets, for example fintech or coding.",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "sortBy",
      "in": "query",
      "description": "Ranking.",
      "schema": {
       "type": "string",
       "enum": [
        "views30d",
        "views7d",
        "views24h",
        "growth7d",
        "peopleTracked",
        "peopleToBrandMultiple",
        "viewsPerPerson"
       ],
       "default": "views30d"
      }
     },
     {
      "name": "minBrandFollowers",
      "in": "query",
      "description": "Brand account has at least this many followers.",
      "schema": {
       "type": "integer"
      }
     },
     {
      "name": "maxBrandFollowers",
      "in": "query",
      "description": "Brand account has at most this many followers.",
      "schema": {
       "type": "integer"
      }
     },
     {
      "name": "order",
      "in": "query",
      "description": "Sort direction.",
      "schema": {
       "type": "string",
       "enum": [
        "desc",
        "asc"
       ],
       "default": "desc"
      }
     },
     {
      "name": "limit",
      "in": "query",
      "description": "Rows to return, 1 to 100. Default 20.",
      "schema": {
       "type": "integer",
       "minimum": 1,
       "maximum": 100,
       "default": 20
      }
     },
     {
      "name": "offset",
      "in": "query",
      "description": "Rows to skip.",
      "schema": {
       "type": "integer",
       "minimum": 0,
       "default": 0
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Companies ranked by the reach of their people",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Envelope"
        }
       }
      }
     },
     "default": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/teams/{slug}": {
   "get": {
    "summary": "One team A to Z: numbers, strategy, activity, full roster, posts to study",
    "parameters": [
     {
      "name": "slug",
      "in": "path",
      "required": true,
      "description": "Team id (slug) from /lookup, for example whop.",
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "One team A to Z: numbers, strategy, activity, full roster, posts to study",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Envelope"
        }
       }
      }
     },
     "default": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/teams/{slug}/posts": {
   "get": {
    "summary": "A team's posts",
    "parameters": [
     {
      "name": "slug",
      "in": "path",
      "required": true,
      "description": "Team id (slug) from /lookup, for example whop.",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "since",
      "in": "query",
      "description": "Time window. Default 30d.",
      "schema": {
       "type": "string",
       "enum": [
        "24h",
        "7d",
        "30d"
       ],
       "default": "30d"
      }
     },
     {
      "name": "role",
      "in": "query",
      "description": "Author role.",
      "schema": {
       "type": "string",
       "enum": [
        "founder",
        "employee"
       ]
      }
     },
     {
      "name": "minFollowers",
      "in": "query",
      "description": "Only accounts with at least this many followers.",
      "schema": {
       "type": "integer"
      }
     },
     {
      "name": "maxFollowers",
      "in": "query",
      "description": "Only accounts with at most this many followers.",
      "schema": {
       "type": "integer"
      }
     },
     {
      "name": "format",
      "in": "query",
      "description": "Post format.",
      "schema": {
       "type": "string",
       "enum": [
        "text",
        "image",
        "video",
        "gif"
       ]
      }
     },
     {
      "name": "sortBy",
      "in": "query",
      "description": "views, outlier, recent or likes.",
      "schema": {
       "type": "string",
       "enum": [
        "views",
        "outlier",
        "recent",
        "likes"
       ],
       "default": "views"
      }
     },
     {
      "name": "order",
      "in": "query",
      "description": "Sort direction.",
      "schema": {
       "type": "string",
       "enum": [
        "desc",
        "asc"
       ],
       "default": "desc"
      }
     },
     {
      "name": "limit",
      "in": "query",
      "description": "Rows to return, 1 to 100. Default 20.",
      "schema": {
       "type": "integer",
       "minimum": 1,
       "maximum": 100,
       "default": 20
      }
     },
     {
      "name": "offset",
      "in": "query",
      "description": "Rows to skip.",
      "schema": {
       "type": "integer",
       "minimum": 0,
       "default": 0
      }
     }
    ],
    "responses": {
     "200": {
      "description": "A team's posts",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Envelope"
        }
       }
      }
     },
     "default": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/teams/{slug}/digest": {
   "get": {
    "summary": "What changed for one team in a window: breakouts, biggest posts, top people",
    "parameters": [
     {
      "name": "slug",
      "in": "path",
      "required": true,
      "description": "Team id (slug) from /lookup, for example whop.",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "since",
      "in": "query",
      "description": "Time window. Default 24h.",
      "schema": {
       "type": "string",
       "enum": [
        "24h",
        "7d",
        "30d"
       ],
       "default": "24h"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "What changed for one team in a window: breakouts, biggest posts, top people",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Envelope"
        }
       }
      }
     },
     "default": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/digest": {
   "get": {
    "summary": "The same digest for up to 10 teams in one call",
    "parameters": [
     {
      "name": "teams",
      "in": "query",
      "description": "Comma-separated team slugs, up to 10.",
      "schema": {
       "type": "string"
      },
      "required": true
     },
     {
      "name": "since",
      "in": "query",
      "description": "Time window. Default 24h.",
      "schema": {
       "type": "string",
       "enum": [
        "24h",
        "7d",
        "30d"
       ],
       "default": "24h"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "The same digest for up to 10 teams in one call",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Envelope"
        }
       }
      }
     },
     "default": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/people": {
   "get": {
    "summary": "Founders and employees ranked by reach",
    "parameters": [
     {
      "name": "market",
      "in": "query",
      "description": "Market id from /markets, for example fintech or coding.",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "company",
      "in": "query",
      "description": "Team slug.",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "role",
      "in": "query",
      "description": "Role.",
      "schema": {
       "type": "string",
       "enum": [
        "founder",
        "employee"
       ]
      }
     },
     {
      "name": "minFollowers",
      "in": "query",
      "description": "Only accounts with at least this many followers.",
      "schema": {
       "type": "integer"
      }
     },
     {
      "name": "maxFollowers",
      "in": "query",
      "description": "Only accounts with at most this many followers.",
      "schema": {
       "type": "integer"
      }
     },
     {
      "name": "since",
      "in": "query",
      "description": "Time window. Default 30d.",
      "schema": {
       "type": "string",
       "enum": [
        "24h",
        "7d",
        "30d"
       ],
       "default": "30d"
      }
     },
     {
      "name": "sortBy",
      "in": "query",
      "description": "Ranking.",
      "schema": {
       "type": "string",
       "enum": [
        "views",
        "viewsPerFollower",
        "growth7d",
        "followers",
        "avgViewsPerPost"
       ],
       "default": "views"
      }
     },
     {
      "name": "order",
      "in": "query",
      "description": "Sort direction.",
      "schema": {
       "type": "string",
       "enum": [
        "desc",
        "asc"
       ],
       "default": "desc"
      }
     },
     {
      "name": "limit",
      "in": "query",
      "description": "Rows to return, 1 to 100. Default 20.",
      "schema": {
       "type": "integer",
       "minimum": 1,
       "maximum": 100,
       "default": 20
      }
     },
     {
      "name": "offset",
      "in": "query",
      "description": "Rows to skip.",
      "schema": {
       "type": "integer",
       "minimum": 0,
       "default": 0
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Founders and employees ranked by reach",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Envelope"
        }
       }
      }
     },
     "default": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/people/{handle}": {
   "get": {
    "summary": "One person: numbers, rank in their team, top posts",
    "parameters": [
     {
      "name": "handle",
      "in": "path",
      "required": true,
      "description": "X handle without the @.",
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "One person: numbers, rank in their team, top posts",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Envelope"
        }
       }
      }
     },
     "default": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/me": {
   "get": {
    "summary": "Your key status and how many requests are left today",
    "description": "Not counted against the daily allowance.",
    "parameters": [],
    "responses": {
     "200": {
      "description": "Your key status and how many requests are left today",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Envelope"
        }
       }
      }
     },
     "default": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/keys": {
   "post": {
    "summary": "Get a free API key",
    "security": [
     {}
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "email"
        ],
        "properties": {
         "email": {
          "type": "string",
          "format": "email"
         },
         "use": {
          "type": "string",
          "description": "What you are building (optional)."
         }
        }
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "The key, shown once",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Envelope"
        }
       }
      }
     }
    }
   }
  }
 },
 "components": {
  "securitySchemes": {
   "bearer": {
    "type": "http",
    "scheme": "bearer",
    "description": "Free key from POST /keys or https://egctracker.com/docs. Optional: without it, 50 requests a day per address."
   }
  },
  "schemas": {
   "Envelope": {
    "type": "object",
    "required": [
     "data",
     "requestId"
    ],
    "properties": {
     "data": {},
     "meta": {
      "type": "object",
      "properties": {
       "total": {
        "type": "integer"
       },
       "limit": {
        "type": "integer"
       },
       "offset": {
        "type": "integer"
       },
       "dataUpdatedAt": {
        "type": "string",
        "format": "date-time"
       }
      }
     },
     "requestId": {
      "type": "string"
     }
    }
   },
   "Error": {
    "type": "object",
    "required": [
     "error"
    ],
    "properties": {
     "error": {
      "type": "object",
      "required": [
       "code",
       "message"
      ],
      "properties": {
       "code": {
        "type": "string",
        "enum": [
         "invalid_request",
         "not_found",
         "invalid_api_key",
         "rate_limited",
         "method_not_allowed",
         "data_unavailable",
         "internal_error"
        ]
       },
       "message": {
        "type": "string"
       },
       "requestId": {
        "type": "string"
       }
      }
     }
    }
   }
  }
 }
}