For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Legacy DocsSign in
DocumentationChangelog
DocumentationChangelog
  • Get Started
    • Introduction
    • Get your API keys
    • Support
    • Privacy policy
    • Status
  • Transaction Enrichment
    • Overview
    • Entities Identification
    • Categorization
    • Recurrence
  • Bank Statements
    • Overview
    • Fast verification
  • Core resources
    • Batches
    • Entities
    • Account Holders
    • Webhooks
    • Personalization
    • Reporting wrong results
  • API Reference
    • Authentication
    • Errors
    • Request IDs
    • Pagination
    • Rate limits
LogoLogo
Legacy DocsSign in
On this page
  • Submitting a batch
  • Viewing the progress of a batch
  • Retrieving the results of a batch
  • Error handling
Core resources

Batches

Was this page helpful?
Previous

Entities

Next
Built with

The Batches API allows you to submit multiple requests in a single one. It allows you to maximize throughput while remaining under rate limits. For production environments, we strongly recommend integrating this API alongside Webhooks. This setup minimizes resource usage as no polling as to be done.

Submitting a batch

A batch is an API abstraction that accepts a set of items data and an operation that corresponds to an HTTP method and a url. Processing a batch is analogous to making a request per item to operation using item as the body of the request.

To submit a batch of transactions, you have to set the operation to the appropriate endpoint operation and set each item as you would for that request:

POST
/v3/batches
1curl -X POST https://api.ntropy.com/v3/batches \
2 -H "X-Api-Key: <apiKey>" \
3 -H "Content-Type: application/json" \
4 -d '{
5 "body": {
6 "operation": "POST /v3/transactions",
7 "data": [
8 {
9 "id": "txn_9f8b7c6d5e4a3b2c",
10 "description": "Amazon Marketplace Purchase",
11 "date": "2024-04-10",
12 "amount": 59.99,
13 "entry_type": "outgoing",
14 "currency": "USD"
15 }
16 ]
17 }
18}'
Try it

When you submit a batch, since it’s an asynchronous operation, you get an id and some metadata:

Response
1{
2 "id": "a1b2c3d4-e5f6-7890-abcd-1234567890ef",
3 "operation": "POST /v3/transactions",
4 "status": "processing",
5 "created_at": "2024-04-11T08:15:00Z",
6 "updated_at": "2024-04-11T08:15:30Z",
7 "progress": 1,
8 "total": 1
9}

Viewing the progress of a batch

As said in the previous section, for production systems we recommend webhooks to receive notifications on batch progress and status changes. However, you’re always free to poll for the batch status by querying the batch API directly supplying its id.

GET
/v3/batches/:id
1curl -X "GET" \
2 "https://api.ntropy.com/v3/batches/203613d2-83c8-4130-8809-d14206eeec20" \
3 -H "Accept: application/json" \
4 -H "X-API-KEY: cd1H...Wmhl"
Try it

Retrieving the results of a batch

When the batch has finished processing its results are ready to be retrieved:

GET
/v3/batches/:id/results
1curl https://api.ntropy.com/v3/batches/id/results \
2 -H "X-Api-Key: <apiKey>" \
3 -H "Content-Type: application/json"
Try it
See the full raw output
Response
1{
2 "id": "203613d2-83c8-4130-8809-d14206eeec20",
3 "total": 1,
4 "status": "completed",
5 "results": [
6 {
7 "created_at": "2024-01-15T09:30:00Z",
8 "id": "xbx8YP14g565Xk",
9 "entities": {
10 "counterparty": {
11 "type": "organization",
12 "id": "d4bc3c80-ec1a-3da2-836e-2a4ca4758be5",
13 "name": "Starbucks",
14 "website": "starbucks.com",
15 "phone_number": "+1 4153753176",
16 "tax_number": "80-0429876",
17 "naics2017": "541519",
18 "logo": "https://logos.ntropy.com/starbucks.com",
19 "mccs": [
20 5814
21 ]
22 },
23 "intermediaries": [
24 {
25 "id": "916bc837-55ef-3106-88f6-5a8269ca9f2a",
26 "name": "Square, Inc.",
27 "website": "squareup.com",
28 "phone_number": "+1 8557006000",
29 "tax_number": "12-3456789",
30 "naics2017": "522320",
31 "logo": "https://logos.ntropy.com/squareup.com",
32 "mccs": [
33 6012
34 ],
35 "parent": {
36 "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
37 "name": "Block, Inc.",
38 "website": "block.xyz",
39 "phone_number": "+1 8885551234",
40 "tax_number": "98-7654321",
41 "naics2017": "521110"
42 }
43 }
44 ]
45 },
46 "categories": {
47 "general": "coffee shop"
48 },
49 "location": {
50 "raw_address": "10 Union Square E, New York, New York 10003, United States",
51 "structured": {
52 "street": "Union Square East",
53 "city": "New York",
54 "state": "New York",
55 "postcode": "10003",
56 "country_code": "US",
57 "country": "United States",
58 "house_number": "10",
59 "latitude": 40.734834,
60 "longitude": -73.989782,
61 "google_maps_url": "https://www.google.com/maps/search/?api=1&query=40.734834,-73.989782",
62 "apple_maps_url": "https://maps.apple.com/?q=40.734834,-73.989782"
63 }
64 },
65 "error": {
66 "code": "account_holder_not_found",
67 "message": "The account holder associated with this transaction could not be found."
68 }
69 }
70 ]
71}

Error handling

A batch is a collection of requests. This way, even if there are some requests that result in an error, these will remain local to the resource that they pertain to and not influence the global status of the batch:

1from ntropy_sdk import SDK
2
3sdk = SDK("cd1H...Wmhl" )
4batch = sdk.batches.get("f203613d2-83c8-4130-8809-d14206eeec20")
5if batch.is_completed():
6 batch_result = sdk.batches.results(batch.id)
7 not_ok = [tx for tx in batch_result.results if tx.error is not None]
8 # Handle specific transactions
9 ...
10elif batch.is_error():
11 # Handle batch error
12 ...

When the batch has an error status it means that there was an unexpected error in the processing. These are rare and can often be solved by retrying the batch. Results are not available in these cases.