### Basic HTTP POST Request Setup (Go) Source: https://www.shipstation.com/docs/api/orders/create-update-order Basic setup for making an HTTP POST request in Go, including defining the URL and method. This snippet is a starting point for constructing more complex requests. ```go package main import ( "fmt" "strings" "net/http" "io/ioutil" ) func main() { url := "https://ssapi.shipstation.com/orders/createorder" method := "POST" ``` -------------------------------- ### Go HTTP Client Example Source: https://www.shipstation.com/docs/api/stores/get-store This Go program demonstrates making a GET request to retrieve store information. ```Go package main import ( "fmt" "net/http" "io/ioutil" ) func main() { url := "https://ssapi.shipstation.com/stores/storeId" method := "GET" client := &http.Client { } req, err := http.NewRequest(method, url, nil) if err != nil { fmt.Println(err) } req.Header.Add("Host", "ssapi.shipstation.com") req.Header.Add("Authorization", "__YOUR_AUTH_HERE__") res, err := client.Do(req) defer res.Body.Close() body, err := ioutil.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Go HTTP Client Example Source: https://www.shipstation.com/docs/api/carriers/get Demonstrates making a GET request for carrier information using Go's standard HTTP client. ```Go package main import ( "fmt" "net/http" "io/ioutil" ) func main() { url := "https://ssapi.shipstation.com/carriers/getcarrier?carrierCode=%7BcarrierCode%7D" method := "GET" client := &http.Client { } req, err := http.NewRequest(method, url, nil) if err != nil { fmt.Println(err) } req.Header.Add("Host", "ssapi.shipstation.com") req.Header.Add("Authorization", "__YOUR_AUTH_HERE__") res, err := client.Do(req) defer res.Body.Close() body, err := ioutil.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### List Marketplaces Source: https://www.shipstation.com/docs/api/stores/list-marketplaces This example demonstrates how to retrieve a list of all marketplaces connected to your ShipStation account using a GET request. ```APIDOC ## GET /stores/marketplaces ### Description Retrieves a list of all marketplaces connected to your ShipStation account. ### Method GET ### Endpoint https://ssapi.shipstation.com/stores/marketplaces ### Parameters #### Query Parameters This endpoint does not accept any query parameters. ### Request Example ```http GET /stores/marketplaces HTTP/1.1 Host: ssapi.shipstation.com Authorization: __YOUR_AUTH_HERE__ ``` ### Response #### Success Response (200) Returns a JSON object containing a list of marketplaces. The exact structure of the marketplace objects is not detailed in the source. #### Response Example (Response structure not provided in source) ``` -------------------------------- ### Register Account with Go Source: https://www.shipstation.com/docs/api/accounts/create This Go example shows how to register a new account using the standard net/http package. It includes setting up the request, headers, and payload. ```go package main import ( "fmt" "strings" "net/http" "io/ioutil" ) func main() { url := "https://ssapi.shipstation.com/accounts/registeraccount" method := "POST" payload := strings.NewReader("{\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"jsmithtest@gmail.com\",\n \"password\": \"testpw1234\",\n \"shippingOriginCountryCode\": \"US\",\n \"companyName\": \"Droid Repair LLC\",\n \"addr1\": \"542 Midichlorian Rd.\",\n \"addr2\": \"\",\n \"city\": \"Austin\",\n \"state\": \"TX\",\n \"zip\": \"78703\",\n \"countryCode\": \"US\",\n \"phone\": \"5124111234\"\n}") client := &http.Client { } req, err := http.NewRequest(method, url, payload) if err != nil { fmt.Println(err) } req.Header.Add("Host", "ssapi.shipstation.com") req.Header.Add("Content-Type", "application/json") res, err := client.Do(req) defer res.Body.Close() body, err := ioutil.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Node.js Request Example Source: https://www.shipstation.com/docs/api/warehouses/get This Node.js example uses the 'request' library to perform a GET request for warehouse details. Ensure you have the 'request' library installed and replace '__YOUR_AUTH_HERE__'. ```javascript var request = require('request'); var options = { 'method': 'GET', 'url': 'https://ssapi.shipstation.com/warehouses/warehouseId', 'headers': { 'Host': 'ssapi.shipstation.com', 'Authorization': '__YOUR_AUTH_HERE__' } }; request(options, function (error, response) { if (error) throw new Error(error); console.log(response.body); }); ``` -------------------------------- ### Python Requests GET Request for Users Source: https://www.shipstation.com/docs/api/users/list This Python example uses the 'requests' library to fetch users. Ensure 'requests' is installed and replace '__YOUR_AUTH_HERE__' with your token. ```python import requests url = "https://ssapi.shipstation.com/users?showInactive=false" payload = {} headers = { 'Host': 'ssapi.shipstation.com', 'Authorization': '__YOUR_AUTH_HERE__' } response = requests.request("GET", url, headers=headers, data = payload) print(response.text.encode('utf8')) ``` -------------------------------- ### Go HTTP Client Request to List Packages Source: https://www.shipstation.com/docs/api/carriers/list-packages This Go example demonstrates how to list packages using the standard net/http package. Ensure your 'Authorization' header is correctly provided. ```Go package main import ( "fmt" "net/http" "io/ioutil" ) func main() { url := "https://ssapi.shipstation.com/carriers/listpackages?carrierCode=carrierCode" method := "GET" client := &http.Client { } req, err := http.NewRequest(method, url, nil) if err != nil { fmt.Println(err) } req.Header.Add("Host", "ssapi.shipstation.com") req.Header.Add("Authorization", "__YOUR_AUTH_HERE__") res, err := client.Do(req) defer res.Body.Close() body, err := ioutil.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Java OkHttpClient for Products Source: https://www.shipstation.com/docs/api/products/list This example demonstrates initiating a request for products using OkHttpClient in Java. ```java OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() ``` -------------------------------- ### List Carriers using Python Requests Source: https://www.shipstation.com/docs/api/carriers/list This Python example uses the 'requests' library to get carrier information. Make sure the 'requests' library is installed. Replace '__YOUR_AUTH_HERE__' with your authorization token. ```python import requests url = "https://ssapi.shipstation.com/carriers" payload = {} headers = { 'Host': 'ssapi.shipstation.com', 'Authorization': '__YOUR_AUTH_HERE__' } response = requests.request("GET", url, headers=headers, data = payload) print(response.text.encode('utf8')) ``` -------------------------------- ### JavaScript Fetch API Example Source: https://www.shipstation.com/docs/api/stores/get-store This JavaScript example uses the Fetch API to get store information. ```JavaScript var myHeaders = new Headers(); myHeaders.append("Host", "ssapi.shipstation.com"); myHeaders.append("Authorization", "__YOUR_AUTH_HERE__"); var requestOptions = { method: 'GET', headers: myHeaders, redirect: 'follow' }; fetch("https://ssapi.shipstation.com/stores/storeId", requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error)); ``` -------------------------------- ### Get Warehouse by ID Source: https://www.shipstation.com/docs/api/warehouses/get This example demonstrates how to retrieve a warehouse's details using its ID via an HTTP GET request. ```APIDOC ## GET /warehouses/warehouseId ### Description Retrieves the details of a specific warehouse by its ID. ### Method GET ### Endpoint /warehouses/warehouseId ### Parameters #### Path Parameters - **warehouseId** (string) - Required - The unique identifier of the warehouse to retrieve. ### Request Example ``` GET /warehouses/warehouseId HTTP/1.1 Host: ssapi.shipstation.com Authorization: __YOUR_AUTH_HERE__ ``` ### Response #### Success Response (200) - **warehouseId** (integer) - The unique identifier for the warehouse. - **warehouseKey** (string) - The key for the warehouse. - **name** (string) - The name of the warehouse. - **isDefault** (boolean) - Indicates if this is the default warehouse. - **city** (string) - The city where the warehouse is located. - **state** (string) - The state or province where the warehouse is located. - **zipCode** (string) - The postal code of the warehouse. - **country** (string) - The country where the warehouse is located. - **phone** (string) - The phone number for the warehouse. - **email** (string) - The email address for the warehouse. - **mondayOpen** (string) - The opening time on Monday (HH:MM). - **mondayClose** (string) - The closing time on Monday (HH:MM). - **tuesdayOpen** (string) - The opening time on Tuesday (HH:MM). - **tuesdayClose** (string) - The closing time on Tuesday (HH:MM). - **wednesdayOpen** (string) - The opening time on Wednesday (HH:MM). - **wednesdayClose** (string) - The closing time on Wednesday (HH:MM). - **thursdayOpen** (string) - The opening time on Thursday (HH:MM). - **thursdayClose** (string) - The closing time on Thursday (HH:MM). - **fridayOpen** (string) - The opening time on Friday (HH:MM). - **fridayClose** (string) - The closing time on Friday (HH:MM). - **saturdayOpen** (string) - The opening time on Saturday (HH:MM). - **saturdayClose** (string) - The closing time on Saturday (HH:MM). - **sundayOpen** (string) - The opening time on Sunday (HH:MM). - **sundayClose** (string) - The closing time on Sunday (HH:MM). ### Response Example ```json { "warehouseId": 12345, "warehouseKey": "WH-ABC-123", "name": "Main Warehouse", "isDefault": true, "city": "Anytown", "state": "CA", "zipCode": "90210", "country": "US", "phone": "555-123-4567", "email": "warehouse@example.com", "mondayOpen": "09:00", "mondayClose": "17:00", "tuesdayOpen": "09:00", "tuesdayClose": "17:00", "wednesdayOpen": "09:00", "wednesdayClose": "17:00", "thursdayOpen": "09:00", "thursdayClose": "17:00", "fridayOpen": "09:00", "fridayClose": "17:00", "saturdayOpen": "10:00", "saturdayClose": "14:00", "sundayOpen": null, "sundayClose": null } ``` ``` -------------------------------- ### Go HTTP Client Example Source: https://www.shipstation.com/docs/api/orders/get-order This Go program demonstrates fetching order details using the standard http package. ```Go package main import ( "fmt" "net/http" "io/ioutil" ) func main() { url := "https://ssapi.shipstation.com/orders/orderId" method := "GET" client := &http.Client { } req, err := http.NewRequest(method, url, nil) if err != nil { fmt.Println(err) } req.Header.Add("Host", "ssapi.shipstation.com") req.Header.Add("Authorization", "__YOUR_AUTH_HERE__") res, err := client.Do(req) defer res.Body.Close() body, err := ioutil.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Node.js Request for Get Rates Source: https://www.shipstation.com/docs/api/shipments/get-rates This Node.js example uses the 'request' library to get shipping rates. Update '__YOUR_AUTH_HERE__' with your authorization token. ```JavaScript var request = require('request'); var options = { 'method': 'POST', 'url': 'https://ssapi.shipstation.com/shipments/getrates', 'headers': { 'Host': 'ssapi.shipstation.com', 'Authorization': '__YOUR_AUTH_HERE__', 'Content-Type': 'application/json' }, body: JSON.stringify({"carrierCode":"fedex","serviceCode":null,"packageCode":null,"fromPostalCode":"78703","toState":"DC","toCountry":"US","toPostalCode":"20500","toCity":"Washington","weight":{"value":3,"units":"ounces"},"dimensions":{"units":"inches","length":7,"width":5,"height":6},"confirmation":"delivery","residential":false}) }; request(options, function (error, response) { if (error) throw new Error(error); console.log(response.body); }); ``` -------------------------------- ### JavaScript Fetch API GET Request for Users Source: https://www.shipstation.com/docs/api/users/list Example using the Fetch API in JavaScript to get users. Replace '__YOUR_AUTH_HERE__' with your authorization token. ```javascript var myHeaders = new Headers(); myHeaders.append("Host", "ssapi.shipstation.com"); myHeaders.append("Authorization", "__YOUR_AUTH_HERE__"); var requestOptions = { method: 'GET', headers: myHeaders, redirect: 'follow' }; fetch("https://ssapi.shipstation.com/users?showInactive=false", requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error)); ``` -------------------------------- ### List Fulfillments with Query Parameters (Go) Source: https://www.shipstation.com/docs/api/fulfillments/list-fulfillments This Go example demonstrates how to fetch a list of fulfillments using the standard `net/http` package. It includes common query parameters for filtering and sorting. Replace '__YOUR_AUTH_HERE__' with your API key. ```go package main import ( "fmt" "net/http" "io/ioutil" ) func main() { url := "https://ssapi.shipstation.com/fulfillments?fulfillmentId=%7BfulfillmentId%7D&orderId=%7BorderId%7D&orderNumber=%7BorderNumber%7D&trackingNumber=%7BtrackingNumber%7D&recipientName=%7BrecipientName%7D&createDateStart=%7BcreateDateStart%7D&createDateEnd=%7BcreateDateEnd%7D&shipDateStart=%7BshipDateStart%7D&shipDateEnd=%7BshipDateEnd%7D&sortBy=%7BsortBy%7D&sortDir=%7BsortDir%7D&page=%7Bpage%7D&pageSize=%7BpageSize%7D" method := "GET" client := &http.Client { } req, err := http.NewRequest(method, url, nil) if err != nil { fmt.Println(err) } req.Header.Add("Host", "ssapi.shipstation.com") req.Header.Add("Authorization", "__YOUR_AUTH_HERE__") res, err := client.Do(req) defer res.Body.Close() body, err := ioutil.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Objective-C NSURLSession for Get Refresh Status Source: https://www.shipstation.com/docs/api/stores/get-refresh-status An Objective-C example using `NSURLSession` to get store refresh status. Replace `storeId` and `__YOUR_AUTH_HERE__` with your credentials. ```Objective-C #import dispatch_semaphore_t sema = dispatch_semaphore_create(0); NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://ssapi.shipstation.com/stores/getrefreshstatus?storeId=storeId"] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10.0]; NSDictionary *headers = @{ @"Host": @"ssapi.shipstation.com", @"Authorization": @"__YOUR_AUTH_HERE__" }; [request setAllHTTPHeaderFields:headers]; [request setHTTPMethod:@"GET"]; NSURLSession *session = [NSURLSession sharedSession]; NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { if (error) { NSLog(@"%@", error); } else { NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response; NSError *parseError = nil; ``` -------------------------------- ### Go HTTP Client for Listing Stores Source: https://www.shipstation.com/docs/api/stores/list This Go example uses the standard HTTP client to list stores. Replace '__YOUR_AUTH_HERE__' with your authorization token. ```go package main import ( "fmt" "net/http" "io/ioutil" ) func main() { url := "https://ssapi.shipstation.com/stores?showInactive=showInactive&marketplaceId=marketplaceId" method := "GET" client := &http.Client { } req, err := http.NewRequest(method, url, nil) if err != nil { fmt.Println(err) } req.Header.Add("Host", "ssapi.shipstation.com") req.Header.Add("Authorization", "__YOUR_AUTH_HERE__") res, err := client.Do(req) defer res.Body.Close() body, err := ioutil.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Java OkHttp for Get Refresh Status Source: https://www.shipstation.com/docs/api/stores/get-refresh-status An example using OkHttp in Java to get store refresh status. Remember to replace `storeId` and `__YOUR_AUTH_HERE__`. ```Java OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://ssapi.shipstation.com/stores/getrefreshstatus?storeId=storeId") .method("GET", null) .addHeader("Host", "ssapi.shipstation.com") .addHeader("Authorization", "__YOUR_AUTH_HERE__") .build(); Response response = client.newCall(request).execute(); ``` -------------------------------- ### Go HTTP Client Example Source: https://www.shipstation.com/docs/api/orders/add-tag This Go program demonstrates how to add a tag to an order using the standard http client. Replace '__YOUR_AUTH_HERE__' with your authorization. ```go package main import ( "fmt" "strings" "net/http" "io/ioutil" ) func main() { url := "https://ssapi.shipstation.com/orders/addtag" method := "POST" payload := strings.NewReader("{ \"orderId\": 123456, \"tagId\": 1234 }") client := &http.Client { } req, err := http.NewRequest(method, url, payload) if err != nil { fmt.Println(err) } req.Header.Add("Host", "ssapi.shipstation.com") req.Header.Add("Authorization", "__YOUR_AUTH_HERE__") req.Header.Add("Content-Type", "application/json") res, err := client.Do(req) ``` -------------------------------- ### PHP cURL Request for Get Refresh Status Source: https://www.shipstation.com/docs/api/stores/get-refresh-status A PHP example using cURL to get the refresh status of a store. Replace `storeId` and `__YOUR_AUTH_HERE__` with your specific values. ```PHP "https://ssapi.shipstation.com/stores/getrefreshstatus?storeId=storeId", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => array( "Host: ssapi.shipstation.com", "Authorization: __YOUR_AUTH_HERE__" ), )); $response = curl_exec($curl); curl_close($curl); echo $response; ?> ``` -------------------------------- ### Go HTTP Client Example Source: https://www.shipstation.com/docs/api/orders/list-by-tag Shows how to list orders by tag using Go's standard HTTP client. ```Go package main import ( "fmt" "net/http" "io/ioutil" ) func main() { url := "https://ssapi.shipstation.com/orders/listbytag?orderStatus=orderStatus&tagId=tagId&page=page&pageSize=pageSize" method := "GET" client := &http.Client { } req, err := http.NewRequest(method, url, nil) if err != nil { fmt.Println(err) } req.Header.Add("Host", "ssapi.shipstation.com") req.Header.Add("Authorization", "__YOUR_AUTH_HERE__") res, err := client.Do(req) defer res.Body.Close() body, err := ioutil.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Go HTTP Client Example Source: https://www.shipstation.com/docs/api/warehouses/get This Go program demonstrates how to fetch warehouse details using the standard net/http package. It constructs an HTTP request with the necessary headers. Replace '__YOUR_AUTH_HERE__' with your token. ```go package main import ( "fmt" "net/http" "io/ioutil" ) func main() { url := "https://ssapi.shipstation.com/warehouses/warehouseId" method := "GET" client := &http.Client { } req, err := http.NewRequest(method, url, nil) if err != nil { fmt.Println(err) } req.Header.Add("Host", "ssapi.shipstation.com") req.Header.Add("Authorization", "__YOUR_AUTH_HERE__") res, err := client.Do(req) defer res.Body.Close() body, err := ioutil.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### JavaScript Fetch API for Get Refresh Status Source: https://www.shipstation.com/docs/api/stores/get-refresh-status An example using the Fetch API in JavaScript to get store refresh status. Update `storeId` and `__YOUR_AUTH_HERE__` as needed. ```JavaScript var myHeaders = new Headers(); myHeaders.append("Host", "ssapi.shipstation.com"); myHeaders.append("Authorization", "__YOUR_AUTH_HERE__"); var requestOptions = { method: 'GET', headers: myHeaders, redirect: 'follow' }; fetch("https://ssapi.shipstation.com/stores/getrefreshstatus?storeId=storeId", requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error)); ``` -------------------------------- ### PHP cURL GET Request for Shipments Source: https://www.shipstation.com/docs/api/shipments/list A PHP example using cURL to make a GET request for shipments. It configures all necessary cURL options, including headers and URL. ```php "https://ssapi.shipstation.com/shipments?recipientName=recipientName&recipientCountryCode=recipientCountryCode&orderNumber=orderNumber&orderId=orderId&carrierCode=carrierCode&serviceCode=serviceCode&trackingNumber=trackingNumber&createDateStart=createDateStart&createDateEnd=createDateEnd&shipDateStart=shipDateStart&shipDateEnd=shipDateEnd&voidDateStart=voidDateStart&voidDateEnd=voidDateEnd&storeId=storeId&includeShipmentItems=includeShipmentItems&sortBy=sortBy&sortDir=sortDir&page=page&pageSize=pageSize", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => array( "Host: ssapi.shipstation.com", "Authorization: __YOUR_AUTH_HERE__" ), )); $response = curl_exec($curl); curl_close($curl); echo $response; ``` -------------------------------- ### Create Warehouse with Go Source: https://www.shipstation.com/docs/api/warehouses/create This Go program demonstrates creating a warehouse using the standard net/http package. Replace '__YOUR_AUTH_HERE__' with your valid authorization header. ```go package main import ( "fmt" "strings" "net/http" "io/ioutil" ) func main() { url := "https://ssapi.shipstation.com/warehouses/createwarehouse" method := "POST" payload := strings.NewReader("{\n \"warehouseName\": \"New Ship From Location\",\n \"originAddress\": {\n \"name\": \"NM Warehouse\",\n \"company\": \"White Sands Co.\",\n \"street1\": \"4704 Arabela Dr.\",\n \"street2\": null,\n \"street3\": null,\n \"city\": \"Las Cruces\",\n \"state\": \"NM\",\n \"postalCode\": \"80012\",\n \"country\": \"US\",\n \"phone\": \"512-111-2222\",\n \"residential\": true\n },\n \"returnAddress\": null,\n \"isDefault\": false\n}") client := &http.Client { } req, err := http.NewRequest(method, url, payload) if err != nil { fmt.Println(err) } req.Header.Add("Host", "ssapi.shipstation.com") req.Header.Add("Authorization", "__YOUR_AUTH_HERE__") req.Header.Add("Content-Type", "application/json") res, err := client.Do(req) defer res.Body.Close() body, err := ioutil.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Python Requests Example Source: https://www.shipstation.com/docs/api/warehouses/get This Python example uses the 'requests' library to make a GET request for warehouse data. It defines the URL, headers, and payload. Remember to replace '__YOUR_AUTH_HERE__'. ```python import requests url = "https://ssapi.shipstation.com/warehouses/warehouseId" payload = {} headers = { 'Host': 'ssapi.shipstation.com', 'Authorization': '__YOUR_AUTH_HERE__' } response = requests.request("GET", url, headers=headers, data = payload) print(response.text.encode('utf8')) ``` -------------------------------- ### Go HTTP Request Setup Source: https://www.shipstation.com/docs/api/orders/create-update-multiple-orders This Go code demonstrates how to set up an HTTP client and create a new POST request for the ShipStation API. It includes adding necessary headers like Host, Authorization, and Content-Type. ```go client := &http.Client { } req, err := http.NewRequest(method, url, payload) if err != nil { fmt.Println(err) } req.Header.Add("Host", "ssapi.shipstation.com") req.Header.Add("Authorization", "__YOUR_AUTH_HERE__") req.Header.Add("Content-Type", "application/json") res, err := client.Do(req) deffer res.Body.Close() body, err := ioutil.ReadAll(res.Body) fmt.Println(string(body)) ``` -------------------------------- ### List Marketplaces using Go HTTP Client Source: https://www.shipstation.com/docs/api/stores/list-marketplaces This Go program demonstrates how to list marketplaces using the standard net/http package. Replace '__YOUR_AUTH_HERE__' with your authorization token. ```go package main import ( "fmt" "net/http" "io/ioutil" ) func main() { url := "https://ssapi.shipstation.com/stores/marketplaces" method := "GET" client := &http.Client { } req, err := http.NewRequest(method, url, nil) if err != nil { fmt.Println(err) } req.Header.Add("Host", "ssapi.shipstation.com") req.Header.Add("Authorization", "__YOUR_AUTH_HERE__") res, err := client.Do(req) defer res.Body.Close() body, err := ioutil.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### C# OkHttp Example Source: https://www.shipstation.com/docs/api/warehouses/get This C# example uses OkHttpClient to perform a GET request for warehouse data. It builds the request with the specified URL and headers. Replace '__YOUR_AUTH_HERE__' with your authorization token. ```csharp OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://ssapi.shipstation.com/warehouses/warehouseId") .method("GET", null) .addHeader("Host", "ssapi.shipstation.com") .addHeader("Authorization", "__YOUR_AUTH_HERE__") .build(); Response response = client.newCall(request).execute(); ``` -------------------------------- ### Ruby Net::HTTP for Products Source: https://www.shipstation.com/docs/api/products/list This example demonstrates how to fetch product data using Ruby's Net::HTTP library. ```ruby require "uri" require "net/http" url = URI("https://ssapi.shipstation.com/products?sku=sku&name=name&productCategoryId=productCategoryId&productTypeId=productTypeId&tagId=tagId&startDate=startDate&endDate=endDate&showInactive=showInactive&sortBy=sortBy&sortDir=sortDir&page=page&pageSize=pageSize") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Get.new(url) request["Host"] = "ssapi.shipstation.com" request["Authorization"] = "__YOUR_AUTH_HERE__" response = https.request(request) puts response.read_body ``` -------------------------------- ### C# RestSharp Example Source: https://www.shipstation.com/docs/api/warehouses/get This C# example uses the RestSharp library to make a GET request to retrieve warehouse information. It configures the client, request, and headers. Ensure '__YOUR_AUTH_HERE__' is replaced. ```csharp var client = new RestClient("https://ssapi.shipstation.com/warehouses/warehouseId"); client.Timeout = -1; var request = new RestRequest(Method.GET); request.AddHeader("Host", "ssapi.shipstation.com"); request.AddHeader("Authorization", "__YOUR_AUTH_HERE__"); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content); ``` -------------------------------- ### Python Requests Example Source: https://www.shipstation.com/docs/api/stores/get-store This Python script uses the 'requests' library to get store information. ```Python import requests url = "https://ssapi.shipstation.com/stores/storeId" payload = {} headers = { 'Host': 'ssapi.shipstation.com', 'Authorization': '__YOUR_AUTH_HERE__' } response = requests.request("GET", url, headers=headers, data = payload) print(response.text.encode('utf8')) ``` -------------------------------- ### Create Warehouse with Ruby Source: https://www.shipstation.com/docs/api/warehouses/create This Ruby example demonstrates how to create a warehouse using Net::HTTP. Remember to substitute '__YOUR_AUTH_HERE__' with your authorization credentials. ```ruby require "uri" require "net/http" url = URI("https://ssapi.shipstation.com/warehouses/createwarehouse") https = Net::HTTP.new(url.host, url.port); https.use_ssl = true request = Net::HTTP::Post.new(url) request["Host"] = "ssapi.shipstation.com" request["Authorization"] = "__YOUR_AUTH_HERE__" request["Content-Type"] = "application/json" request.body = "{\n \"warehouseName\": \"New Ship From Location\",\n \"originAddress\": {\n \"name\": \"NM Warehouse\",\n \"company\": \"White Sands Co.\",\n \"street1\": \"4704 Arabela Dr.\",\n \"street2\": null,\n \"street3\": null,\n \"city\": \"Las Cruces\",\n \"state\": \"NM\",\n \"postalCode\": \"80012\",\n \"country\": \"US\",\n \"phone\": \"512-111-2222\",\n \"residential\": true\n },\n \"returnAddress\": null,\n \"isDefault\": false\n}" response = https.request(request) puts response.read_body ``` -------------------------------- ### cURL Request Example Source: https://www.shipstation.com/docs/api/carriers/get Shows how to make a GET request to the carrier endpoint using cURL. ```Shell curl -iX GET 'https://ssapi.shipstation.com/carriers/getcarrier?carrierCode={carrierCode}' \ -H 'Authorization: __YOUR_AUTH_HERE__' ``` -------------------------------- ### PowerShell Request Example Source: https://www.shipstation.com/docs/api/orders/get-order This PowerShell script demonstrates how to fetch order information. ```PowerShell $headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]" $headers.Add("Host", "ssapi.shipstation.com") $headers.Add("Authorization", "__YOUR_AUTH_HERE__") $response = Invoke-RestMethod 'https://ssapi.shipstation.com/orders/orderId' -Method 'GET' -Headers $headers -Body $body $response | ConvertTo-Json ``` -------------------------------- ### HTTP Request Example Source: https://www.shipstation.com/docs/api/carriers/get Demonstrates the structure of an HTTP GET request to retrieve carrier information. ```HTTP GET /carriers/getcarrier?carrierCode={carrierCode} HTTP/1.1 Host: ssapi.shipstation.com Authorization: __YOUR_AUTH_HERE__ ``` -------------------------------- ### Swift: Get Shipping Rates Source: https://www.shipstation.com/docs/api/shipments/get-rates This Swift example shows how to make a POST request to get shipping rates. It configures the request with necessary headers and a JSON body, then sends it using URLSession. ```Swift var semaphore = DispatchSemaphore (value: 0) let parameters = "{\n \"carrierCode\": \"fedex\",\n \"serviceCode\": null,\n \"packageCode\": null,\n \"fromPostalCode\": \"78703\",\n \"toState\": \"DC\",\n \"toCountry\": \"US\",\n \"toPostalCode\": \"20500\",\n \"toCity\": \"Washington\",\n \"weight\": {\n \"value\": 3,\n \"units\": \"ounces\"\n },\n \"dimensions\": {\n \"units\": \"inches\",\n \"length\": 7,\n \"width\": 5,\n \"height\": 6\n },\n \"confirmation\": \"delivery\",\n \"residential\": false\n}" let postData = parameters.data(using: .utf8) var request = URLRequest(url: URL(string: "https://ssapi.shipstation.com/shipments/getrates")!,timeoutInterval: Double.infinity) request.addValue("ssapi.shipstation.com", forHTTPHeaderField: "Host") request.addValue("__YOUR_AUTH_HERE__", forHTTPHeaderField: "Authorization") request.addValue("application/json", forHTTPHeaderField: "Content-Type") request.httpMethod = "POST" request.httpBody = postData let task = URLSession.shared.dataTask(with: request) { data, response, error in guard let data = data else { print(String(describing: error)) return } print(String(data: data, encoding: .utf8)!) semaphore.signal() } task.resume() semaphore.wait() ``` -------------------------------- ### PowerShell Request Example Source: https://www.shipstation.com/docs/api/stores/get-store This PowerShell script demonstrates how to fetch store data. ```PowerShell $headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]" $headers.Add("Host", "ssapi.shipstation.com") $headers.Add("Authorization", "__YOUR_AUTH_HERE__") $response = Invoke-RestMethod 'https://ssapi.shipstation.com/stores/storeId' -Method 'GET' -Headers $headers -Body $body $response | ConvertTo-Json ``` -------------------------------- ### Java OkHttp Example Source: https://www.shipstation.com/docs/api/orders/list-by-tag Illustrates listing orders by tag using OkHttp in Java. ```Java OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://ssapi.shipstation.com/orders/listbytag?orderStatus=orderStatus&tagId=tagId&page=page&pageSize=pageSize") .method("GET", null) .addHeader("Host", "ssapi.shipstation.com") .addHeader("Authorization", "__YOUR_AUTH_HERE__") .build(); Response response = client.newCall(request).execute(); ``` -------------------------------- ### Example Response for Get Store API Source: https://www.shipstation.com/docs/api/stores/get-store This JSON object represents a successful response from the Get Store API. It includes store identification, marketplace information, integration details, and status mapping configurations. ```json { "storeId": 12345, "storeName": "WooCommerce Store", "marketplaceId": 36, "marketplaceName": "WooCommerce", "accountName": null, "email": null, "integrationUrl": "http://shipstation-test.wpengine.com", "active": true, "companyName": "", "phone": "", "publicEmail": "", "website": "", "refreshDate": "2014-12-16T17:47:05.457", "lastRefreshAttempt": "2014-12-16T09:47:05.457", "createDate": "2014-11-06T15:21:13.223", "modifyDate": "2014-11-10T08:02:19.117", "autoRefresh": true, "statusMappings": [ { "orderStatus": "awaiting_payment", "statusKey": "Pending" }, { "orderStatus": "awaiting_shipment", "statusKey": "Processing" }, { "orderStatus": "shipped", "statusKey": "Completed" }, { "orderStatus": "cancelled", "statusKey": "Cancelled" }, { "orderStatus": "on_hold", "statusKey": "On-hold" } ] } ``` -------------------------------- ### Ruby Net::HTTP for Get Refresh Status Source: https://www.shipstation.com/docs/api/stores/get-refresh-status An example using Ruby's built-in `Net::HTTP` library to get store refresh status. Ensure `storeId` and `__YOUR_AUTH_HERE__` are correctly configured. ```Ruby require "uri" require "net/http" url = URI("https://ssapi.shipstation.com/stores/getrefreshstatus?storeId=storeId") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Get.new(url) request["Host"] = "ssapi.shipstation.com" request["Authorization"] = "__YOUR_AUTH_HERE__" response = https.request(request) puts response.read_body ``` -------------------------------- ### Register Account with Java (OkHttp) Source: https://www.shipstation.com/docs/api/accounts/create This Java example uses OkHttp to register a new account. It demonstrates setting up the client, request, headers, and body. ```java OkHttpClient client = new OkHttpClient().newBuilder() .build(); MediaType mediaType = MediaType.parse("application/json"); RequestBody body = RequestBody.create(mediaType, "{\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"email\": \"jsmithtest@gmail.com\",\n \"password\": \"testpw1234\",\n \"shippingOriginCountryCode\": \"US\",\n \"companyName\": \"Droid Repair LLC\",\n \"addr1\": \"542 Midichlorian Rd.\",\n \"addr2\": \"\",\n \"city\": \"Austin\",\n \"state\": \"TX\",\n \"zip\": \"78703\",\n \"countryCode\": \"US\",\n \"phone\": \"5124111234\"\n}"); Request request = new Request.Builder() .url("https://ssapi.shipstation.com/accounts/registeraccount") .method("POST", body) .addHeader("Host", "ssapi.shipstation.com") .addHeader("Content-Type", "application/json") .build(); Response response = client.newCall(request).execute(); ```