Difference between revisions of "Example Clients"

From Textserver wiki
Jump to: navigation, search
(Example Clients for Retrieving Results of Batch Requests)
 
(8 intermediate revisions by the same user not shown)
Line 19: Line 19:
 
You'll need to replace <tt>SERVICENAME</tt> with the actual name of the desired service, and adapt the list of parameters in the request to those expected by the service.
 
You'll need to replace <tt>SERVICENAME</tt> with the actual name of the desired service, and adapt the list of parameters in the request to those expected by the service.
  
* '''[[Python Interactive Client|Python]]'''
+
* '''[[Python2 Interactive Client|Python2]]'''
 +
* '''[[Python3 Interactive Client|Python3]]'''
 
* '''[[Java Interactive Client|Java]]'''
 
* '''[[Java Interactive Client|Java]]'''
 
* '''[[Perl Interactive Client|Perl]]'''
 
* '''[[Perl Interactive Client|Perl]]'''
Line 30: Line 31:
 
You'll need to replace <tt>SERVICENAME</tt> with the actual name of the desired service, and adapt the list of parameters in the multipart form to those expected by the service.
 
You'll need to replace <tt>SERVICENAME</tt> with the actual name of the desired service, and adapt the list of parameters in the multipart form to those expected by the service.
  
These clients send the request, then poll the server until the job is finished, and then they retrieve the results.
+
These clients send the request and obtain the job Token ID from TextServer. This Token ID can be used later to retrieve the results of the job
  
However, this doesn't have to be like this, and can be done to your convenience (e.g. have an independent cron job that polls for all sent requests once every hour, add a trigger in your mail that will launch the retrieval when the "job completed" mail is received, etc.)
+
* '''[[Python2 Batch Client|Python2]]'''
 
+
* '''[[Python3 Batch Client|Python3]]'''
* '''[[Python Batch Client|Python]]'''
+
 
* '''[[Java Batch Client|Java]]'''
 
* '''[[Java Batch Client|Java]]'''
 
* '''[[Perl Batch Client|Perl]]'''
 
* '''[[Perl Batch Client|Perl]]'''
Line 40: Line 40:
 
* '''[[curl Batch Client|bash (using curl)]]'''
 
* '''[[curl Batch Client|bash (using curl)]]'''
  
== Retrieving Results of Batch Requests ==
+
== Example Clients for Retrieving Results of Batch Requests ==
 
+
When the user submits a batch request, TextServer responds with a Token ID that will identify the job and allow retrieval of the results when it is done.
+
 
+
The user can retrieve the results manually in the web page, or programmatically from a remote client. Example remote clients to retrieve batch requests results are provided below.
+
 
+
TextServer will notify the user via email when the job is finished. Alteratively, the user can poll TextServer periodically to find out whether job results are ready.
+
 
+
When the user attempts to retrieve the results of an unfinished job, TextServer will respond with a HTTP 503 error message (Service Unavailable) containing the TextServer error code TS-125 (job not finished) in the message body.
+
  
 +
Below there is a list of examples of how to retrieve the result of a batch job from a remote client.
 +
The client just needs the username and the job Token ID to get the results.
  
* '''[[Batch Results Retrieval in Python|Python]]'''
+
* '''[[Batch Results Retrieval in Python2|Python2]]'''
 +
* '''[[Batch Results Retrieval in Python3|Python3]]'''
 
* '''[[Batch Results Retrieval in Java|Java]]'''
 
* '''[[Batch Results Retrieval in Java|Java]]'''
 
* '''[[Batch Results Retrieval in Perl|Perl]]'''
 
* '''[[Batch Results Retrieval in Perl|Perl]]'''
 
* '''[[Batch Results Retrieval in PHP|PHP]]'''
 
* '''[[Batch Results Retrieval in PHP|PHP]]'''
 
* '''[[Batch Results Retrieval in curl|bash (using curl)]]'''
 
* '''[[Batch Results Retrieval in curl|bash (using curl)]]'''

Latest revision as of 10:29, 24 August 2018

To call a TextServer service from a client program running on your side, this client needs to send the appropriate request in the right format.

The request is a standard HTTP POST request with a multiform part containing the same information you would submit via the web interface.

Below you'll find a list of example client programs in different programming languages.

The same code can be used to access any TextServer service with small variations:

  • Simply change the service name in the URL to access a different service. You can find out the service name at the top of the "Execute" form of your subscribed services.
  • Replace the parameters in the example client with the parametes that the called service requires. Rules are simple:
    • Language identification service does not require a "language" parameter, but the other services do.
    • All services require a "interactive" parameter stating whether the job is interactive or batch.
    • All services require either a "text_input" parameter (for interactive jobs) or a "input_file" parameter (for batch jobs).
    • You can find out the name of any other specific parameters for a service in the "Execute" form of your subscribed services.

Example Clients for Interactive Jobs

Below there is a list of example of how to send an interactive request to a service named SERVICENAME using different programming languages. You'll need to replace SERVICENAME with the actual name of the desired service, and adapt the list of parameters in the request to those expected by the service.

Example Clients for Batch Jobs

Below there is a list of example of how to send a batch request to a service named SERVICENAME using different programming languages. You'll need to replace SERVICENAME with the actual name of the desired service, and adapt the list of parameters in the multipart form to those expected by the service.

These clients send the request and obtain the job Token ID from TextServer. This Token ID can be used later to retrieve the results of the job

Example Clients for Retrieving Results of Batch Requests

Below there is a list of examples of how to retrieve the result of a batch job from a remote client. The client just needs the username and the job Token ID to get the results.