Docs
Example: curl
title: "curl Example"
curl Example
These examples show how to use the Profile Scoring API from the command line with curl.
Score a file
curl -X POST https://api.ausynth.com/api/score \
-H "Authorization: Bearer ask_live_abc123def456" \
-F "file=@my_customers.csv" \
-o response.json
cat response.json | python -m json.tool
This uploads my_customers.csv and saves the API response to response.json. The -F flag sends the file as multipart/form-data.
Download the scored CSV
The response includes a download_url. Extract it and download:
# Extract the download URL from the response
DOWNLOAD_URL=$(cat response.json | python -c "import sys,json; print(json.load(sys.stdin)['download_url'])")
# Download the scored CSV
curl -o scored_output.csv "$DOWNLOAD_URL"
# Preview the first few rows
head -5 scored_output.csv
Inspect response headers
Use -v (verbose) or -i (include headers) to see HTTP status codes and rate limit headers:
curl -i -X POST https://api.ausynth.com/api/score \
-H "Authorization: Bearer ask_live_abc123def456" \
-F "file=@my_customers.csv"
What a 401 looks like
If the key is wrong or missing:
$ curl -i -X POST https://api.ausynth.com/api/score \
-H "Authorization: Bearer ask_live_WRONG_KEY" \
-F "file=@my_customers.csv"
HTTP/2 401
content-type: application/json
{"error":"unauthorized","message":"Missing or invalid API key. Generate one at /account/api."}
Retry on 429
If you hit the rate limit:
$ curl -i -X POST https://api.ausynth.com/api/score \
-H "Authorization: Bearer ask_live_abc123def456" \
-F "file=@my_customers.csv"
HTTP/2 429
content-type: application/json
{"error":"rate_limit_exceeded","retry_after_seconds":60}
Wait the specified number of seconds and retry:
sleep 60
curl -X POST https://api.ausynth.com/api/score \
-H "Authorization: Bearer ask_live_abc123def456" \
-F "file=@my_customers.csv"
Poll an async job
For files over 10,000 rows, the API returns a poll_url instead of immediate results:
# Initial upload returns 202
curl -X POST https://api.ausynth.com/api/score \
-H "Authorization: Bearer ask_live_abc123def456" \
-F "file=@large_file.csv" \
-o response.json
# Extract poll URL
POLL_URL=$(cat response.json | python -c "import sys,json; print(json.load(sys.stdin)['poll_url'])")
# Poll until complete
while true; do
RESULT=$(curl -s "https://api.ausynth.com${POLL_URL}" \
-H "Authorization: Bearer ask_live_abc123def456")
STATUS=$(echo "$RESULT" | python -c "import sys,json; print(json.load(sys.stdin)['status'])")
if [ "$STATUS" = "complete" ]; then
echo "Done!"
echo "$RESULT" | python -m json.tool
break
fi
echo "Still processing..."
sleep 5
done
One-liner
Score a file and download the result in one command chain:
curl -s -X POST https://api.ausynth.com/api/score \
-H "Authorization: Bearer $AUSYNTH_API_KEY" \
-F "file=@my_customers.csv" \
| python -c "import sys,json; r=json.load(sys.stdin); print(f'Scored {r[\"rows_scored\"]} rows'); import urllib.request; urllib.request.urlretrieve(r['download_url'], 'scored.csv')"
Set your key as an environment variable first:
export AUSYNTH_API_KEY="ask_live_abc123def456"