amazonproduct

package module
v0.0.0-...-1c2c2bc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 29, 2019 License: MIT Imports: 12 Imported by: 3

README

Simple library to simplify grabbing and posting data from the Amazon Affiliate API

Build Status MIT GODOC

Have a look at the go docs here: http://godoc.org/github.com/DDRBoxman/go-amazon-product-api

Example


package main

import (
	"fmt"
	"net/http"
	"encoding/xml"
	"github.com/DDRBoxman/go-amazon-product-api"
)

func main() {
	var api amazonproduct.AmazonProductAPI

	api.AccessKey = ""
	api.SecretKey = ""
	api.Host = "webservices.amazon.com"
	api.AssociateTag = ""
	api.Client = &http.Client{} // optional

	result,err := api.ItemSearchByKeyword("sgt+frog", 0)
	if (err != nil) {
		fmt.Println(err)
	}

	fmt.Println(result)


	//Parse result
	if err == nil {
		aws := new(amazonproduct.ItemLookupResponse)
		xml.Unmarshal([]byte(result), aws)
		//TODO: Use "aws" freely :-)
	}
}

Documentation

Overview

Package amazonproduct provides methods for interacting with the Amazon Product Advertising API

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateAmazonUrl

func GenerateAmazonUrl(api AmazonProductAPI, Operation string, Parameters map[string]string) (finalUrl *url.URL, err error)

func SetTimestamp

func SetTimestamp(origUrl *url.URL) (err error)

func SignAmazonUrl

func SignAmazonUrl(origUrl *url.URL, api AmazonProductAPI) (signedUrl string, err error)

Types

type AWSResponse

type AWSResponse struct {
	OperationRequest struct {
		RequestID             string     `xml:"RequestId"`
		Arguments             []Argument `xml:"Arguments>Argument"`
		RequestProcessingTime float64
	}
}

Response describes the generic API Response

type AmazonProductAPI

type AmazonProductAPI struct {
	AccessKey    string
	SecretKey    string
	AssociateTag string
	Host         string
	Client       *http.Client
}

func (AmazonProductAPI) BrowseNodeLookup

func (api AmazonProductAPI) BrowseNodeLookup(nodeId string) (string, error)

BrowseNodeLookup takes a BrowseNodeId and returns the result.

func (AmazonProductAPI) BrowseNodeLookupWithResponseGroup

func (api AmazonProductAPI) BrowseNodeLookupWithResponseGroup(nodeId string, responseGroup string) (string, error)

func (AmazonProductAPI) CartAdd

func (api AmazonProductAPI) CartAdd(items map[string]int, cartid, HMAC string) (string, error)

CartAdd takes a map containing ASINs and quantities and adds them to the given cart. Up to 10 items are allowed

func (AmazonProductAPI) CartClear

func (api AmazonProductAPI) CartClear(CartId, HMAC string) (string, error)

CartClear takes a CartId and HMAC that were returned when generating a cart It then removes the contents of the cart

func (AmazonProductAPI) CartCreate

func (api AmazonProductAPI) CartCreate(items map[string]int) (string, error)

CartCreate takes a map containing ASINs and quantities. Up to 10 items are allowed

func (AmazonProductAPI) CartGet

func (api AmazonProductAPI) CartGet(CartId, HMAC string) (string, error)

Cart get takes a CartID and HMAC that were returned when generating a cart Returns the contents of the specified cart

func (AmazonProductAPI) ItemLookup

func (api AmazonProductAPI) ItemLookup(ItemId string) (string, error)

ItemLookup takes a product ID (ASIN) and returns the result

func (AmazonProductAPI) ItemLookupWithParams

func (api AmazonProductAPI) ItemLookupWithParams(params map[string]string) (string, error)

ItemLookupWithParams takes the params for ItemLookup and returns the result

func (AmazonProductAPI) ItemLookupWithResponseGroup

func (api AmazonProductAPI) ItemLookupWithResponseGroup(ItemId string, ResponseGroup string) (string, error)

ItemLookupWithResponseGroup takes a product ID (ASIN) and a ResponseGroup and returns the result

func (AmazonProductAPI) ItemSearch

func (api AmazonProductAPI) ItemSearch(SearchIndex string, Parameters map[string]string) (string, error)

func (AmazonProductAPI) ItemSearchByKeyword

func (api AmazonProductAPI) ItemSearchByKeyword(Keywords string, page int) (string, error)

ItemSearchByKeyword takes a string containing keywords and returns the search results

func (AmazonProductAPI) ItemSearchByKeywordWithResponseGroup

func (api AmazonProductAPI) ItemSearchByKeywordWithResponseGroup(Keywords string, ResponseGroup string) (string, error)

func (AmazonProductAPI) MultipleItemLookup

func (api AmazonProductAPI) MultipleItemLookup(ItemIds []string) (string, error)

MultipleItemLookup takes an array of product IDs (ASIN) and returns the result

func (AmazonProductAPI) MultipleItemLookupWithResponseGroup

func (api AmazonProductAPI) MultipleItemLookupWithResponseGroup(ItemIds []string, ResponseGroup string) (string, error)

MultipleItemLookupWithResponseGroup takes an array of product IDs (ASIN) as well as a ResponseGroup and returns the result

type Argument

