Back

Code Samples for AP Higher Education Score Report Web Service

Get code samples that will assist in downloading AP score report data files using the web service.

These code samples will help you set up your system to generate and download AP score report data files using the web service.

JavaScript 

Attached is a .zip file containing sample JavaScript code to generate and download AP score data files for your organization: aposrd-node-sample.zip.

To Run the Sample JavaScript Client (NodeExample.cjs)

  1. Download the ZIP file linked above, extract it, and navigate to the directory in your terminal or command line.
  2. Download and install node.js version 20.10.2 (or later).
  3. Test node.js installation -- execute ‘'node --version',’ it should display “'v20.10.0.”'
  4. Open NodeExample.cjs and update the configuration: 
    const parameters = { 
          username: 'u', // enter username credential, this will be your account email
          password: 'p', // enter password credential 
          diCode: '0000', // di code that the user account has access to 
          format: "TXT', // TXT or CSV 
    downloadType: 'full', // full or new 
    }; 
    const DOWNLOAD_LOCATION = '/Users/your_username/Downloads/'; // update this to your local download location, ex. C:/TEMP/ or /Users/your_username/Downloads/
  5. Run the script with 'node NodeExample.cjs' to generate and download a file based on the parameters entered in step 3 above.
  6. Updates will be logged such as 'Step 1/4 complete: Authentication successful.' as the script progresses. If any step is unsuccessful, you will see a message or error logged. 

Java 

Attached is a .zip file containing the sample Java project to generate and download score report data files for your organization: aposrd-java-example.zip.

 
To Run the Sample Java Cient

  1. Download the ZIP file linked above, extract it, and navigate to the directory in your terminal or command line.
  2. To build the project, gradle is needed. Gradle can be obtained from Gradle Build Tool
  3. Test gradle installation -- execute 'gradle --version', it should display the version information 'Gradle 8.14.3'
  4. Open the ./src/main/resources/config.properties file and update the configuration: 
    username=u 
    password=p 
    diCode=0000 
    format=TXT
    downloadType=full 
    downloadLocation=${user.home}/Downloads/
  5. In command line, run the project with 'gradle run' 
    prompt> gradle run 

Curl

Attached is a .zip file containing the sample curl script to generate and download score report data files for your organization: aposrd-curl-example.zip.

To Run the Sample Curl Script (curlExample.sh):

  1. Download the ZIP file linked above, extract it, and navigate to the directory in your terminal or command line.
  2. Ensure curl and jq are installed
    • for curl - test by running 'curl --version' (Mac and Windows should come with this pre-installed)
    • for jq - test by running 'jq --version', if not installed it may be found here: Download jq
  3. Open curlExample.sh, update the configuration: 
    DOWNLOAD_LOCATION="$HOME/Downloads" 
    USERNAME="u" # Replace with your username, this will be your account email 
    PASSWORD="p" # Replace with your password 
    DICODE="0000" # DI code 
    FORMAT="TXT" # File format ( TXT or, CSV) 
    DOWNLOAD_TYPE="full" # Download type (e.g., full, new)
  4. Run the script with './curlExample.sh' 
    Note: the script must have execute permissions