The Ixia Public Core Services API uses REST over HTTPS, and hence uses HTTP error codes to indicate API errors. It also uses HTTP verbs (GET, POST, etc.) to indicate the action to be taken in a specific request. The request body of every API call is a JSON object, and the response to every API call is also a JSON object.
The JSON for each API request has the following basic structure:
Every API call requires authentication. You authenticate to the Ixia API by submitting an encrypted SHA256 hash of the current date, and by including your pre-assigned client id.
"authentication": { "clientID": "MY_PREASSIGNED_CLIENT_KEY", "date": 1439401799, "dateSignature": "AAAAB3NzaC1yc2EAAAEAJ30M..." }
To get started making API calls, you will need your pre-assigned client id (provided by Ixia), and a X.509 public/private key pair. The easiest and possibly most common way to generate a X.509 key is to use OpenSSL.
# Linux-compatible platforms # Generate a new 2048-bit RSA private key and X.509 certificate (self-signed) > openssl req -x509 -nodes -days 36500 -newkey rsa:2048 -keyout my-private-key -out my-cert # Given the certificate, extract the public key to a separate file > openssl x509 -in my-cert -pubkey -noout > my-public-key # Once generated, the private and public keys will look like this: # private key -----BEGIN RSA PRIVATE KEY----- MIIEpAIBAAKCAQEAwWTmnYJ3iWHdycoK8Coib1GBw1ZPClN52tRJLKa6GX8vbNDu vVxHasItS7nF9sXNWGypFgdas6boiNQ8Zg73tom8S2seGL5zWKTewO6WEfDSbIP0 F5ioftVtY5i8DyC65CylkxKXaYuI7OZTdAC... -----END RSA PRIVATE KEY----- # public key -----BEGIN PUBLIC KEY----- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwWTmnYJ3iWHdycoK8Coi b1GBw1ZPClN52tRJLKa6GX8vbNDuvVxHasItS7nF9sXNWGypFgdas6boiNQ8Zg73 tom8S2seGL5zWKTewO6WEfDSbIP0F5ioftV... -----END PUBLIC KEY----- # Note that to load the private key in Java, you must first convert it to PKCS#8 encoding > openssl pkcs8 -topk8 -nocrypt -outform DER < my-private-key > my-private-key-pkcs8
Once generated, send your public key file to Ixia. Then use the private key to create a cryptographic signature of the date field. Writing code to generate the date and date signature is relatively straightforward. Below are code snippets in Bash and Java.
# Linux-compatible platforms # Get the current date in seconds since the Epoch, and write to a file > date +%s | awk '{printf $0}' > date.txt # Get the signature of the date, and write to a file > openssl sha -sha256 -binary < date.txt | openssl rsautl -inkey my-private-key -sign | openssl base64 | awk '{printf $0}' > signature.txt # The date and date signature are now in date.txt and signature.txt respectively
Note that the above Java code sample uses Apache Commons.
Some API calls require meta data to be included in the request. This meta data structure is unique to each individual API call, and contains additional parameters that control how the request is processed.
"metadata": { ... fields related to the specific API call ... }
The request details contain the content of the request, and are hence unique to each individual API call.
"requestDetails": { ... fields related to the specific API call ... }
There are two HTTP verbs that can be used to make API calls; GET and POST.
GET requests:
GET /<requestType>?query=... # where the query cgi parameter is the base-64 form of the JSON basic request structure.
GET /salestax?query=iVBORw0KGgoAAAANSUhEUgAAAFEAAAAmCAYAAAC8qHdPAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1... # where iVBORw0KGgoAAAANSUhEUgAAAFEAAAAmCAYAAAC8qHdPAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1 is the base-64 encoded version of the JSON request object
POST requests:
POST /<requestType>
, where the POST data of the request is the JSON basic request structure.