Synchronous vs. Asynchronous Calls

Introduction

Anduin's public API includes both synchronous and asynchronous call types. Customers have the flexibility to choose the type that best suits their specific requirements.

Synchronous API calls are blocking, waiting until the operation is completed or an error occurs.

Asynchronous APIs offer an immediate response, confirming that the server has acknowledged the request for processing. The real-time processing status can be queried through a dedicated synchronous API.

Please note: At present, we provide only a single asynchronous API specifically designed for bulk inviting investors. This API streamlines the process of inviting multiple investors to a fund simultaneously. If you are not currently using this API, you can skip this section for the time being.

Handling Asynchronous APIs

Asynchronous APIs are identified by the /async part in the endpoint route, such as /api/v1/fundsub/async/bulk/orders.

Asynchronous API Calls

  • If valid, an async API call is accepted, and the response HTTP code is 202, indicating the request has been accepted for processing.
  • The response body contains a requestId that can be used for periodic polling to get updated information on the call's progress.

Example of a successful asynchronous response:

{
	"requestId": "req1nsf6k39j43kgkehhfj"
	"requestStatus": "PENDING"
}

Polling the Asynchronous Call Status

To track the progress of the query, the client can periodically retrieve the request status through the request status API. There are four statuses:

0 - PENDING: The request is still in progress.

1 - COMPLETED: The request has been successfully processed.

  • The response code is HTTP 200.
  • The response provides detailed results, including the request type and a report (e.g., a list of created orders).

Example of a complete response:

{
	"requestType": "fundsub.orders.createMultipleAsync",
  "status": 2
	"response": {
		"orders": ["lpp39dkwre", "lpponr23ja"]
	}
}

3 - FAILED

  • The request has encountered a failure during processing.
  • The response provides detailed information about the encountered failure.

Example of a failed response:

{
	"requestType": "fundsub.orders.createMultipleAsync",
	"status": 3
	"error": "Unauthorized request"
}
  • There are some common reasons for a failed request:
    • Request timeout
    • Invalid input parameter
    • Unauthorized request

4 - IN-PROGRESS

  • The request is currently in processing, and partial results are accessible. This status is relevant for bulk requests, where multiple sub-requests are included in the same asynchronous call. An instance of this is the bulk order creation request, allowing the creation of multiple orders for a fund.
  • The response provides information about the status of each sub-request. The sub-request status is also one of the fourth statuses: PENDING, COMPLETE, FAILED, and IN-PROGRESS.

Example of an IN-PROGRESS response:

{
	"requestType": "fundsub.orders.createMultipleAsync",
  "status": 4
	"response": {
		"orders": [
			{
				"lpp39dkwre",
				"status": 1
			},
			{
				"status": 4
			+
		]
	}
}
  • The order of sub-request statuses in a response follows the order of sub-requests in input parameters. In the example above, the overall request status is 4 - IN-PROGRESS, the status of each order is in each element of the orders array with their statuses.