API Help

Introduction

GunsAmerica selling APIs enable dealers to manage their sales by using simple REST API. In 2016 we introduced Bulk Upload, where inventory is managed by uploading a .CSV file containing the entire inventory. The new GunsAmerica APIs infrastructure provides major advancement over traditional Bulk Upload. With our new APIs dealers are able to incorporate their sales and listings from GunsAmerica into their system or their web site.

Overview

GunsAmerica selling APIs are built on the latest RESTfull and JSON technologies and are secured with OAuth 2.0 protocol.

We are using seller stock number based inventory management, which allows you to manage multiple listings by your internal stock number rather than by the listing IDs.

Currently there is 1 selling API:

  • Inventory

The Base URL for all api calls is: https://functions-prod.gunsamerica.com/

Inventory API

The inventory API allows sellers to manage their inventory on GunsAmerica web site. It allows users to post and update items to GunsAmerica web site or to the Seller Store (if there is one). Items are managed by the seller stock number instead of listing id.

Restrictions:

  • Seller stock numbers can only be listed once on GunsAmerica.
  • In cases where an item with the same seller stock number already exists on the seller’s account that item cannot be created/posted by the Inventory API.
  • If the item that is posted by API is edited on GunsAmerica that item becomes a manual listing and cannot be updated by the Inventory API anymore.

Authentication

All GunsAmerica APIs use OAuth 2.0 protocol for application authentication and user authorization. To access our API, you will first need to obtain an access token from GunsAmerica access token service by providing your Client ID and Client secret.

All requests made to GunsAmerica REST operations require the authorization HTTP header for authentication

To obtain Client Id and Client secret you must sign up for GA API.

Obtaining OAuth access token

The request requires the following values:

  • ClientID – your client id (provided to you when you sign up for the service).
  • ClientSecret – Base64-encoded string (provided to you when you sign up for the service).
  • OAuth scope(s) – required for access to the REST interfaces.

Access token Request example:

HTTP method: POST

URL: https://functions-prod.gunsamerica.com/api/identity/connect/token

HTTP headers:

content-type: application/x-www-form-urlencoded

Request body

grant_type:”client_credentials”

scope:”InventoryServiceAPI”

client_id:”TestSeller”

client_secret:”XXXXX-XXX-XXXX-XXXX-XXXXXXX”

Response Body

access_token:”5404d41b24a788u9khknhd0eac9360092″

expires_in:3600

token_type:”Bearer”

Inventory API Reference

GET Inventory

 

{{url}}/api/inventory

Returns uploaded inventory on GunsAmerica associated with the dealer account.

HEADERS

The authorization header is the only required HTTP header for this call.

HeaderData TypeDescription
Content-Typeapplication/jsonThe format and encoding of the request message
AuthorizationOAuth 2.0 access tokenOAuth 2.0 protocol used for application authentication and user authorization

 

RESPONSE

FieldTypeDescription
AddToGAbooleanIs item posted to GA Listings
ListingTypeint
  • 0 – National
  • 2 – Local
CaliberstringThe caliber that item uses Required if firearm
CategoryIDintGunsAmerica category Id
CategoryNamestringGunsAmerica category name
ConditionintItem Condition:

  • 0 – New in Box
  • 1 – Used
  • 2 – Never Fired
CountOfDropsintCount of quantity reduced
DeletedOndatetimeWhen the item was deleted
DescriptionStringItem description
ErrorstringList of errors if any
FixedPricedecimalItem price
ItemIDintInventory item id
ListingIdintListing Id
ListingUrlstringURL of listing on GunsAmerica
ListingStatusstringLast listing status:

  • CREATED
  • DROP – Listing has been deleted
  • MANUAL – You have a listing with the same seller stock number as a manual listing on GunsAmerica
  • UPDATED
ListingDurationintNumber of days before listings ends
ManufacturerstringName of manufacturer Required
MfgPartNumberstringManufacturer
ModelstringName of model Required if firearm
ModifiedOndatetimeModified date time
PictureURLsstringComma delimited image URLs
QuantityintQuantity
SerialNumberstringDeprecated use Seller stock number instead
ShippingCoststringShipping cost, if no cost is entered shipping will default to free
ShippingTextstringShipping text
TitlestringItem title
UPCstringItem UPC
WeightdecimalItem weight in pounds

