← Back to Home

Image (Content Negotiation)

/image
Returns an image based on Accept header (content negotiation).

Parameters

Accept header
Specify image format (image/png, image/jpeg, image/webp, image/svg+xml)

Examples

curl
curl -H "Accept: image/png" https://tcpdata.com/image -o image.png
JavaScript (fetch)
fetch('https://tcpdata.com/image', {
  headers: { 'Accept': 'image/png' }
})
  .then(res => res.blob())
  .then(blob => console.log(blob));
Python (requests)
import requests

headers = {'Accept': 'image/png'}
response = requests.get('https://tcpdata.com/image', headers=headers)
with open('image.png', 'wb') as f:
    f.write(response.content)