{
 "openapi": "3.1.0",
 "info": {
  "title": "WAKENEX research API",
  "version": "1.0.0",
  "description": "WAKENEX is independent systems research on finance, AI and the creator economy. Each piece takes one real event, explains the system behind it, who gains and who pays, gives the strongest counter-argument, and names the evidence that would change our mind. English first, with a Chinese edition of every piece. Read-only, no key needed. Each piece has a canonical page URL and a ready-made cite_as line (title, date, URL). Financial pieces are research, not investment advice.",
  "license": {
   "name": "© WAKENEX. You may quote and summarise with attribution and a link to the canonical URL."
  }
 },
 "servers": [
  {
   "url": "https://wakenex.com"
  }
 ],
 "paths": {
  "/api/search": {
   "get": {
    "operationId": "searchWakenex",
    "summary": "Search WAKENEX essays and notes",
    "parameters": [
     {
      "name": "q",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string",
       "maxLength": 200
      },
      "description": "Search words in English or Chinese. Empty returns the newest pieces."
     },
     {
      "name": "lang",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string",
       "enum": [
        "en",
        "zh"
       ]
      },
      "description": "Language of titles and snippets (default: detected from the query, else en)."
     },
     {
      "name": "kind",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string",
       "enum": [
        "article",
        "note",
        "concept"
       ]
      }
     },
     {
      "name": "limit",
      "in": "query",
      "required": false,
      "schema": {
       "type": "integer",
       "minimum": 1,
       "maximum": 20,
       "default": 8
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Results, best first",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/SearchResponse"
        }
       }
      }
     }
    }
   }
  },
  "/api/content/{kind}/{slug}": {
   "get": {
    "operationId": "getWakenexPiece",
    "summary": "Full text of one essay or note (Markdown, English and Chinese)",
    "parameters": [
     {
      "name": "kind",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "enum": [
        "article",
        "note",
        "concept"
       ]
      }
     },
     {
      "name": "slug",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "lang",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string",
       "enum": [
        "en",
        "zh"
       ]
      },
      "description": "Language of titles and snippets (default: detected from the query, else en)."
     }
    ],
    "responses": {
     "200": {
      "description": "The piece",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Piece"
        }
       }
      }
     },
     "404": {
      "description": "No such piece"
     }
    }
   }
  }
 },
 "components": {
  "schemas": {
   "Result": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string"
     },
     "kind": {
      "type": "string"
     },
     "title": {
      "type": "string"
     },
     "url": {
      "type": "string"
     },
     "snippet": {
      "type": "string"
     },
     "published": {
      "type": "string"
     },
     "markdown": {
      "type": "string"
     }
    }
   },
   "SearchResponse": {
    "type": "object",
    "properties": {
     "query": {
      "type": "string"
     },
     "lang": {
      "type": "string"
     },
     "total": {
      "type": "integer"
     },
     "results": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/Result"
      }
     },
     "cite": {
      "type": "string"
     }
    }
   },
   "Piece": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string"
     },
     "kind": {
      "type": "string"
     },
     "url": {
      "type": "string"
     },
     "title": {
      "type": "string"
     },
     "published": {
      "type": "string"
     },
     "lang": {
      "type": "string"
     },
     "text": {
      "type": "string"
     },
     "cite_as": {
      "type": "string"
     },
     "license": {
      "type": "string"
     }
    }
   }
  }
 }
}
