Welcome to Anvil API usage examples in Java! There are example scripts for the following API actions.
All of these files are within the com.useanvil.examples
namespace.
- Filling a PDF template with your own data
- Generating a PDF from HTML and CSS
- Generating a PDF from Markdown
- Creating an e-sign packet
- Starting a workflow and updating workflow submissions
- Making an arbitrary GraphQL request
- Java 11 and above
- Maven - https://maven.apache.org/install.html
These examples were built with Java 11 in mind -- mainly for java.net.http.HttpClient
. If you would like to run these
examples in older versions of Java, the com.useanvil.examples.client
clients should be changed to use a different
HTTP client.
All scripts will require that you have an Anvil API key. See the getting started documentation for help grabbing your API key.
Each example is set up to be runnable with minimal input. Once you have an API key, you can clone this repo and run the example scripts from this directory.
Once you have this repo cloned, cd into this java
directory and install the dependencies:
cd java
# Download dependencies and built the .jar file
mvn clean package
[INFO] Building jar: /anvil-api-usage-examples/java/target/Examples-1.0-SNAPSHOT.jar
# Run the example that you want.
# Replace `<example-name>` with one of:
# make-graphql-request, fill-pdf,
# generate-html-to-pdf, generate-markdown-to-pdf,
# create-etch-packet, create-update-workflow
ANVIL_API_KEY="YOUR_KEY_HERE" java -jar target/Examples-1.0-SNAPSHOT.jar <example-name>
The program will output filled and generated PDFs into the output directory.
ANVIL_API_KEY="YOUR_KEY_HERE" java -jar target/Examples-1.0-SNAPSHOT.jar fill-pdf
Generate a PDF from HTML and CSS:
ANVIL_API_KEY="YOUR_KEY_HERE" java -jar target/Examples-1.0-SNAPSHOT.jar generate-html-to-pdf
ANVIL_API_KEY="YOUR_KEY_HERE" java -jar target/Examples-1.0-SNAPSHOT.jar generate-markdown-to-pdf
ANVIL_API_KEY="YOUR_KEY_HERE" java -jar target/Examples-1.0-SNAPSHOT.jar create-etch-packet <[email protected]>
Start and update workflow submissions:
ANVIL_API_KEY="YOUR_KEY_HERE" java -jar target/Examples-1.0-SNAPSHOT.jar create-update-workflow <your-org-slug>
Make an arbitrary GraphQL request:
ANVIL_API_KEY="YOUR_KEY_HERE" java -jar target/Examples-1.0-SNAPSHOT.jar make-graphql-request