Ways to Download a Label
Option 1: Download via URL
By default, ShipEngine provides URLs to download labels in multiple formats. The URLs will remain valid for 90 days.
You can download the label in your web browser by appending ?download=0
to the URL. Or you download it on the command line using curl:
Label Rotation
You can rotate the label 90
, 180
, or 360
degrees by appending ?rotation=:value
to the URL.
- Supported for
zpl
andpdf
formats. - Valid
rotation
value forzpl
labels are0
(default) and180
. - Valid
rotation
values forpdf
labels are0
(default),90
,180
, and270
.
You can view the rotated image in your web browser using this URL or download it on the command line using curl:
Option 2: Inline Label
If you only intend to download the label in a single format, and you know ahead of time which format that is, then you can optimize your workflow by eliminating the extra HTTP request to download the label. Instead, you can use the label_format
, label_layout
, and label_download_type
fields to include the full label in the API response.
Label Format | Description pdf |
---|---|
pdf (default) | Adobe PDF format. This is the default if label_format is unspecified. |
png | A PNG (portable network graphics) image file |
zpl | Zebra Programming Language format, which is useful for printing with a Zebra Printer |
Label Layout | Description |
---|---|
4x6 (default) | 4 inches by 6 inches This is the default if label_layout is unspecified. |
letter | U.S. Letter size (8.5 inches by 11 inches) |
Label Download Type | Description |
---|---|
url (default) | You will receive URLs to download the label in separate HTTP requests. The URLs will remain valid for 90 days. This is the default if label_download_type is unspecified. |
inline | You will receive a single, Base64-encoded label as part of the response. No need for a second request to download the label. |
Example
This example demonstrates how to use label_format
, label_layout
, and label_download_type
to request a 4x6
PNG label to be included in the API response.
The label_download.href
field in the response will be a Data URI, which is a special kind of URL that includes the data inline.
The Data URI has four parts: scheme:media type;encoding,data
Name | Examples | Description |
---|---|---|
Scheme | Always data: | This just identifies the URL as a Data URI, as opposed to other schemes, such as http: or ftp: . |
Media Type | application/pdf image/png application/zpl | This is the label's MIME Type, which corresponds to the label_format that you specified when creating the label. |
Encoding Type | Always base64 | ShipEngine always encodes inline labels in Base64 format. |
Data | A very long Base64 string | This is the actual Base64-encoded label data. \n\nMost programming languages include a Base64 decoder as part of their standard library. If your language doesn't, then you may need to use a third-party Base64 decoder. |