{"id":51126549,"url":"https://github.com/apiverve/ocr-scanner-python-tutorial","last_synced_at":"2026-06-25T08:01:59.274Z","repository":{"id":338744222,"uuid":"1158967702","full_name":"apiverve/ocr-scanner-python-tutorial","owner":"apiverve","description":"OCR scanner that extracts text from images using Python","archived":false,"fork":false,"pushed_at":"2026-02-16T07:40:58.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-16T14:18:11.448Z","etag":null,"topics":["apiverve","cli","document-scanner","image-to-text","ocr","python","text-extraction","tutorial"],"latest_commit_sha":null,"homepage":"https://apiverve.com/marketplace/imagetotext","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/apiverve.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-16T06:24:44.000Z","updated_at":"2026-02-16T07:41:01.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/apiverve/ocr-scanner-python-tutorial","commit_stats":null,"previous_names":["apiverve/ocr-scanner-python-tutorial"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/apiverve/ocr-scanner-python-tutorial","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apiverve%2Focr-scanner-python-tutorial","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apiverve%2Focr-scanner-python-tutorial/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apiverve%2Focr-scanner-python-tutorial/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apiverve%2Focr-scanner-python-tutorial/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apiverve","download_url":"https://codeload.github.com/apiverve/ocr-scanner-python-tutorial/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apiverve%2Focr-scanner-python-tutorial/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34765322,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-25T02:00:05.521Z","response_time":101,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apiverve","cli","document-scanner","image-to-text","ocr","python","text-extraction","tutorial"],"created_at":"2026-06-25T08:01:59.175Z","updated_at":"2026-06-25T08:01:59.258Z","avatar_url":"https://github.com/apiverve.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OCR Scanner | APIVerve API Tutorial\r\n\r\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)\r\n[![Build](https://img.shields.io/badge/Build-Passing-brightgreen.svg)]()\r\n[![Python](https://img.shields.io/badge/Python-3.7+-3776ab)](https://python.org)\r\n[![APIVerve | Image to Text](https://img.shields.io/badge/APIVerve-Image_to_Text-purple)](https://apiverve.com/marketplace/imagetotext?utm_source=github\u0026utm_medium=tutorial\u0026utm_campaign=ocr-scanner-python-tutorial)\r\n\r\nA Python CLI tool that extracts text from images using OCR (Optical Character Recognition). Works with local files and URLs.\r\n\r\n![Screenshot](https://raw.githubusercontent.com/apiverve/ocr-scanner-python-tutorial/main/screenshot.jpg)\r\n\r\n---\r\n\r\n### Get Your Free API Key\r\n\r\nThis tutorial requires an APIVerve API key. **[Sign up free](https://dashboard.apiverve.com?utm_source=github\u0026utm_medium=tutorial\u0026utm_campaign=ocr-scanner-python-tutorial)** - no credit card required.\r\n\r\n---\r\n\r\n## Features\r\n\r\n- Extract text from local image files\r\n- Extract text from image URLs\r\n- Support for JPG, PNG, and GIF formats\r\n- Interactive mode or command-line arguments\r\n- Clean, formatted output with character count\r\n- Handles errors gracefully\r\n\r\n## Quick Start\r\n\r\n1. **Clone this repository**\r\n   ```bash\r\n   git clone https://github.com/apiverve/ocr-scanner-python-tutorial.git\r\n   cd ocr-scanner-python-tutorial\r\n   ```\r\n\r\n2. **Install dependencies**\r\n   ```bash\r\n   pip install -r requirements.txt\r\n   ```\r\n\r\n3. **Add your API key**\r\n\r\n   Open `scanner.py` and replace the API key:\r\n   ```python\r\n   API_KEY = 'your-api-key-here'\r\n   ```\r\n\r\n4. **Run the scanner**\r\n\r\n   Interactive mode:\r\n   ```bash\r\n   python scanner.py\r\n   ```\r\n\r\n   Command line mode:\r\n   ```bash\r\n   python scanner.py /path/to/image.jpg\r\n   python scanner.py https://example.com/image.png\r\n   ```\r\n\r\n## Usage Examples\r\n\r\n### Scan a local file\r\n```bash\r\n$ python scanner.py receipt.jpg\r\n\r\n==================================================\r\n  OCR Scanner - Extracted Text\r\n==================================================\r\n\r\n  Source: receipt.jpg\r\n\r\n--------------------------------------------------\r\n  GROCERY STORE\r\n  123 Main Street\r\n\r\n  Milk         $3.99\r\n  Bread        $2.49\r\n  Eggs         $4.99\r\n\r\n  Total:      $11.47\r\n--------------------------------------------------\r\n\r\n  Characters extracted: 89\r\n==================================================\r\n```\r\n\r\n### Scan from URL\r\n```bash\r\n$ python scanner.py https://example.com/document.png\r\n```\r\n\r\n### Interactive mode\r\n```bash\r\n$ python scanner.py\r\n\r\n==================================================\r\n  OCR Scanner\r\n  Powered by APIVerve\r\n==================================================\r\n\r\nExtract text from images (files or URLs)\r\nType 'quit' to exit\r\n\r\nEnter image path or URL: screenshot.png\r\n```\r\n\r\n## Project Structure\r\n\r\n```\r\nocr-scanner-python-tutorial/\r\n├── scanner.py          # Main Python script\r\n├── requirements.txt    # Dependencies (requests)\r\n├── screenshot.jpg      # Preview image\r\n├── LICENSE             # MIT license\r\n├── .gitignore          # Git ignore rules\r\n└── README.md           # This file\r\n```\r\n\r\n## How It Works\r\n\r\n1. User provides an image (file path or URL)\r\n2. Script detects input type and validates format\r\n3. For files: uploads image to API via multipart form\r\n4. For URLs: sends URL in JSON body\r\n5. API processes image with OCR\r\n6. Script displays extracted text\r\n\r\n### The API Call (File Upload)\r\n\r\n```python\r\nwith open(file_path, 'rb') as f:\r\n    files = {'image': (filename, f, 'image/jpeg')}\r\n    response = requests.post(\r\n        'https://api.apiverve.com/v1/imagetotext',\r\n        files=files,\r\n        headers={'x-api-key': API_KEY}\r\n    )\r\n```\r\n\r\n### The API Call (URL)\r\n\r\n```python\r\nresponse = requests.post(\r\n    'https://api.apiverve.com/v1/imagetotext',\r\n    json={'url': image_url},\r\n    headers={\r\n        'Content-Type': 'application/json',\r\n        'x-api-key': API_KEY\r\n    }\r\n)\r\n```\r\n\r\n## API Reference\r\n\r\n**Endpoint:** `POST https://api.apiverve.com/v1/imagetotext`\r\n\r\n**Option 1: File Upload**\r\n\r\n| Parameter | Type | Required | Description |\r\n|-----------|------|----------|-------------|\r\n| `image` | file | Yes | Image file (JPG, PNG, GIF, max 5MB) |\r\n\r\n**Option 2: URL**\r\n\r\n| Parameter | Type | Required | Description |\r\n|-----------|------|----------|-------------|\r\n| `url` | string | Yes | URL of the image |\r\n\r\n**Example Response:**\r\n\r\n```json\r\n{\r\n  \"status\": \"ok\",\r\n  \"error\": null,\r\n  \"data\": {\r\n    \"text\": \"Extracted text from the image appears here...\",\r\n    \"confidence\": 88,\r\n    \"words\": 28,\r\n    \"characters\": 170,\r\n    \"lines\": 5\r\n  }\r\n}\r\n```\r\n\r\n## Use Cases\r\n\r\n- **Receipt scanning** - Extract totals and items from receipts\r\n- **Document digitization** - Convert scanned documents to text\r\n- **Screenshot text extraction** - Pull text from screenshots\r\n- **Business card scanning** - Extract contact information\r\n- **Sign/label reading** - Read text from photos of signs\r\n- **Handwritten notes** - Digitize handwritten content\r\n\r\n## Customization Ideas\r\n\r\n- Add output to file option (`--output results.txt`)\r\n- Add batch processing for multiple images\r\n- Add JSON output format\r\n- Build a web interface with Flask\r\n- Add clipboard support (paste image)\r\n- Integrate with cloud storage (S3, Google Drive)\r\n\r\n## Related APIs\r\n\r\nExplore more APIs at [APIVerve](https://apiverve.com/marketplace?utm_source=github\u0026utm_medium=tutorial\u0026utm_campaign=ocr-scanner-python-tutorial):\r\n\r\n- [Image Caption](https://apiverve.com/marketplace/imagecaption?utm_source=github\u0026utm_medium=tutorial\u0026utm_campaign=ocr-scanner-python-tutorial) - Generate captions for images\r\n- [QR Code Reader](https://apiverve.com/marketplace/qrcodereader?utm_source=github\u0026utm_medium=tutorial\u0026utm_campaign=ocr-scanner-python-tutorial) - Read QR codes from images\r\n- [Face Detector](https://apiverve.com/marketplace/facedetect?utm_source=github\u0026utm_medium=tutorial\u0026utm_campaign=ocr-scanner-python-tutorial) - Detect faces in images\r\n\r\n## Free Plan Note\r\n\r\nThis tutorial works with the free APIVerve plan. Some APIs may have:\r\n- **Locked fields**: Premium response fields return `null` on free plans\r\n- **Ignored parameters**: Some optional parameters require a paid plan\r\n\r\nThe API response includes a `premium` object when limitations apply. [Upgrade anytime](https://dashboard.apiverve.com/plans) to unlock all features.\r\n\r\n## License\r\n\r\nMIT - see [LICENSE](LICENSE)\r\n\r\n## Links\r\n\r\n- [Get API Key](https://dashboard.apiverve.com?utm_source=github\u0026utm_medium=tutorial\u0026utm_campaign=ocr-scanner-python-tutorial) - Sign up free\r\n- [APIVerve Marketplace](https://apiverve.com/marketplace?utm_source=github\u0026utm_medium=tutorial\u0026utm_campaign=ocr-scanner-python-tutorial) - Browse 300+ APIs\r\n- [Image to Text API](https://apiverve.com/marketplace/imagetotext?utm_source=github\u0026utm_medium=tutorial\u0026utm_campaign=ocr-scanner-python-tutorial) - API details\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapiverve%2Focr-scanner-python-tutorial","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapiverve%2Focr-scanner-python-tutorial","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapiverve%2Focr-scanner-python-tutorial/lists"}