Using cURL to access the API

Technically this isn’t a client but these are some copy-and-paste examples of how to use cURL. cURL can be very useful when automating API access, f.e. in a build server. The environment variables ${COLLECTION_ID} and ${API_TOKEN} must be set. Create a new API token in the Span dashboard

List all collections

curl -HX-API-Token:${API_TOKEN}

Extract the “name” tag from a collection

This requires jq to extract the JSON field:

curl -HX-API-Token:${API_TOKEN}${COLLECTION_ID}/tags | jq -r .Name

Upload firmware image for collection

The firmware image is in the file app_update.bin and the version should be set to 1.0.0:

    -F image=@app_update.bin \${COLLECTION_ID}/firmware)

curl -HX-API-Token:${API_TOKEN} \
    -XPATCH -d'{"version":"1.0.0"}' \${COLLECTION_ID}/firmware/${IMAGE_ID}