GET Inventory Item

{{url}}/api/inventory/{your seller stock number}

Returns an item that matches your seller stock number.

HEADERS

The authorization header is the only required HTTP header for this call.

HeaderData TypeDescription
Content-Typeapplication/jsonThe format and encoding of the request message
AuthorizationOAuth 2.0 access tokenOAuth 2.0 protocol used for application authentication and user authorization

 

INPUT – URI parameters

ParameterData TypeDescription
idstringSeller stock number

Required

 

RESPONSE

FieldData TypeDescription
AddToGAbooleanIs item posted to GA Listings
ListingTypeint
  • 0 – National
  • 2 – Local
CaliberstringThe caliber that item uses Required if firearm
CategoryIDintGunsAmerica category Id
CategoryNamestringGunsAmerica category name
ConditionintItem Condition:

  • 0 – New in Box
  • 1 – Used
  • 2 – Never Fired
CountOfDropsintCount of quantity reduced
DeletedOndatetimeWhen the item was deleted
DescriptionStringItem description
ErrorstringList of errors if any
FixedPricedecimalItem price
ItemIDintInventory item id
ListingIdintListing Id
ListingUrlstringURL of listing on GunsAmerica
ListingStatusstringLast listing status:

  • CREATED
  • DROP – Listing has been deleted
  • MANUAL – You have a listing with the same seller stock number as a manual listing on GunsAmerica
  • UPDATED
ManufacturerstringName of manufacturer Required
MfgPartNumberstringManufacturer
ModelstringName of model Required if firearm
ModifiedOndatetimeModified date time
PictureURLsstringComma delimited image URLs
QuantityintQuantity
SerialNumberstringDeprecated use Seller stock number instead
ShippingCoststringShipping cost, if no cost is entered shipping will default to free
ShippingTextstringShipping text
TitlestringItem title
UPCstringItem UPC
WeightdecimalItem weight
WeightUnitintItem weight in pounds

 

RESPONSE CODES

This call returns one of the following HTTP status codes:

StatusDescription
200OK
400Bad Request
404Not Found
500Internal Server Error

POST Inventory Item

{{url}}/api/inventory/

This API enables you to create (post listing) or update inventory item.

Important notes/rules:

If the same seller stock number is listed manually the item will not be created.

If you edit a listing on GunsAmerica that is created by API or bulk upload, that listing cannot be updated anymore by API/Bulk upload.

If the item has already been posted to your inventory an UPDATE will be performed. In this case the fields that are not sent and not required will not be updated. For example if you only send required fields and Item Title, only the Title (plus required fields) will be updated. Other fields will be ignored.

Once item quantity reaches 0 the listing will be made inactive.

You can create listings with limited data: UPC, Price, Seller Stock Number, & Condition. This will create listings with manufacture specification data, including descriptions and pictures. 

If UPC is not provided: Manufacturer, Model, Category ID, Caliber, Seller stock number, PictureURL, Title, Price, Quantity, Weight, Condition, and Description are required.

HEADERS

HeaderData TypeDescription
Content-Typeapplication/jsonThe format and encoding of the request message.
AuthorizationOAuth 2.0 access tokenOAuth 2.0 protocol used for application authentication and user authorization.

INPUT – JSON

FieldData TypeDescription
AddToGAbooleanList item on GA Listings
ListingTypeint
  • 0 – National
  • 2 – Local
CaliberstringThe caliber that item uses

Required if UPC is not provided

CategoryIDintValid GunsAmerica Category ID

Required if UPC is not provided

DescriptionStringItem description. Non ASCII characters will be removed. If length is > 5000, the rest is truncated.
ConditionintItem Condition:

  • 0 – New in Box
  • 1 – Used
  • 2 – Never Fired

Required

FixedPricedecimalItem price

Required

ManufacturerstringName of manufacturer