type Argument struct {
	Name  string `xml:"Name,attr"`
	Value string `xml:"Value,attr"`
}

Argument todo

type BrowseNode

type BrowseNode struct {
	BrowseNodeID string `xml:"BrowseNodeId"`
	Name         string
	TopSellers   struct {
		TopSeller []TopSeller
	}
	Ancestors struct {
		BrowseNode []BrowseNode
	}
}

BrowseNode represents a browse node returned by API

type BrowseNodeLookupRequest

type BrowseNodeLookupRequest struct {
	BrowseNodeId  string
	ResponseGroup string
}

BrowseNodeLookupRequest is the confirmation of a BrowseNodeInfo request

type BrowseNodeLookupResponse

type BrowseNodeLookupResponse struct {
	AWSResponse
	BrowseNodes struct {
		Request struct {
			IsValid                 bool
			BrowseNodeLookupRequest BrowseNodeLookupRequest
		}
		BrowseNode BrowseNode
	}
}

type Creator

type Creator struct {
	Role  string `xml:"Role,attr"`
	Value string `xml:",chardata"`
}

Creator element in ItemAttributes

type EditorialReview

type EditorialReview struct {
	Source  string
	Content string
}

EditorialReview response attribute

type EditorialReviews

type EditorialReviews struct {
	EditorialReview EditorialReview
}

EditorialReviews response group

type Image

type Image struct {
	URL    string
	Height uint16
	Width  uint16
}

Image todo

type ImageSet

type ImageSet struct {
	//Category string `xml:"Category,attr"`
	Category       string `xml:",attr"`
	SwatchImage    *Image
	SmallImage     *Image
	ThumbnailImage *Image
	TinyImage      *Image
	MediumImage    *Image
	LargeImage     *Image
}

type ImageSets

type ImageSets struct {
	ImageSet []ImageSet
}

type Item

type Item struct {
	ASIN             string
	URL              string
	DetailPageURL    string
	ItemAttributes   *ItemAttributes
	OfferSummary     OfferSummary
	Offers           Offers
	SalesRank        int
	SmallImage       *Image
	MediumImage      *Image
	LargeImage       *Image
	ImageSets        *ImageSets
	EditorialReviews EditorialReviews
	BrowseNodes      struct {
		BrowseNode []BrowseNode
	}
}

Item represents a product returned by the API

type ItemAttributes

type ItemAttributes struct {
	Author          []string
	Binding         string
	Brand           string
	Color           string
	EAN             string
	EISBN           string
	Creator         []Creator
	Title           string
	ListPrice       Price
	Manufacturer    string
	Publisher       string
	NumberOfItems   int
	PackageQuantity int
	Feature         []string
	Model           string
	ProductGroup    string
	PublicationDate string
	ReleaseDate     string
	Studio          string
	Warranty        string
	Size            string
	UPC             string
}

ItemAttributes response group

type ItemLookupRequest

type ItemLookupRequest struct {
	IDType        string `xml:"IdType"`
	ItemID        string `xml:"ItemId"`
	ResponseGroup string `xml:"ResponseGroup"`
	VariationPage string
}

ItemLookupRequest is the confirmation of a ItemLookup request

type ItemLookupResponse

type ItemLookupResponse struct {
	AWSResponse
	Items struct {
		Request struct {
			IsValid           bool
			ItemLookupRequest ItemLookupRequest
		}
		Item []Item `xml:"Item"`
	}
}

ItemLookupResponse describes the API response for the ItemLookup operation

type ItemSearchRequest

type ItemSearchRequest struct {
	Keywords      string `xml:"Keywords"`
	SearchIndex   string `xml:"SearchIndex"`
	ResponseGroup string `xml:"ResponseGroup"`
}

ItemSearchRequest is the confirmation of a ItemSearch request

type ItemSearchResponse

type ItemSearchResponse struct {
	AWSResponse
	Items struct {
		Request struct {
			IsValid           bool
			ItemSearchRequest ItemSearchRequest
		}
		Items                []Item `xml:"Item"`
		TotalResults         int
		TotalPages           int
		MoreSearchResultsUrl string
	}
}

type Offer

type Offer struct {
	Condition          string `xml:"OfferAttributes>Condition"`
	ID                 string `xml:"OfferListing>OfferListingId"`
	IsEligibleForPrime bool   `xml:"OfferListing>IsEligibleForPrime"`
	Price              Price  `xml:"OfferListing>Price"`
	PercentageSaved    uint   `xml:"OfferListing>PercentageSaved"`
	Availability       string `xml:"OfferListing>Availability"`
}

Offer response attribute

type OfferSummary

type OfferSummary struct {
	LowestNewPrice   Price
	LowestUsedPrice  Price
	TotalNew         int
	TotalUsed        int
	TotalCollectible int
	TotalRefurbished int
}

OfferSummary response group

type Offers

type Offers struct {
	TotalOffers     int
	TotalOfferPages int
	MoreOffersURL   string  `xml:"MoreOffersUrl"`
	Offers          []Offer `xml:"Offer"`
}

Offers response group

type Price

type Price struct {
	Amount         uint
	CurrencyCode   string
	FormattedPrice string
}

Price describes the product price as Amount of cents in CurrencyCode

type TopSeller

type TopSeller struct {
	ASIN  string
	Title string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL