{
    "openapi": "3.0.3",
    "info": {
        "title": "Infojara Tips API",
        "version": "1.0.0",
        "description": "Read the daily tips published on Infojara. Authenticate with an API key. Add ?pretty=1 for readable JSON."
    },
    "servers": [
        {
            "url": "https://www.dev.infojara.com.ng/api/v1"
        }
    ],
    "security": [
        {
            "bearerAuth": []
        },
        {
            "apiKeyHeader": []
        }
    ],
    "paths": {
        "/tips/today": {
            "get": {
                "summary": "Today's tips",
                "parameters": [
                    {
                        "name": "access",
                        "in": "query",
                        "description": "free, vip or all (VIP needs a key with VIP access)",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "free",
                                "vip",
                                "all"
                            ]
                        }
                    },
                    {
                        "name": "category",
                        "in": "query",
                        "description": "Category slug",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "description": "Max results (1-100)",
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Tips published today",
                        "headers": {
                            "X-RateLimit-Limit": {
                                "schema": {
                                    "type": "integer"
                                },
                                "description": "Requests allowed per hour"
                            },
                            "X-RateLimit-Remaining": {
                                "schema": {
                                    "type": "integer"
                                }
                            },
                            "X-RateLimit-Reset": {
                                "schema": {
                                    "type": "integer"
                                },
                                "description": "Unix time when the hourly window resets"
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/Tip"
                                            }
                                        },
                                        "meta": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Error"
                    },
                    "403": {
                        "$ref": "#/components/responses/Error"
                    },
                    "429": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/tips": {
            "get": {
                "summary": "List published tips",
                "parameters": [
                    {
                        "name": "access",
                        "in": "query",
                        "description": "free, vip or all (VIP needs a key with VIP access)",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "free",
                                "vip",
                                "all"
                            ]
                        }
                    },
                    {
                        "name": "category",
                        "in": "query",
                        "description": "Category slug",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "date",
                        "in": "query",
                        "description": "Exact date, YYYY-MM-DD",
                        "schema": {
                            "type": "string",
                            "format": "date"
                        }
                    },
                    {
                        "name": "from",
                        "in": "query",
                        "description": "From date",
                        "schema": {
                            "type": "string",
                            "format": "date"
                        }
                    },
                    {
                        "name": "to",
                        "in": "query",
                        "description": "To date",
                        "schema": {
                            "type": "string",
                            "format": "date"
                        }
                    },
                    {
                        "name": "q",
                        "in": "query",
                        "description": "Search text",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "page",
                        "in": "query",
                        "description": "Page number",
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "description": "Page size (1-100)",
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "A page of tips",
                        "headers": {
                            "X-RateLimit-Limit": {
                                "schema": {
                                    "type": "integer"
                                },
                                "description": "Requests allowed per hour"
                            },
                            "X-RateLimit-Remaining": {
                                "schema": {
                                    "type": "integer"
                                }
                            },
                            "X-RateLimit-Reset": {
                                "schema": {
                                    "type": "integer"
                                },
                                "description": "Unix time when the hourly window resets"
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/Tip"
                                            }
                                        },
                                        "meta": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Error"
                    },
                    "403": {
                        "$ref": "#/components/responses/Error"
                    },
                    "429": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/tips/{id}": {
            "get": {
                "summary": "One tip",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "headers": {
                            "X-RateLimit-Limit": {
                                "schema": {
                                    "type": "integer"
                                },
                                "description": "Requests allowed per hour"
                            },
                            "X-RateLimit-Remaining": {
                                "schema": {
                                    "type": "integer"
                                }
                            },
                            "X-RateLimit-Reset": {
                                "schema": {
                                    "type": "integer"
                                },
                                "description": "Unix time when the hourly window resets"
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/Tip"
                                        },
                                        "meta": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Error"
                    },
                    "403": {
                        "$ref": "#/components/responses/Error"
                    },
                    "429": {
                        "$ref": "#/components/responses/Error"
                    },
                    "404": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/tips/{id}/image": {
            "get": {
                "summary": "The tip's picture",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Image",
                        "content": {
                            "image/png": {
                                "schema": {
                                    "type": "string",
                                    "format": "binary"
                                }
                            },
                            "image/jpeg": {
                                "schema": {
                                    "type": "string",
                                    "format": "binary"
                                }
                            }
                        }
                    },
                    "404": {
                        "$ref": "#/components/responses/Error"
                    },
                    "401": {
                        "$ref": "#/components/responses/Error"
                    },
                    "403": {
                        "$ref": "#/components/responses/Error"
                    },
                    "429": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/categories": {
            "get": {
                "summary": "Categories",
                "responses": {
                    "200": {
                        "description": "Categories with published tip counts",
                        "headers": {
                            "X-RateLimit-Limit": {
                                "schema": {
                                    "type": "integer"
                                },
                                "description": "Requests allowed per hour"
                            },
                            "X-RateLimit-Remaining": {
                                "schema": {
                                    "type": "integer"
                                }
                            },
                            "X-RateLimit-Reset": {
                                "schema": {
                                    "type": "integer"
                                },
                                "description": "Unix time when the hourly window resets"
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/Category"
                                            }
                                        },
                                        "meta": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Error"
                    },
                    "403": {
                        "$ref": "#/components/responses/Error"
                    },
                    "429": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/me": {
            "get": {
                "summary": "Your key: access, limits, usage",
                "responses": {
                    "200": {
                        "description": "OK",
                        "headers": {
                            "X-RateLimit-Limit": {
                                "schema": {
                                    "type": "integer"
                                },
                                "description": "Requests allowed per hour"
                            },
                            "X-RateLimit-Remaining": {
                                "schema": {
                                    "type": "integer"
                                }
                            },
                            "X-RateLimit-Reset": {
                                "schema": {
                                    "type": "integer"
                                },
                                "description": "Unix time when the hourly window resets"
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/Me"
                                        },
                                        "meta": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Error"
                    },
                    "403": {
                        "$ref": "#/components/responses/Error"
                    },
                    "429": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/webhooks": {
            "get": {
                "summary": "List your webhooks",
                "responses": {
                    "200": {
                        "description": "Your webhooks",
                        "headers": {
                            "X-RateLimit-Limit": {
                                "schema": {
                                    "type": "integer"
                                },
                                "description": "Requests allowed per hour"
                            },
                            "X-RateLimit-Remaining": {
                                "schema": {
                                    "type": "integer"
                                }
                            },
                            "X-RateLimit-Reset": {
                                "schema": {
                                    "type": "integer"
                                },
                                "description": "Unix time when the hourly window resets"
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/Webhook"
                                            }
                                        },
                                        "meta": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Error"
                    },
                    "403": {
                        "$ref": "#/components/responses/Error"
                    },
                    "429": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            },
            "post": {
                "summary": "Register a webhook (max 3 per key)",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "url"
                                ],
                                "properties": {
                                    "url": {
                                        "type": "string",
                                        "format": "uri",
                                        "description": "HTTPS address that will receive events"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Created. The signing secret is returned once.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/Webhook"
                                        },
                                        "meta": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "422": {
                        "$ref": "#/components/responses/Error"
                    },
                    "401": {
                        "$ref": "#/components/responses/Error"
                    },
                    "403": {
                        "$ref": "#/components/responses/Error"
                    },
                    "429": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/webhooks/{id}/delete": {
            "post": {
                "summary": "Delete one of your webhooks",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Deleted"
                    },
                    "404": {
                        "$ref": "#/components/responses/Error"
                    },
                    "401": {
                        "$ref": "#/components/responses/Error"
                    },
                    "403": {
                        "$ref": "#/components/responses/Error"
                    },
                    "429": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        }
    },
    "components": {
        "securitySchemes": {
            "bearerAuth": {
                "type": "http",
                "scheme": "bearer"
            },
            "apiKeyHeader": {
                "type": "apiKey",
                "in": "header",
                "name": "X-API-Key"
            }
        },
        "responses": {
            "Error": {
                "description": "Error",
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/Error"
                        }
                    }
                }
            }
        },
        "schemas": {
            "Error": {
                "type": "object",
                "properties": {
                    "error": {
                        "type": "object",
                        "properties": {
                            "code": {
                                "type": "string"
                            },
                            "message": {
                                "type": "string"
                            }
                        }
                    }
                }
            },
            "Step": {
                "type": "object",
                "properties": {
                    "title": {
                        "type": "string"
                    },
                    "text": {
                        "type": "string"
                    }
                }
            },
            "Tip": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "integer"
                    },
                    "title": {
                        "type": "string"
                    },
                    "summary": {
                        "type": "string"
                    },
                    "steps": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Step"
                        }
                    },
                    "benefits": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    },
                    "pro_tip": {
                        "type": "string",
                        "nullable": true
                    },
                    "category": {
                        "type": "object",
                        "nullable": true,
                        "properties": {
                            "slug": {
                                "type": "string"
                            },
                            "name": {
                                "type": "string"
                            }
                        }
                    },
                    "access": {
                        "type": "string",
                        "enum": [
                            "free",
                            "vip"
                        ]
                    },
                    "published_on": {
                        "type": "string",
                        "format": "date",
                        "nullable": true
                    },
                    "url": {
                        "type": "string",
                        "format": "uri"
                    },
                    "image_url": {
                        "type": "string",
                        "format": "uri",
                        "nullable": true
                    }
                }
            },
            "Category": {
                "type": "object",
                "properties": {
                    "slug": {
                        "type": "string"
                    },
                    "name": {
                        "type": "string"
                    },
                    "description": {
                        "type": "string"
                    },
                    "published_tips": {
                        "type": "integer"
                    }
                }
            },
            "Me": {
                "type": "object",
                "properties": {
                    "name": {
                        "type": "string"
                    },
                    "scope": {
                        "type": "string"
                    },
                    "status": {
                        "type": "string"
                    },
                    "expires_at": {
                        "type": "string",
                        "nullable": true
                    },
                    "limits": {
                        "type": "object",
                        "properties": {
                            "per_hour": {
                                "type": "integer"
                            },
                            "per_day": {
                                "type": "integer"
                            }
                        }
                    },
                    "usage": {
                        "type": "object",
                        "properties": {
                            "this_hour": {
                                "type": "integer"
                            },
                            "today": {
                                "type": "integer"
                            },
                            "total": {
                                "type": "integer"
                            }
                        }
                    }
                }
            },
            "Webhook": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "integer"
                    },
                    "url": {
                        "type": "string"
                    },
                    "events": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    },
                    "status": {
                        "type": "string"
                    },
                    "failures": {
                        "type": "integer"
                    },
                    "last_delivery_at": {
                        "type": "string",
                        "nullable": true
                    },
                    "secret": {
                        "type": "string",
                        "description": "Only in the create response"
                    }
                }
            },
            "TipsPublishedEvent": {
                "type": "object",
                "description": "Body POSTed to your webhook URL when tips are published. Verify X-Webhook-Signature = sha256 HMAC of \"<X-Webhook-Timestamp>.<raw body>\" with your secret.",
                "properties": {
                    "event": {
                        "type": "string",
                        "example": "tips.published"
                    },
                    "created_at": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "data": {
                        "type": "object",
                        "properties": {
                            "tips": {
                                "type": "array",
                                "items": {
                                    "$ref": "#/components/schemas/Tip"
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}