Required if UPC is not provided

MfgPartNumberstringItem part number
ModelstringName of model

Required if UPC is not provided

PictureURLsstringComma delimited image URLs

Required if UPC is not provided

QuantityintQuantity

Required

SerialNumberstringDeprecated use Seller stock number instead

Required

ShippingCoststringShipping cost, if no cost is entered shipping will default to free
ShippingTextstringShipping text. Non ASCII characters will be removed. Maximum 500 characters.
TitlestringItem title

Required if UPC is not provided

UPCstringItem UPC if available
WarningstringWarning messages
WeightdecimalItem weight
WeightUnitint Item weight in pounds

 

RESPONSE CODES

This call returns one of the following HTTP status codes:

StatusDescription
200OK
201Created
400Bad Request
404Not Found
500Internal Server Error

This call will return created or updated inventory items.

Status can be:

  • CREATED
  • UPDATED
  • MANUAL
  • DROP
  • NO CHANGE

The returned item will also have a list of error messages if any.

POST ITEM Request example:

var settings = {

“async”: true,

“crossDomain”: true,

“url”: “http://{{url}}/api/inventory/”,

“method”: “POST”,

“headers”: {

“Content-Type”: “application/json”

},

“processData”: false,

“data”: “{

“CategoryID”: 4,

“Condition”: 2,

“Description”: “For sale is a Glock 19 gen 5 chambered in 9mm!”,

“FixedPrice” : “600”,

“MfgPartNumber” : ,

“SerialNumber” : “135686-mro997”,

“UPC” : “723175704183”,

“ShippingCost”: 19.99,

“ShippingText”:”not expensive shipping…

only $19.99″,

“Title”:”Glock 19 gen 5 w/ 3 mags and add ons!”,

“Quantity”:5,

“ShippingCost”:30,

“AddToGA”:”true”,

“AddToLSF”:”true”

}”

}

 

$.ajax(settings).done(function (response) {

console.log(response);

});

 

POST ITEM response example:

{

“ItemID”: 246266,

“ListingId”: 933227534,

“ListingStatus”: “CREATED”,

“ListingUrl”: “https://gunsamerica.com/firearms/handguns/semi-auto/Glock/19?p=3a57e6b9-6603-43db-95cf-b70f00e22985”,

“Message”: null,

“ModifiedOn”: “2017-12-29T01:24:31.567”,

“DeletedOn”: null,

“Error”: [],

“Warning”: [],

“AddToGA”: true,

“AddToLSF”: true,

“BuyNowPrice”: null,

“CategoryID”: 894,

“CategoryName”: null,

“Condition”: 2,

“ConditionDescription”: “NIB”,

“CountOfDrops”: 0,

“Description”: “For sale is a Glock 19 gen 5 chambered in 9mm!”,

“FixedPrice”: 600,

“InspectionPeriod”: 14,

“MfgPartNumber”: “glock”,

“ListingDuration”: null,

“PictureURLs”: null,

“Quantity”: 5,

“ReserverPrice”: null,

“SerialNumber”: “135686-mro997”,

“ShippingCost”: 19.99,

“ShippingText”: “not very expensive shipping… <br>only $19.99”,

“SKU”: “JRC10G3-TB/BL”,

“Title”: “Glock 19 gen 5 w/ 3 mags and add ons!”,

“UPC”: “723175704183”,

“Weight”: 0,

“WeightUnit”: 0

}

 

DELETE Inventory Item

{{url}}/api/inventory/{your seller stock number}

This will mark your uploaded item as deleted. Listings with the same seller stock number that are not manually listed will become inactive.

HEADERS

HeaderData TypeDescription
Content-Typeapplication/jsonThe format and encoding of the request message.
AuthorizationOAuth 2.0 access tokenOAuth 2.0 protocol used for application authentication and user authorization.

INPUT – URI parameters

ParameterData TypeDescription
idstringSeller stock number

Required

RESPONSE

This call returns one of the following HTTP status codes:

StatusDescription
200OK
400Bad Request
404Not Found
500Internal Server Error

 

Leave a Reply