-
Notifications
You must be signed in to change notification settings - Fork 0
/
apiary.apib
217 lines (179 loc) · 9.2 KB
/
apiary.apib
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
FORMAT: 1A
HOST: https://api.shipcloud.io
# shipcloud API v1
## Introduction
To make it easier for you the developer, we've created the Shipcloud API deliberately using the RESTful architectural style. This means if you're familiar with REST and using RESTful services, you will have no problems using our API. As it's common when implementing a REST-API we're using resource-oriented URLs and HTTP authentication.
For developers to test their code before shipping it, we're supplying every account with test and live API keys.
## Authentication
Every call to our API is secured by an API key. This key is tied specificly to your account and therefore should never be given to anyone else outside of your control. You are able to manage your API keys from your account page.
Aside from sending you're API key all API requests must be made using HTTPS. Don't bother trying to use HTTP. It will fail!
## Versioning
From time to time we will be releasing new versions of our API. In order to not break (your) implementations of our API, we will adjust the path to reflect each new major version. So consecutive releases will be called using /v2/, /v3/ and so on after the base url.
## Address handling
When sending __to__ or __from__ parameters you have to specify a contact for the shipment. This can either be a __company__ or a person identified by __first_name__ and __last_name__. So although the entries are marked as being optional, one of them has to be specified in the request.
# Shipment Resources [/shipments]
The following is a section of resources related to shipments. Be advised: We will charge you only for shipments that a label was created for.
## Creating a shipment [POST]
If you want to create a shipment, this is the way to go!
+ Request (application/json)
+ Headers
Authorization: [Base64](http://en.wikipedia.org/wiki/Base64) encoded string literal in form _"apikey:"_ preceeded by authorization method and its space.
+ Body
{
"to": {
"company": "Receiver Inc.",
"first_name": "Max",
"last_name": "Mustermann",
"street": "Beispielstrasse",
"street_no": "42",
"city": "Hamburg",
"zip_code": "22100"
},
"package": {
"weight": 1.5,
"length": 20,
"width": 20,
"height": 20
},
"carrier": "dhl",
"reference_number": "ref123456",
"create_shipping_label": true
}
+ Response 200 (application/json)
+ Body
{
"id": "3a186c51d4281acbecf5ed38805b1db92a9d668b",
"carrier_tracking_no": "84168117830018",
"tracking_url": "http://track.shipcloud.io/3a186c51d4",
"label_url": "http://api.shipcloud.io/shipping_label_3a186c51d4.pdf",
"price": 3.4
}
## Working with shipments [/shipments/{id}]
After creating a shipment, you can still do awesome stuff with it like finding out every piece of data we have on it or even deleting it, in case you've made a mistake while creating it.
+ Parameters
+ id (number, `3a186c51d4281acbecf5ed38805b1db92a9d668b`) ... This is the ID of your shipment returned to you when creating a shipment
### Get all infos [GET]
You can get every piece of information we know about a shipment with this single call.
+ Request
+ Headers
Authorization: [Base64](http://en.wikipedia.org/wiki/Base64) encoded string literal in form _"apikey:"_ preceeded by authorization method and its space.
+ Response 200 (application/json)
{
"id": "3a186c51d4281acbecf5ed38805b1db92a9d668b",
"carrier_tracking_no": "84168117830018",
"carrier": "dhl",
"created_at": "2013-04-16T10:43:04Z",
"tracking_url": "http://track.shipcloud.io/3a186c51d4",
"label_url": "http://api.shipcloud.io/shipping_label_3a186c51d4.pdf",
"from": {
"company": "Musterfirma",
"first_name": "Hans",
"last_name": "Meier",
"care_of": null,
"street": "Musterstraße",
"street_no": "22",
"city": "Musterstadt",
"zip_code": "12345",
"state": null,
"country": "de"
},
"to": {
"company": "Receiver Inc.",
"first_name": "Max",
"last_name": "Mustermann",
"street": "Beispielstrasse",
"street_no": "42",
"city": "Hamburg",
"zip_code": "22100",
"state": null,
"country": "de"
},
"packages": [
{
"id": "3af8f7e5af196e1950deebd389a87406e1e5bb80",
"weight": 1.5,
"length": 10.0,
"width": 6.0,
"height": 8.0,
"tracking_events": [
{
"timestamp": "2013-05-26T16:55:24+02:00",
"location": "Hamburg, Deutschland",
"status": "delivered"
"details": "Die Sendung wurde erfolgreich zugestellt."
},
{
"timestamp": "2013-05-26T08:12:12+02:00",
"location": "Hamburg, Deutschland",
"status": "out_for_delivery"
"details": "Die Sendung wurde in das Zustellfahrzeug geladen."
},
{
"timestamp": "2013-05-25T11:46:34+02:00",
"location": "Hamburg, Deutschland",
"status": "transit"
"details": "Die Sendung wurde im Start-Paketzentrum bearbeitet."
}
]
}
],
"price": 3.4,
"reference_number": "ref123456"
}
### Updating a shipment [PUT]
If you haven't already created a shipping label for your shipment, you can still adjust it's parameters using this call.
+ Parameters
+ carrier (optional, string) ... the carrier you want to use. Possible values are _"DHL", "UPS", "HERMES", "DPD"_
+ to (optional) ... object describing the receivers address
+ company (optional, string) ... the receivers company name
+ first_name (optional, string) ... the receivers first name
+ last_name (optional, string) ... the receivers last name
+ care_of (optional, string) ... name of the person that should be able to receive the package
+ street (optional, string) ... street name
+ street_no (optional, string) ... house number
+ city (optional, string) ... city
+ zip_code(optional, string) ... zip code
+ state (optional, string) ... state
+ country (optional, string) ... country as ISO 3166-1 alpha-2 code
+ from (optional) ... object describing the senders address. Address definition: see "to". If missing, the default sender address (if defined in your shipcloud account) will be used
+ package (optional) ... object describing the package dimensions
+ number (string) ... used to identify the package
+ width (optional, float) ... width of the package in cm
+ length (optional, float) ... length of the package in cm
+ height (optional, float) ... height of the package in cm
+ weight (optional, float) ... weight in kg
+ reference_number (optional, string) ... a reference number (max. 255 characters) that you want this shipment to be identified with. You can use this afterwards to easier find the shipment in the shipcloud.io backoffice
+ create_shipping_label (boolean) ... determines if a shipping label should be created at the carrier (this means you will be charged)
+ Request (application/json)
+ Headers
Authorization: [Base64](http://en.wikipedia.org/wiki/Base64) encoded string literal in form _"apikey:"_ preceeded by authorization method and its space.
+ Body
{
"to":{
"company": "Receiver Inc.",
"first_name": "Max",
"last_name": "Mustermann",
"street": "Beispielstrasse",
"street_no": "42",
"city": "Hamburg",
"zip_code": "22100"
},
"package": {
"weight": 1.5,
"length": 20,
"width": 20,
"height": 20
},
"carrier": "dhl",
"reference_number": "ref123456",
"create_shipping_label" :true
}
+ Response 200 (application/json)
+ Body
{
"id": "3a186c51d4281acbecf5ed38805b1db92a9d668b",
"carrier_tracking_no": "84168117830018",
"tracking_url": "http://track.shipcloud.io/3a186c51d4",
"label_url": "http://api.shipcloud.io/shipping_label_3a186c51d4.pdf",
"price": 3.4
}