-
Notifications
You must be signed in to change notification settings - Fork 0
OCR Address Extractor API Reference
The Address Extractor API is used to submit the document for address extraction.
The API is built using RESTful endpoints and standard HTTP verbs.
Response codes are used to indicate the status of the message and any error codes.
JSON is returned on all our API responses, including errors, with a consistent structure for all messages.
All API requests must be made over HTTPS. Calls made over plain HTTP will fail.
The UploadFile method accepts Multi-Part HTTP POST
POST https://addressextractorapi.net/api/AddressExtractor/UploadFile
Content-Type: multipart/form-data;
The API processes the document and return the Address formatted using the Royal Mail Address Database.
An example response is showed below:
{
"RawTextExtracted": "\r\nMax Smith\r\nFlat 11 Block\r\nRed Estate\r\nLillie Road\r\nLondon\r\nSW6 1XP",
"FormattedAddress": [
{
"postcode": "SW6 2LT",
"postcode_inward": "2LT",
"postcode_outward": "SW6",
"post_town": "LONDON",
"dependant_locality": "",
"double_dependant_locality": "",
"thoroughfare": "Oxford Road",
"dependant_thoroughfare": "Estate",
"building_number": "",
"building_name": "A Block",
"sub_building_name": "Flat 101",
"po_box": "",
"department_name": "",
"organisation_name": "",
"udprn": 23838575,
"umprn": "",
"postcode_type": "S",
"su_organisation_indicator": "",
"delivery_point_suffix": "2U",
"line_1": "Flat 10",
"line_2": "A Block",
"line_3": "Estate, Oxford Road",
"premise": "Flat 101, A Block",
"longitude": -0.20110598106607,
"latitude": 51.485678908626,
"eastings": 525001,
"northings": 177837,
"country": "England",
"traditional_county": "Greater London",
"administrative_county": "",
"postal_county": "London",
"county": "London",
"district": "Hammersmith and Fulham",
"ward": "Fulham Broadway"
}
]
The API accepts an extra form parameter ocr-only to disable the Address Validation / Formatting features (default=false) . If ocr-only=True the API will return just the Text as it appears on the document (OCR only)
Sample responde (OCR only)
{
"result": " Mark Smith Flat 1 White Road London WE1 5TL"
}
Below is a JS code snippet to pass the "ocr-only" parameter using $.ajax Form-post
// Get Form
var form = $('#post-file')[0];
// Create an FormData object
var data = new FormData(form);
// get the checkbox value (form checkbox)
var isOCROnly = $('#ocrOnly').prop('checked');
// add the ocr-only parameter to the form data
data.append("ocr-only", isOCROnly );
$.ajax({
type: "POST",
enctype: 'multipart/form-data',
url: "/api/AddressExtractor/UploadFile",
data: data,
.................
});