About
Downloads
- Cheat Sheet
- Data Management Plan Resources
- Logging Format (XSD/DTD)
- Logging Libraries
- Web Services
- XML Validator Tool
DataShopa data analysis service for the learning science community |
|||||||||
|
Downloads / Web Services
Web Services provide a way to enable your program or web site to retrieve DataShop data
and insert data back into the central repository programmatically.
Our service follows the REST guidelines,
which means that requests to web services are done over HTTP using URLs that represent resources.
Web Services API Status
As of October 2018, you can use DataShop web services to:
In addition, you can use web services for the following LearnSphere operations:
Table of Contents
Web Services XML Schema
Use this XML schema file as documentation for the format of responses from DataShop and
to validate requests you make to DataShop web services.
DataShop & LearnSphere APIs
Documentation for the application programming interface to DataShop Web Services.
Documentation for the application programming interface to LearnSphere Web Services.
Sample Java Client
We've written a small command-line application in Java that prints the results of URL
requests to the console. If you are considering writing an application in Java to interface with
DataShop, browse the source for this program, which is included in the download.
A similar application exists for use with the LearnSphere webservices. This download includes
those necessary libraries as well as an example Java client.
Download the LearnSphere Java client and libraries
LearnSphere_webservices_java1.6.zip (91 MB) java 1.6
Sample Java Client Documentation
1. Introduction
DataShop Web Services let you access DataShop data programmatically. By sending a HTTP GET request to a URL, you can get information about datasets and samples in XML format, and retrieve transaction or student-step records in a tab-delimited format. The returned XML is structured according to the pslc_datashop_message.xsd schema. This package includes a LearnSphere Web Services allow you to access LearnSphere Workflow data in a similar way.
The LearnSphere package includes a To use web services, you need a DataShop account, a public access key ID to identify you, and a secret key used to authenticate that a request really comes from you. If you don't already have a DataShop account, you can create one for free as described here. Once you have a DataShop account, you can create access keys by visiting this web services page. 2. Package Organization
The DataShop Web Services package is organized in the following manner:
3. How to Call a Web Service Programmatically
You can call a web service from your Java program with the import edu.cmu.pslc.datashop.webservices.DatashopClient; ... String apiToken = MY_API_TOKEN; String secret = MY_SECRET_KEY; String rootURL = "https://pslcdatashop.web.cmu.edu"; String servicePath = "/datasets/1"; DatashopClient client = new DatashopClient(rootURL, apiToken, secret); String datasetXml = client.getService(servicePath, "text/xml"); The The The Similarly, you can call a LearnSphere web service from your Java program with the import edu.cmu.learnsphere.webservices.LearnSphereWebServicesClient; ... String apiToken = MY_API_TOKEN; String secret = MY_SECRET_KEY; String rootURL = "https://pslcdatashop.web.cmu.edu"; String servicePath = "/workflows"; String fileServicePath = "/workflow_files/1"; Integer workflowId = 1; String resultZipFilePath = "your_working_dir/result.zip"; LearnSphereWebServicesClient client = new LearnSphereWebServicesClient(rootURL, apiToken, secret); //get meta data for all worklows you can access String workflowXml = client.printService(servicePath, "text/xml"); //get single workflow XML String workflowXml = client.getWorkflow(workflowId); //get workflow associated files, input and output. the result zip file can be found in resultZipFilePath client.getFileService(fileServicePath, "application/zip", resultZipFilePath); 4. How to Call a Web Service from the Command Line
You can also access web services directly from the command line. The first step is to edit webservices.properties file in the package root directory to set your public API token and secret key. The initial contents should be api.token=YOUR_API_TOKEN secret=YOUR_SECRET_KEY Replace YOUR_API_TOKEN with your actual token string and YOUR_SECRET_KEY with your actual secret key and save the file. Note that the webservices.properties file must be in the directory from which you will run the program. From the command line, cd to the package root directory. Now you can call a web service like this: java -jar dist/datashop-webservices.jar "https://pslcdatashop.web.cmu.edu/services/datasets/1" The results of calling the service will be printed to standard output. The quotes around the URL are recommended because the shell might try to interpret some URL characters. Note also that when calling a web service from the command line, the entire URL must be specified. Note: If you see an error such as You can call a LearnSphere web service like this: java -jar dist/learnsphere-webservices.jar "https://pslcdatashop.web.cmu.edu/learnsphere/services/workflows?verbose=true" or java -jar dist/learnsphere-webservices.jar "https://pslcdatashop.web.cmu.edu/learnsphere/services/workflows/1?verbose=true" or //All output files for this workflow is zipped and named "result.zip"; and can be found in the current running directory java -jar dist/learnsphere-webservices.jar "https://pslcdatashop.web.cmu.edu/learnsphere/services/workflow_files/1?file_type=output" 5. Version Information
To get the version of the jar file, execute the following command on a single line: java -classpath dist/datashop-webservices.jar edu.cmu.pslc.datashop.util.VersionInformation 6. Other Programming Languages
Right now, we only have client code for Java. If you would like to access web services from another programming language, please contact us. Constructing HTTP requests to access the services should be relatively straightforward. Signing each request so that it will properly authenticate you, however, is more complex. We can help you implement the authentication part, and also advise you on constructing valid HTTP requests for accessing web services from your preferred programming language. |
|||||||||
|
|||||||||