The HTTP client is a basic client which makes it easy to process a document and handles all HTTP requests and responses for you, in a reliable way. This client is best for simple single-document scenarios such as scanning or simple interactive applications.
You can find samples demonstrating use of this client in the .NET client libraries repository (see Overview).
The HTTP client is available as a NuGet package and can be installed from their using one of these methods:
dotnet add package Aluma.Http
To instantiate a client, we'll need an API client ID and secret. You can create a new API client in the Aluma dashboard if you don't already have one.
var client = AlumaClient.Create("<your-API-client-id>", "<your-API-client-secret>");
Fist we'll need to create a new Aluma document from your file on disk. There are overloads if you want to pass it a stream, instead, or even a URI if your document is downloadable and accessible to the Aluma service.
var document = await client.CreateDocumentAsync(documentFilePath);
Now we can process the document. Here we're doing some data extraction, but there are also methods for classifying a document, reading a document and returning its text, creating a searchable PDF, creating a highlighted PDF and creating a redacted PDF.
Each method returns either data in a structured object or a stream that you can read and write results to disk or another location.
var results = await document.ExtractAsync(extractorName);
foreach (var fieldResult in results.FieldResults)
Finally we delete the document from the Aluma service. If we don't do this then the document will be automatically deleted 10 minutes after it is last used, but it is important to delete them explicitly so you free up a slot in your API client's document quota (30 documents by default).
In fact, to ensure that your documents are always deleted you should put all your processing in a try block, catch exceptions and delete your document in a finally block, like this:
// Create document
// Process the document
catch (Exception ex)
// Handle exceptions
// Delete document
The client automatically retries requests to the Aluma service that fail due to any transient network errors between your server and the Aluma service, so you do not need to implement this behaviour.
Updated over 2 years ago