{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# FilingSift public evidence demo\n",
        "\n",
        "This dependency-free notebook fetches the current public AAPL record and prints the provenance needed to review each event. Current coverage is limited and `machine_checked` does not mean human-verified. No API key is required for this public example."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "import json\n",
        "from urllib.request import Request, urlopen\n",
        "\n",
        "BASE_URL = 'https://api.filingsift.com/api/v1'\n",
        "request = Request(f'{BASE_URL}/companies/AAPL', headers={'Accept': 'application/json'})\n",
        "with urlopen(request, timeout=15) as response:\n",
        "    body = json.load(response)\n",
        "\n",
        "company = body['data']\n",
        "print(company['ticker'], company['filingCount'], company['latestFiling']['accession'])"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "for event in company['events']:\n",
        "    comparison = event.get('comparison') or {}\n",
        "    previous_source = event.get('previousSource') or {}\n",
        "    current_source = event.get('currentSource') or {}\n",
        "    print(json.dumps({\n",
        "        'headline': event['headline'],\n",
        "        'before': event['before'],\n",
        "        'after': event['after'],\n",
        "        'verification': comparison.get('verification'),\n",
        "        'previousSource': {key: previous_source.get(key) for key in ('accession', 'evidence', 'evidenceSha256', 'url')},\n",
        "        'currentSource': {key: current_source.get(key) for key in ('accession', 'evidence', 'evidenceSha256', 'url')},\n",
        "    }, indent=2))"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Review questions\n",
        "\n",
        "1. Can you reproduce the value from the exact cited evidence?\n",
        "2. Are the periods and concepts comparable?\n",
        "3. Is the verification state sufficient for your workflow?\n",
        "4. What should the system do when any of those checks fail?\n",
        "\n",
        "Never convert missing or refused values to zero."
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "name": "python",
      "version": "3"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 5
}
