You can now group multiple DayPI requests into one request using the Batch API. Batch APIs help improve the performance of your application as your application makes only HTTP request to the DayPIs.
You can also download a PHP script to call the Batch API.
Read more about how to call the Batch API using PHP.
The Batch API accepts multiple DayPI requests, executes each of them in parallel and returns a combined response for all DayPI requests. You can make upto 20 individual DayPI requests in one batch request.
http: //freeapi.daylife.com/xmlrest/publicapi/4.2/search_getRelatedArticles? query=george%20bush&accesskey=youraccesskey&signature=thesignature
/publicapi/4.2/search_getRelatedArticles? query=george%20bush&accesskey=youraccesskey&signature=thesignature
http: //freeapi.daylife.com/xmlrest/batch/1.0/parallel?accesskey=youraccesskey& request=urlencode(/publicapi/4.2/search_getRelatedArticles?query=george%20bush& accesskey=youraccesskey&signature=thesignature&request_id=1001) &request=urlencode(/publicapi/4.2/search_getRelatedTopics?query=george%20bush& accesskey=youraccesskey&signature=thesignature&request_id=1002)
Notice the request_id param in the values of the request parameter above. Every single DayPI request provided as input to the batch.parallel method needs to have a unique alphanumeric request_id. When the batch API combines the response of each individual DayPI request, it adds the request_id from the indvidual request to its corresponding response. Your Batch API client can then match up every single request sent to batch.parallel to the individual responses in the combined response using the request_id.
Download Sample Batch Response Here.
Yes, any parameter to the batch.parallel API call that starts with "batch_" is appended to each individual request without the prefix "batch_". For e.,g,, your provide batch_accesskey=XYZ as an input to the batch.parallel call, then accesskey=XYZ gets added as a parameter to each individual request.
Yes. The Batch API attempts to make individual requests in parallel, waits a maximum upto 25 seconds for each request to come back and then returns the combined responses of the requests that got completed.
No. The Batch API has no authentication of its own. Each individual DayPI request provided as an input must contain a valid accesskey and signature. However, you can use the feature mentioned in topic 6 above to provide batch_accesskey and batch_signature as an input to the batch.parallel call rather than providing accesskey and signature in each individual request.
3001: Succes. All individual requests were completed without a timeout. However, this does not guarantee that each individual request was successful.
-3001: One or more individual requests did not complete within the 25 second timeframe.
-3002: Duplicate request_ids provided in the individual requests
-3003: One or more of the individual DayPI request were not formatted properly. See above how to make a valid request for the Batch API.
-3004: More than 20 requests provided as input to the batch API.
| Attachment | Size |
|---|---|
| response-parallel.zip | 8.65 KB |