This is a simple API Wrapper for Optical Character Recognition (OCR) using Microsoft’s Azure Optical Character Recognition service. It allows the user to input an image and it returns the extracted text.
- Base URL:
http://147.182.167.158:3000/api/ocr - Swagger UI: http://147.182.167.158:3000/docs/
- User Guide: user_guide.md
- Extracts text from an image using Azure OCR service
- Supports both image URLs and image uploads with
POST /urlandPOST /uploadendpoints - Validates file format and size before processing
- Returns clean and readable JSON responses with status codes
- Swagger UI available for request/response formats and live testing
- Deployed to a DigitalOcean droplet with PM2 server
- Supported formats: All image formats, including JPG, PNG, BMP, TIFF, WEBP, AVIF, and even GIF
- Max file size: 4 MB
- Dimensions: Images must be between 50 and 4,200 pixels in both width and height
- Node.js + Express – Backend server framework for handling API endpoints
- Axios – Sends HTTP requests to Azure OCR's REST API with proper headers and body
- CORS – Enables cross-origin access for API testing
- Multer – Handles file uploads with
multipart/form-dataand enforces the 4MB size limit - Sharp – Converts unsupported image formats (like WebP or AVIF) to PNG to ensure compatibility with Azure OCR
- Swagger (swagger-jsdoc + swagger-ui-express) – Automatic generator for interactive API documentation
- DigitalOcean Droplet – Continuously hosts the Express server with PM2
You can find these images in the test_data folder of this repository, which were obtained from:
- MSRA-TD500 Text Detection Dataset
- Other custom image searches and manually created examples
-
Clone the repository:
git clone https://github.com/andlamb2002/ITIS-6177-API-Wrapper.git -
Install dependencies:
npm install -
Create an Azure Computer Vision resource through the Azure Portal. Then, add a
.envfile in the root directory with your Azure credentials:AZURE_API_KEY=your_api_key AZURE_ENDPOINT=https://your-azure-endpoint/
-
Start the server:
node server.js
-
Test the API endpoints:
POST http://localhost:3000/api/ocr/url– Submit an image URL in a JSON body using theimageUrlfieldPOST http://localhost:3000/api/ocr/upload– Upload an image file usingmultipart/form-datawith the field namefile
Or access the Swagger UI at: http://localhost:3000/docs
This project was created as part of the ITIS-6177 System Integration course at UNC Charlotte. It is intended for educational and demonstration purposes only.