openapi: 3.0.0 info: title: API version: 0.0.1 servers: - url: '{env}/api/v1' variables: env: default: http://localhost:8080 enum: - http://localhost:8080 paths: /articles: get: operationId: getArticles responses: '200': {$ref: '#/components/responses/GetArticles'} '500': {$ref: '#/components/responses/ErrorMsg'} /articles/{articleRef}: get: operationId: getArticle parameters: - $ref: '#/components/parameters/articleRef' - name: track in: query required: false description: >- When true (the default) the server records a view for this request. Pass false when the caller fetches articles server-side and reports views itself through POST /articles/{articleRef}/views, so readers are not counted twice. schema: type: boolean default: true responses: '200': {$ref: '#/components/responses/GetArticle'} '404': {$ref: '#/components/responses/ErrorMsg'} '500': {$ref: '#/components/responses/ErrorMsg'} /articles/{articleRef}/views: post: operationId: trackArticleView description: >- Records one view/click for the article. Fields absent from the body are taken from the HTTP request itself (client IP, User-Agent, Referer), which is the right default when the reader's browser calls this endpoint directly. Platforms that render articles server-side should pass the original reader's data in the body instead. parameters: - $ref: '#/components/parameters/articleRef' requestBody: {$ref: '#/components/requestBodies/TrackView'} responses: '204': {description: View recorded} '404': {$ref: '#/components/responses/ErrorMsg'} '500': {$ref: '#/components/responses/ErrorMsg'} /rss: get: operationId: getRss responses: '200': {$ref: '#/components/responses/GetRss'} '500': {$ref: '#/components/responses/ErrorMsg'} components: parameters: articleRef: name: articleRef in: path required: true description: >- Article permalink slug. Numeric ids are still accepted so links published before permalinks existed keep resolving; the response always carries the canonical slug. schema: type: string requestBodies: TrackView: required: false content: application/json: schema: {$ref: '#/components/schemas/TrackView'} responses: ErrorMsg: description: Error message content: application/json: schema: type: object properties: error: {type: string} required: [error] GetArticles: description: List of articles content: application/json: schema: type: object properties: data: {$ref: '#/components/schemas/Articles'} required: [data] GetArticle: description: Article content: application/json: schema: type: object properties: data: {$ref: '#/components/schemas/Article'} required: [data] GetRss: description: RSS feed content: application/xml: schema: {$ref: '#/components/schemas/RssFeed'} schemas: ErrorMsg: type: object properties: error: {type: string} required: [error] Article: type: object properties: id: {type: number, format: int64, x-go-type: int} slug: {type: string, description: Canonical permalink segment} title: {type: string} body: {type: string} description: {type: string} tags: {type: array, items: {type: string}} author: {type: string} viewCount: {type: number, format: int64, x-go-type: int, description: Lifetime recorded views} createdAt: {type: string, format: date-time} updatedAt: {type: string, format: date-time} required: [id, slug, title, body, tags, author, description, viewCount, createdAt, updatedAt] Articles: type: array items: {$ref: '#/components/schemas/Article'} TrackView: type: object description: >- Optional overrides for a recorded view. Use them when the tracking request is made server-to-server on behalf of a reader; otherwise omit the body and the values are read from the HTTP request. properties: clientIp: {type: string, description: The reader's IP address} userAgent: {type: string, description: The reader's User-Agent} referrer: {type: string, description: The page that linked to the article} country: {type: string, description: "ISO 3166-1 alpha-2 country code, if the platform resolved it"} city: {type: string, description: "City name, if the platform resolved it"} RssFeed: type: object x-go-type: feeds.Feed x-go-package: github.com/gorilla/feeds securitySchemes: {} security: []